Page 2 of 5

Re: Cart Design Questions

Posted: Sat Aug 18, 2018 2:56 pm
by themrcul
Thanks so much for that detailed reply Tiido.

So, there isn't a problem with sending a 0-5v signal through to cart B1/B3? Isn't the Mega Drive expecting a -1v to +1v signal on those lines? If that's not a problem, that's good news.

With the diagrams you kindly posted, how should I go about working out what value the resistors in the diagram should be? Is there some sort of formula I should follow? There appear to be many resistors in the diagram, but I'm unsure about what values they should be or even how to find out what values they should be.
I'm sorry if I am asking too much...
If worse comes to worse I can try using the LM358, biased between 0v and 5v, filtering the output with a capacitor and seeing how I go. If the signal is too loud I can try reducing it with some resistors, hopefully..

Re: Cart Design Questions

Posted: Sat Aug 18, 2018 3:33 pm
by TmEE co.(TM)
MD biases the signals to its own needed offsets, there's series capacitors on all the signals which are there for that purpose. It is all AC coupled. You cannot do full 5V swing for similar reasons as you get in the cart, the machine still only has 5V power rails. You'll have to experimentally find the right gain that won't clip on any hardware.

Bias voltage resistors are only a voltage divider, the calculation to those is found easily online. Biasing resitor depends on what sort of filter response you need (the serier capacitor will from a RC high pass filter), formula is easily found online too. Gain resistors depend on what gain you want. On power buffer side things get more complicated, the first 4 resistors determine idle current and set operating conditions for the transistors and their values are completely dependent on transistors, opamp and what idle current you want. Emmiter resistors are 1ohm range things, higher values are better but will reduce immunity to driving hard loads like 75ohm (output will droop and distortions increase). LM358 has low output current so it might have hard time driving the transistors fully. 1k (from opamp to base) and 68k ohm (base to power rail) might be good starting points. If things distort then you have to reduce the 68k resistor and possibly decrease 1k resistor too.
There are variations that use diodes in place of the 1k resistors but from my experience they limit output swing dramatically for given bias currents and there seems to be no advantages in distortion performance either.

Re: Cart Design Questions

Posted: Tue Aug 21, 2018 11:13 pm
by themrcul
Thanks Tiido. I have done lots of learning since your last post. I know now that the LM358 for example will only output a puny amount of current, and not enough to surmount 75ohms on a model 1 MD, that is why the output goes through a power buffer circuit that you have designed there.

In that case, perhaps the LM358 is not powerful enough and I should be looking at another op-amp entirely.
I have found another op-amp, the NJM2073. This op-amp looks like the ticket. Just like with the circuit you suggested, the NJM2073 needs voltage reduction resistors and filtering capacitors at the inputs and outputs, but the output should be powerful enough to not need a power buffer circuit, which should help to reduce part count and complexity. With the example circuits given in the datasheet for the NJM2073, it appears the negative input can be ground, just like with the LM358.

I am designing a PCB for the Mega Drive in a PCB design software package which uses 3.3V flash, a linear power regulator and voltage steppers, along with jumpers for me to divert stuff to an ARM discovery board once I get that going. After the initial PCB is designed I'll order the parts and get my first PCB made.

Once all those things are in my possession, I can experiment with different voltage reduction and gain settings on the op-amp to find what sounds good and doesn't clip.

My biggest problem now is to find free PCB design software that allows me to place card edge connectors! I've tried 3 so far and am having trouble with all of them either to bugs or missing functionality! I will get there though!

Re: Cart Design Questions

Posted: Wed Aug 22, 2018 4:03 am
by TmEE co.(TM)
All opamps can have the negative power go to GND, and as with all opamps you then have to bias the inputs to somewhere between GND and positive power rail in such case. Now as far as NJM2073 goes, it isn't a regular opamp but a special purpose thing which has internal biasing to reduce external part count. only drawback is that it is a pretty low quality thing with poor THD+N figures but it can drive 75ohm without any drop in output. You will have to make sure the output capacitors are large enough not to kill too much of the lower frequency range. Output capacitor + 75ohm resistor forms a high pass filter. Signal swing will also be limited by power rails,

Card edge connectors are made with multiple pads turned into a component that you can then place whereever you want.

Re: Cart Design Questions

Posted: Thu Aug 23, 2018 10:44 am
by themrcul
Hmmm. It's a shame the NJM2073 looks to be low sound quality.. I have found plenty of linear power regulators which take in up to 6V and spit out both 3.3V and 2.5V - so the mid-point voltage is easily solvable if necessary.
In that case, which op-amp would you choose Tiido if you were me? Do you know of another op-amp that could drive 75ohms well and have good sound quality, while not needing a further power buffer circuit to give it more current? Would the LM4880 be a better bet? (It seems to have many of the same features, similar price, but better THD).

Re: Cart Design Questions

Posted: Fri Aug 24, 2018 2:21 am
by TmEE co.(TM)
LM4880 seems to be adequate. It has better THD and PSRR and looks to be just as easy to use. It should be noted that the output is inverted compared to input (but this has no consequences usually).
Only opamps made to drive 75ohms are video stuff but they're usually unsuitable for audio for the most part. Very noisy in the lower frequencies, easy to make them oscillate and made to work with 1Vpp signals pretty much.
I personally will stick with a high quality opamp such as NJM4580 and a power buffer, I'm after the higher end of performance figures and guaranteed operation.

Re: Cart Design Questions

Posted: Fri Aug 24, 2018 4:00 am
by themrcul
Awesome, thanks Tiido. I think I'll purchase both and experiment when building the op-amp circuit. Can't wait to get started. Need to design the first PCB that holds most of the components together first though!

Re: Cart Design Questions

Posted: Tue Oct 09, 2018 9:25 am
by themrcul
Hi everyone,
8 weeks ago my wife and I had our first baby so things have been very busy but I have been planning and thinking about this project lots regardless!

I now have a question about the pins on the cart and how write low/high works. It's difficult for me to explain so I'll try to use examples to illustrate as best I can.

I note that pin B28 is Lower Byte Write and pin B29 is Upper Byte Write. Both active low, as I understand it.

What I want to know is how they relate to writes, when writing 16 or 8 bit.

When writing 8Bit numbers to even addresses, is pin B28 (lower byte write) taken low and pin B29 left high, and for odd addresses B28 is left high and B29 is taken low? Or visa versa? Or does it work differently?
Like this:
volatile unsigned char* addr = (volatile unsigned char*)(0xA13000);
*addr = 128;
=> This will take pin B28 low, pin B29 will still be high, and pins D0-D8 will form the number 128?

volatile unsigned char* addr = (volatile unsigned char*)(0xA13001);
*addr = 128;
=> This will bring pin B28 high, pin B29 will be taken low, and pins D0-D8 will form the number 128?

When writing 16bit numbers, I assume that both B28 and B29 are taken low, is that correct?

Pins D9-D15 are only utilized when writing a 16bit number, is that correct?
eg: volatile unsigned short* addr = (volatile unsigned char*)(0xA13000);
*addr = 3000;
=> If this relates to memory, then 0xA13000 will have 0B10111000 and 0xA13001 will have 0B00001011, using D0-D15?

I have sincerely looked around but have not been able to learn exactly how the pins on the cartridge work when writing 8bit and 16bit numbers. Any help explaining this to me will be infinitely helpful! Thanks guys.

Re: Cart Design Questions

Posted: Tue Oct 09, 2018 11:48 pm
by Mask of Destiny
themrcul wrote:
Tue Oct 09, 2018 9:25 am
When writing 8Bit numbers to even addresses, is pin B28 (lower byte write) taken low and pin B29 left high, and for odd addresses B28 is left high and B29 is taken low? Or visa versa? Or does it work differently?
!LDSW (B28) goes low (which is the "active" level) for writes to odd addresses and !UDSW (B29) goes low for writes to even addresses. For 16-bit writes, both will go low.

Re: Cart Design Questions

Posted: Wed Oct 10, 2018 12:39 am
by themrcul
Awesome, thanks heaps Mask.
Just to confirm, for 8bit writes, only the first 8 data lines are used, is that correct? Do the upper 8 data lines (D8-D15) go to 0V? Or is their state indeterminate?

Re: Cart Design Questions

Posted: Wed Oct 10, 2018 5:23 am
by TmEE co.(TM)
Low and high bytes contain same data when doing 8 bit writes.

Re: Cart Design Questions

Posted: Wed Oct 10, 2018 5:39 am
by themrcul
You guys are amazing, thanks. How do you know all these things!?

Anyway, so if my interface between the MD and the ARM chip is 8bit, I can just hook up the lower 8 data lines, and hook the write high/write low to an AND gate, so that 0V = WRITE, 5V = READ.
The ARM chip I am looking at now is the ATSAM4SD32BA-AU. It has an External Bus Interface for handling data transfers without interrupts. Even though it is only an 8bit interface, it's timings are highly configurable. From my reading, transfers happen independently from normal CPU operation. Should be fun to experiment.

Re: Cart Design Questions

Posted: Fri May 17, 2019 2:55 am
by themrcul
Hey fellas,
I've been progressing with the design, and I've gone back and forward about needing a CPLD or FPGA for the design to work.
After a lot of thought and research I have come to the conclusion that everyone else was right from the beginning - I will need a CPLD or FPGA if I am hoping to retrieve data from the MCU on the cartridge.

I have mostly designed the initial PCB schematic, but have a few questions I am hoping any of you may know the answer to.

Part of the design I have made is that the EEPROM is writable, so I can do testing and iteration on of my game engine, and experiment with different ways the MD can communicate with the MCU. If there is ever a commercial release, the functionality to write to the EEPROM will not be necessary I spose, but for this stage of the project it is essential.

My plan is to create a separate device which has a MD cart port where I can plug the cartridge into, and an MCU and required USB connectivity so that I can plug it up to my computer via USB and flash the EEPROM that way, then plug the cartridge back into the MD for testing.
The CPLD and MCUs on the board will have their own JTAG jumpers that I can use to update the software on those chips for testing/iteration.

The difficult part is facilitating EEPROM writing using the standard MD cart connector, without breaking functionality when the PCB is plugged into a real Mega Drive, as almost all lines are output lines from the MD to the cartridge.
The EEPROM chip has a hardware "busy" line which I would like to hook up to one of the MD cartridge lines, so that I can communicate to the device that writes to the EEPROM that it is busy writing and to wait until it isn't before sending more data across to write to the EEPROM.

Looking at the pinout for the MD cart, there is one spare input line, /DTACK.
I have read as much as I can about that line, and looked at other cartridge PCBs - most don't have it hooked up.
From what I understand, /DTACK is asserted by the bus arbiter during normal operation anyway.
I am hoping to hook the EEPROM busy flag line up to /DTACK.

The busy line on the EEPROM I am thinking of using is an open drain output pin. When the output of the pin is low, the device is busy. When it is high, it is ready.
Also of note is that the EEPROM is a 3.3V device.

Does the /DTACK on the MD active low? Will this work the way I am thinking of?
Is it electrically safe to hook an open drain ready/busy line from a 3.3V device up to /DTACK? Or should I feed that line through the CPLD to the /DTACK line and internally disable it unless the CPLD knows the system is trying to write to the EEPROM?

Or would you guys solve the issue in a completely different way that I haven't thought of yet?

Re: Cart Design Questions

Posted: Fri May 17, 2019 3:23 pm
by Chilly Willy
Note that a number of FPGAs have MCUs built into them. ARM+FPGA is actually pretty common.

An active low open drain /DTACK should work on the MD, but remember that /DTACK goes low when the memory is ready, not when it's waiting.

Re: Cart Design Questions

Posted: Fri May 17, 2019 11:59 pm
by themrcul
Thanks very much Chilly.
Just so I understand what is going on electrically:
The EEPROM will expect the line to drift high with a pull-up resistor. The MD expects the signal to be low to signify "ready".
If the line from the EEPROM is hooked up to the MD directly *without* a pull-up resistor to 3.3V, the line will always be low and therefore the MD will always see that the line is ready. This should be fine as most cartridges don't hook the /DTACK line up anyway, which is the same as signifying "ready" all the time.
However on the separate device I am making to write to the EEPROM, I can put a pull-up resistor in between the MCU on that board to the cartridge connector, which will make that line float up to 3.3V when ready.
When the EEPROM wants to signify "busy" it will pull that line down, and the MCU it is connected to will see that the EEPROM is busy.

Am I understanding that correctly?


I had a brief look into ARM+FPGA duos, but that solution appeared to be expensive.
The ARM chip I am looking at has 2MB of it's own storage (that I can use for sound data), 128KB of SRAM, and a 2 channel, 12 bit DAC, for $4.50.
The CPLD is the Intel Max V, which for the 100 pin version which would facilitate 16bit communication between the MD and ARM is only $2.70.
If I was happy with 8bit, then I could probably drop down to the 64pin version which is only $1.30.

The ARM+FPGA combos seemed to start at $10+ and didn't have the internal storage or DAC options that I was looking for. But the concept is fantastic.