Go Down

Topic: Simple reading and writing on Floppy Disk (Read 397 times) previous topic - next topic

slune

Hi - I am trying to interface a 3.5" floppy drive (read and write data onto floppy disc). Since I need to write just few bit long number on it (16 is more than enough) I am thinking I could write it track-wise (each track is one bit), which gives me teoretically 80 bit long number, so I could write 4 times 16 bit long number for some redundancy.

I found this code, which solves reading data out. For writing I found this page which says, that writing should be similar easy process.

I attached code I am running. Reading seems to work, but writing not. The interesting part of code is:
Code: [Select]

void writeData(byte data){
  Serial.println("Writing");
  digitalWrite(writeEnablePin, LOW); //starting spining a motor
  digitalWrite(motorEnableBPin, LOW); //enabling motorEnable
  stepAllTheWayOut(); //moving head to the edge of drive
  for(unsigned i = 0; i<10; i++){ //repeating 10 times
    for(unsigned index = 0; index<=8; index++){ //repeating 8 times (there are 80 tracks)
      digitalWrite(writeDataPin,bitRead(data,index)); //setting data pin
      Serial.print(bitRead(data,index)); //printing out what is being written
      delay(500); //spinning for a while to write all over the track
      digitalWrite(writeEnablePin, HIGH); //stepping not working when writeEnablePin is LOW
      stepIn();
      digitalWrite(writeEnablePin, LOW);
    }
    Serial.println("");
  }
  digitalWrite(motorEnableBPin, HIGH);
  digitalWrite(writeEnablePin, HIGH);
}


The output is:
Code: [Select]

Setup done.
Writing
010101010
010101010
010101010
010101010
010101010
010101010
010101010
010101010
010101010
010101010
Reading
111001000
101010001
110111001
001000101
001011001
111111101
110101101
111110011
111111001
101111110

The output is not what should be written. (the bits are changed every time i run the code)

Any idea what am I doing wrong when writing?

Riva

First a question of why use a floppy disk to store just 16 bits of information? There are several other options to store data that is persistent across resets of the Arduino. Internal EEPROM memory (on some Arduinos), External EEPROM/Flash memory, SD Card. DS1307 RTC chip to name a few.

The code you linked to for reading a floppy disc is not actually reading data from the disk, it is just spinning the disc spindle motor up and stepping the heads back and forth and reading the state of the signal pins like track0 and index mark.
The other page you link to about writing to a disc is just outlining the control signals sent/received from the floppy connections and does not cover the writing of data to sectors on a track.
Don't PM me for help as I will ignore it.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy