dhansel / ArduinoFDC

Library for using an Arduino as a floppy disk controller
GNU General Public License v3.0
281 stars 41 forks source link

Problem with changing the floppy disk. #11

Closed GSoftwareDevelopment closed 1 year ago

GSoftwareDevelopment commented 1 year ago

Hello.

By way of introduction - great project. I'm just playing with it and I'm going to use it as an interface for Atari 8-bit :) however...

The problem is that changing the floppy disk is not checked. It appears as follows:

  1. I start the project.
  2. I insert a floppy disk
  3. I do for example dir - it shows me that it is empty and the amount of free space
  4. I change the floppy disk to another one
  5. I do dir and again it shows that it is empty and the same amount of free space - it is already suspicious.
  6. I do a reset of Arduino
  7. The same floppy disk as in point 4
  8. I do dir and it shows the contents of the floppy disk - some files.
dhansel commented 1 year ago

Yes, ArduDOS does not automatically detect a disk change. This is shown in the list of limitations (item 3): https://github.com/dhansel/ArduinoFDC#ardudos

To notify ArduDOS that the disk has changed, re-select the curent drive (e.g. "a:" followed by ENTER).

GSoftwareDevelopment commented 1 year ago

Thank you for your quick reply :) and my apologies, I must not have read.

I think you can close the topic. Regards.

GSoftwareDevelopment commented 1 year ago

Or not. :)

What is the reason for the lack of detection?

dhansel commented 1 year ago

Laziness :) I was focused on reading/writing the actual data, which is what the ArduinoFDC library is about. Adding ArduDOS was just an idea to demonstrate what can be done using the library.

Checking whether the disk has changed is not hard. Just connect pin 34 [edit: incorrectly said pin 33 before] of the floppy cable to an unused Arduino pin. In the sketch, call pinMode(pin, INPUT_PULLUP) to configure the input pin. Then you can use if( digitalRead(pin)==LOW ) { /* disk change detected */ } to detect the change.

Note that the pin will continue reading LOW until you clear the "disk change" flag in the drive. The only way to clear that flag is to move the disk drive head. So you'll have to (attempt to) read some sector data on a track different from the one that the head is currently on.

GSoftwareDevelopment commented 1 year ago

heh... I see, I asked because I thought it was something more complicated :)

By the way, thanks for giving the way.

However... pin 33? isn't that GND by any chance? ;) I noticed, while looking for information about the DSKCHG# signal (i.e. pin 34), that - according to Wiki - it's an input pin, which surprises me a bit, that you set pinMode() to INPUT_PULLUP no but.... there's always a chance that there's an error in the Wiki :)

dhansel commented 1 year ago

Oops sorry yes I meant pin 34. I fixed it in my original comment so as to not misinform anybody reading this thread. Thanks for the correction!