📜 ⬆️ ⬇️

MIDI player on eight floppy. Or how the electronics engineer went crazy

Once I watched a video about singing flops and a mountain of written-off computers. I decided to do something like that.

ready device

Do on Arduino like the rest? Are you serious? F * ck the system, as they say! It was decided to do at Atmega8A , because only she was at hand. Wires are also for wimps, so I found HC-05 (why unnecessary snot?).
')
Go!

Scheme


The first stage, as usual, the scheme. There are no problems with it.

scheme

It is simple and without unnecessary frills.

Pay


The board is also done without much stress using photoresist. Scattered in 10 minutes and manufactured in an hour.

PCB layout



Write the code


Now the most interesting thing is programming. I decided to write in C in order to save time. But did not have time to start, as already rake.

Rakes are to manage flops. As you know, if Direct pin = 0, and to give impulses to Step, then the flop steps forward, and if Direct pin = 1, then back, but the flop has only 80 steps. Little what to do? The solution is simple. The flop can do half a step, if you just change the state of Step, rather than pulsing it. Do it better this way:

Step ^= (1<<pin); 

The first problem is solved! Further implementation of the entire control function.

 void output(int drive){ // drive -   1 - 8 int position = drive - 1; //       0-7 if(currentPosition[position] >= max)direct |= 1 << position; // direct -  char (8 ).   ,    if(currentPosition[position] <= 0)direct &= ~(1<<position); // ,     if(direct & (1<<position)){ //  back(drive); //  currentPosition[position]--; //    }else{ forward(drive); //  currentPosition[position]++; //  } } 

Made! Now the timers. We set the timer in CTC mode with division by 8 and enable interrupt by Output Compare (hereinafter OC). In OCR we put 40. About once in 40 microsec an OC event occurs. The interrupt handler is quite capacious.

For the curious
 void Action(){ if(fr1 != 0){ currentTick[0]++; //   if(currentTick[0] >= fr1){ //fr* -     output(1); currentTick[0]=0; // -  } }; if(fr2 != 0){ currentTick[1]++; if(currentTick[1] >= fr2){ currentTick[1]=0; output(2); } }; if(fr3 != 0){ currentTick[2]++; if(currentTick[2] >= fr3){ output(3); currentTick[2]=0; } }; if(fr4 != 0){ currentTick[3]++; if(currentTick[3] >= fr4){ currentTick[3]=0; output(4); } }; if(fr5 != 0){ currentTick[4]++; if(currentTick[4] >= fr5){ currentTick[4]=0; output(5); } }; if(fr6 != 0){ currentTick[5]++; if(currentTick[5] >= fr6){ currentTick[5]=0; output(6); } }; if(fr7 != 0){ currentTick[6]++; if(currentTick[6] >= fr7){ currentTick[6]=0; output(7); } }; if(fr8 != 0){ currentTick[7]++; if(currentTick[7] >= fr8){ currentTick[7]=0; output(8); } }; } ISR(TIMER2_COMP_vect){ Action(); } 


Now the connection with the computer. Here we do. A string is transmitted with a macro in the header (C / F) -> body (number) -> end of the packet (';'). First, processing through the state machine:

 void parse(){ char data = UDR; switch(data){ case 'C': tmp_int = 0; SM= data; break; //  -    case 'F': tmp_int = 0; SM= data; break; // F -  case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': tmp_int = tmp_int * 10 + (data -'0'); break; case ';': switch(SM){ case 'C': channel=tmp_int; break; case 'F': freq = tmp_int; break; }; play(freq, channel); break; // play          fr* case 'R' : resetAll(); break; default: break; } } 

Secondly, reception only in the Idle state:

 while ( UCSRA & (1<<RXC))parse(); 

- Well, everything already?
- Not! And how to manage?

The control program was broken from scratch, so I added functionality to my Tesla coil control program ( HETC control terminal ). Addiction? Of course. With its interface, you can figure it out yourself, I will not write much. The only thing that you need to select in the beginning is Floppy and the COM port of the device, then Connect.

Yes, it is possible without a biloba, it's just my problem.

Selecting MIDI file ...



Sources


Sources + firmware .

Source: https://habr.com/ru/post/253189/


All Articles