Difference between revisions of "Split-flap display"
From Fixme.ch
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
Someone donated three flip flop to fixme, it would be good to make them work and display whatever we would like to. | Someone donated three flip flop to fixme, it would be good to make them work and display whatever we would like to. | ||
− | + | ||
+ | == Circuit board == | ||
+ | |||
+ | === Controller === | ||
+ | 8 bit micro | ||
Full datasheet : [[File:MC68HC705P6A-7151.pdf]] | Full datasheet : [[File:MC68HC705P6A-7151.pdf]] | ||
+ | |||
+ | === T bridge === | ||
+ | basically switch the power | ||
+ | Full datasheet : [[File:DSA-60676.pdf]] | ||
+ | |||
+ | == Manual driving == | ||
+ | |||
+ | === Principle === | ||
+ | |||
+ | The stepper-motors can be driven directly by an Arduino powering the coils properly. The Arduino output is low-power so the motor needs to be driven in "high-torque" mode, ie. 2 coils at a time. That is to say, instead of having the magnetic field going N > E > S > W, it goes NE > SE > SW > NW. | ||
+ | |||
+ | To lower the electrical stress on the Arduino, it would be '''great''' to drive the motors with H-Bridges (or maybe T-bridge like in the original design). | ||
+ | |||
+ | === Show me the code === | ||
+ | |||
+ | The code is there (not pushed to any GIT): | ||
+ | |||
+ | <code> // Roue des minutes : | ||
+ | // Engrenage moteur avec 4 aimants, capteur à effet Hall sur la PCB a la verticale | ||
+ | // Il faut compter 79 passages pour faire un tour de flaps. Vérifier s'il y a une dérive. | ||
+ | // Conclusion pour afficher le bon nombre : mapper 79*4 pas sur 62 positions (00->60 + blancs) | ||
+ | |||
+ | // Tempo du moteur pas à pas | ||
+ | #define tempo 14 | ||
+ | |||
+ | #define SEC 10 | ||
+ | #define MIN 6 | ||
+ | #define HOR 2 | ||
+ | |||
+ | unsigned int h = 0, m = 0, s = 0; | ||
+ | unsigned int hM = 0, mM = 0, sM = 0; | ||
+ | |||
+ | void setup() { | ||
+ | // Define outputs | ||
+ | for(int i=0; i<12; i++) | ||
+ | pinMode(i+1, OUTPUT); | ||
+ | Serial.begin(9600); | ||
+ | Serial.setTimeout(30*1000); | ||
+ | } | ||
+ | |||
+ | void rot(unsigned char hms, unsigned int target) | ||
+ | { | ||
+ | // Demande invalide | ||
+ | if((hms != SEC && hms != MIN && hms != HOR) || target > 60) | ||
+ | { | ||
+ | Serial.println("Incorrect !"); | ||
+ | return; | ||
+ | } | ||
+ | |||
+ | // Flap 00 > 29 : numéros | ||
+ | // Flap 30 : blanc | ||
+ | // Flap 31 > 60 : numéros-1 | ||
+ | // Flap 61 : blanc | ||
+ | |||
+ | // Position actuelle | ||
+ | unsigned int* current; | ||
+ | if(hms == SEC) current = &s; | ||
+ | else if(hms == MIN) current = &m; | ||
+ | else current = &h; | ||
+ | |||
+ | Serial.print("Position actuelle : "); | ||
+ | Serial.println(*current); | ||
+ | Serial.print("Target : "); | ||
+ | Serial.println(target); | ||
+ | |||
+ | // Action ! | ||
+ | // On flip les flaps tant qu'on est pas arrivé à destination | ||
+ | Serial.print("Action sur les pins "); | ||
+ | Serial.print(hms+3); | ||
+ | Serial.print(", "); | ||
+ | Serial.print(hms+2); | ||
+ | Serial.print(", "); | ||
+ | Serial.print(hms+1); | ||
+ | Serial.print(", "); | ||
+ | Serial.println(hms); | ||
+ | |||
+ | while(*current != target) | ||
+ | { | ||
+ | Serial.print("Position actuelle : "); | ||
+ | int lol = *current; | ||
+ | Serial.println(lol); | ||
+ | |||
+ | for(int i = 0; i<4; i++) | ||
+ | { | ||
+ | // Step 5 | ||
+ | digitalWrite(hms+3, LOW); | ||
+ | digitalWrite(hms+2, HIGH); | ||
+ | digitalWrite(hms+1, LOW); | ||
+ | digitalWrite(hms, HIGH); | ||
+ | delay(tempo); | ||
+ | |||
+ | // Step 7 | ||
+ | digitalWrite(hms+3, HIGH); | ||
+ | digitalWrite(hms+2, LOW); | ||
+ | digitalWrite(hms+1, LOW); | ||
+ | digitalWrite(hms, HIGH); | ||
+ | delay(tempo); | ||
+ | |||
+ | // Step 1 | ||
+ | digitalWrite(hms+3, HIGH); | ||
+ | digitalWrite(hms+2, LOW); | ||
+ | digitalWrite(hms+1, HIGH); | ||
+ | digitalWrite(hms, LOW); | ||
+ | delay(tempo); | ||
+ | |||
+ | // Step 3 | ||
+ | digitalWrite(hms+3, LOW); | ||
+ | digitalWrite(hms+2, HIGH); | ||
+ | digitalWrite(hms+1, HIGH); | ||
+ | digitalWrite(hms, LOW); | ||
+ | delay(tempo); | ||
+ | } | ||
+ | |||
+ | // Demi-step pour faire tomber le flap, mais pas 2 | ||
+ | digitalWrite(hms+3, LOW); | ||
+ | digitalWrite(hms+2, HIGH); | ||
+ | digitalWrite(hms+1, LOW); | ||
+ | digitalWrite(hms, LOW); | ||
+ | delay(tempo*2); | ||
+ | |||
+ | (*current)++; | ||
+ | if(*current >= 61) | ||
+ | *current = 0; | ||
+ | } | ||
+ | |||
+ | // Stop motor | ||
+ | digitalWrite(hms+3, LOW); | ||
+ | digitalWrite(hms+2, LOW); | ||
+ | digitalWrite(hms+1, LOW); | ||
+ | digitalWrite(hms, LOW); | ||
+ | |||
+ | Serial.println("Done"); | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | if (Serial.available() > 0) { | ||
+ | unsigned char b = Serial.read(); | ||
+ | if(b == 'h' || b == 'm' || b == 's') | ||
+ | { | ||
+ | int roue; | ||
+ | if(b == 'h') roue = HOR; | ||
+ | else if(b = 'm') roue = MIN; | ||
+ | else roue = SEC; | ||
+ | Serial.print("Roue selectionnee : "); | ||
+ | Serial.println(roue); | ||
+ | int nb = Serial.parseInt(); | ||
+ | Serial.println(nb); | ||
+ | rot(roue,nb); | ||
+ | } | ||
+ | else if(b == 'w') | ||
+ | { | ||
+ | Serial.println("Give me 3 values !"); | ||
+ | h = Serial.parseInt(); | ||
+ | m = Serial.parseInt(); | ||
+ | s = Serial.parseInt(); | ||
+ | } | ||
+ | else if(b == '+') | ||
+ | { | ||
+ | rot(MIN,m+1); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </code> |
Latest revision as of 01:37, 23 November 2013
Someone donated three flip flop to fixme, it would be good to make them work and display whatever we would like to.
Contents
[hide]Circuit board
Controller
8 bit micro Full datasheet : File:MC68HC705P6A-7151.pdf
T bridge
basically switch the power Full datasheet : File:DSA-60676.pdf
Manual driving
Principle
The stepper-motors can be driven directly by an Arduino powering the coils properly. The Arduino output is low-power so the motor needs to be driven in "high-torque" mode, ie. 2 coils at a time. That is to say, instead of having the magnetic field going N > E > S > W, it goes NE > SE > SW > NW.
To lower the electrical stress on the Arduino, it would be great to drive the motors with H-Bridges (or maybe T-bridge like in the original design).
Show me the code
The code is there (not pushed to any GIT):
// Roue des minutes :
// Engrenage moteur avec 4 aimants, capteur à effet Hall sur la PCB a la verticale
// Il faut compter 79 passages pour faire un tour de flaps. Vérifier s'il y a une dérive.
// Conclusion pour afficher le bon nombre : mapper 79*4 pas sur 62 positions (00->60 + blancs)
// Tempo du moteur pas à pas
#define tempo 14
#define SEC 10
#define MIN 6
#define HOR 2
unsigned int h = 0, m = 0, s = 0;
unsigned int hM = 0, mM = 0, sM = 0;
void setup() {
// Define outputs
for(int i=0; i<12; i++)
pinMode(i+1, OUTPUT);
Serial.begin(9600);
Serial.setTimeout(30*1000);
}
void rot(unsigned char hms, unsigned int target)
{
// Demande invalide
if((hms != SEC && hms != MIN && hms != HOR) || target > 60)
{
Serial.println("Incorrect !");
return;
}
// Flap 00 > 29 : numéros
// Flap 30 : blanc
// Flap 31 > 60 : numéros-1
// Flap 61 : blanc
// Position actuelle
unsigned int* current;
if(hms == SEC) current = &s;
else if(hms == MIN) current = &m;
else current = &h;
Serial.print("Position actuelle : ");
Serial.println(*current);
Serial.print("Target : ");
Serial.println(target);
// Action !
// On flip les flaps tant qu'on est pas arrivé à destination
Serial.print("Action sur les pins ");
Serial.print(hms+3);
Serial.print(", ");
Serial.print(hms+2);
Serial.print(", ");
Serial.print(hms+1);
Serial.print(", ");
Serial.println(hms);
while(*current != target)
{
Serial.print("Position actuelle : ");
int lol = *current;
Serial.println(lol);
for(int i = 0; i<4; i++)
{
// Step 5
digitalWrite(hms+3, LOW);
digitalWrite(hms+2, HIGH);
digitalWrite(hms+1, LOW);
digitalWrite(hms, HIGH);
delay(tempo);
// Step 7
digitalWrite(hms+3, HIGH);
digitalWrite(hms+2, LOW);
digitalWrite(hms+1, LOW);
digitalWrite(hms, HIGH);
delay(tempo);
// Step 1
digitalWrite(hms+3, HIGH);
digitalWrite(hms+2, LOW);
digitalWrite(hms+1, HIGH);
digitalWrite(hms, LOW);
delay(tempo);
// Step 3
digitalWrite(hms+3, LOW);
digitalWrite(hms+2, HIGH);
digitalWrite(hms+1, HIGH);
digitalWrite(hms, LOW);
delay(tempo);
}
// Demi-step pour faire tomber le flap, mais pas 2
digitalWrite(hms+3, LOW);
digitalWrite(hms+2, HIGH);
digitalWrite(hms+1, LOW);
digitalWrite(hms, LOW);
delay(tempo*2);
(*current)++;
if(*current >= 61)
*current = 0;
}
// Stop motor
digitalWrite(hms+3, LOW);
digitalWrite(hms+2, LOW);
digitalWrite(hms+1, LOW);
digitalWrite(hms, LOW);
Serial.println("Done");
}
void loop() {
if (Serial.available() > 0) {
unsigned char b = Serial.read();
if(b == 'h' || b == 'm' || b == 's')
{
int roue;
if(b == 'h') roue = HOR;
else if(b = 'm') roue = MIN;
else roue = SEC;
Serial.print("Roue selectionnee : ");
Serial.println(roue);
int nb = Serial.parseInt();
Serial.println(nb);
rot(roue,nb);
}
else if(b == 'w')
{
Serial.println("Give me 3 values !");
h = Serial.parseInt();
m = Serial.parseInt();
s = Serial.parseInt();
}
else if(b == '+')
{
rot(MIN,m+1);
}
}
}