acemielektron / fddEMU

AVR (atmega328p) based floppy drive emulator for PC
https://acemielektronikci.blogspot.com/2021/10/fddemu-disket-surucu-emulatoru.html
GNU General Public License v3.0
145 stars 22 forks source link

Confusion around write vs read pins #4

Closed hachi closed 2 years ago

hachi commented 2 years ago

I am confused about the write vs read pin setup in this:

https://github.com/acemielektron/fddEMU/blame/main/README.md#L50..L51 and https://github.com/acemielektron/fddEMU/blame/main/README.md#L69..L70

both have read and write swapped between their left and right columns... and don't line up with the WRITE_GATE pin.

Can you help me understand what is going on? I want to use this with a device that doesn't have a normal cable.

acemielektron commented 2 years ago

İt is like serial comm rx and tx pins, one device's tx pin is connected to other device's rx pin. Floppy drive controller(FDC) writes data to floppy cable's pin 22(writedata) and Arduino nano reads data written by FDC on its D8 pin (readdata). Again nano writes mfm data through its D9 pin(writedata) which is read by FDC on floppy cable's pin 30(readdata). WriteGate is asserted when FDC is writing to floppy so nano listens to what FDC is writing when WriteData signal is asserted (active low). Hope this clears the confusion.

hachi commented 2 years ago

Thanks it does clarify it... though if it ever needs a suggestion I would swap them around because the pins on a drive are opposite of what you have. The drive pinout is labelled WRITE_GATE and WRITE_DATA as input pins because it's operating on the disk media. The same applies to this device.

All this said... thank you for publishing this project. I'm trying to use it as a floppy replacement on an Agilent E4411B Spectrum Analyzer but so far not having perfect success. I need to adjust for better debugging info for me and I'll send a PR back.

acemielektron commented 2 years ago

Thanks it does clarify it... though if it ever needs a suggestion I would swap them around because the pins on a drive are opposite of what you have. The drive pinout is labelled WRITE_GATE and WRITE_DATA as input pins because it's operating on the disk media. The same applies to this device.

I plan to update documentation after I merged atmega32u4 (I have adopted the code to atmega32u4 but I haven't merged that branch yet).

All this said... thank you for publishing this project. I'm trying to use it as a floppy replacement on an Agilent E4411B Spectrum Analyzer but so far not having perfect success. I need to adjust for better debugging info for me and I'll send a PR back.

Please check if you have external pullups on D2(step) and D8(pin which must not be named :) ). If you are compiling yourself you can enable debugging in makefile or make command line. I have tested fddEMU on ArduinoFDC and a couple of PCs (no Spectrum Analyzer sorry), floppy drive controller(FDC) behaviour should be similar if your Spectrum Analyzer has a common FDC chip that speaks MFM, though I can not be sure. Edit: fixed typo

hachi commented 2 years ago

I do have pullups, I've actually added more pullups because I can't quite figure out what is wrong.

D2 and D8 are pulled up, but I've also pulled up D7 and a few others to make sure the signal is clean. I don't have an arduino mini so I'm using an arduino Uno... so I don't have an A7 for input.

I'm watching the output pin on oscilloscope and it's not staying consistent but I'm not sure if it should be. I know your docs say it's not cycle-perfect but I expect it to be consistent.

acemielektron commented 2 years ago

I do have pullups, I've actually added more pullups because I can't quite figure out what is wrong.

D2 and D8 are pulled up, but I've also pulled up D7 and a few others to make sure the signal is clean. I don't have an arduino mini so I'm using an arduino Uno... so I don't have an A7 for input.

External pullups are needed only on the input pins of the micro, D7(index) pin is an output pin, as fddEMU is emulating open collector outputs, pullups for output pins are on FDC side. Atmega's internal pullups are sufficient for most input signals but unfortunately not fast enough for step (D2) and incoming MFM (D8) signals. Actually to simplify test setup write gate (A0) and incoming MFM (D8) can be disconnected for a read only setup.

I'm watching the output pin on oscilloscope and it's not staying consistent but I'm not sure if it should be. I know your docs say it's not cycle-perfect but I expect it to be consistent.

I am not sure what you mean by inconsistent, If drive select (D5) and motor on (D4) signals are asserted (LOW) drive starts spinning and there should be continuous MFM data on output pin (D9). What I meant by not cycle-perfect is fddEMU is not reading SD card and pushing MFM data at the same time atmega328 doesn't have enough ram to cache a full track (18x512 bytes) so it first reads sector from SD card, then pushes converted data on output pin while simultaneously converting it to MFM. So unlike a real floppy drive there are pauses between MFM data bursts. Theoretically it should be possible to output a complete track while reading from SD simultaneously but then writing data to sd becomes impossible. Of course on a more capable microcontroller with more ram, a cycle-exact emulation is possible but there is already open source implementations for stm32f105 based gotek floppy emulator and its clones namely FlashFloppy and OpenFlops.

To eliminate points of failure: If you have spare arduino uno that you can install ArduinoFDC then you can test fddEMU with ArduinoFDC to make sure it is working.