n00b
July 23, 2019, 4:35pm
1
Hi, I have really cheap Photo Tachometer that I got to measure spindle speeds for a CNC build, but interesting in checking its acracy.
As it just works on reflective light I thought I could use the Blink sketch to trigger it and have some LEDs flashing at say 4 sets "RPM" by just adjusting the delay time in the sketch.
This is what I was thinking:
void setup () {
pinMode (9,OUTPUT);
pinMode (10,OUTPUT);
pinMode (11,OUTPUT);
pinMode (12,OUTPUT);
}
//5 RPM = 60000/5 = 12000ms
//50 RPM = 60000/50 = 1200ms
//500 RPM = 60000/500 = 120ms
//5000 RPM = 60000/5000 = 12ms
//50000 RPM = 60000/50000 = 1.2ms
void loop () {
digitalWrite(9, HIGH); // 5RPM
delay (12000);
digitalWrite(9, LOW);
delay (12000);
digitalWrite(10, HIGH); //50RPM
delay (1200);
digitalWrite(10, LOW);
delay (1200);
digitalWrite(11, HIGH); //500RPM
delay (12);
digitalWrite(11, LOW);
delay (12);
digitalWrite(12, HIGH); //5000RPM
delay (1.2);
digitalWrite(12, LOW);
delay (1.2);
}
Would this approach work, is my maths sound, and can the Arduino blink at 1.2ms?
JCA34F
July 23, 2019, 5:38pm
2
Does your tach have a visible light sensor or an infra red sensor?
can the Arduino blink at 1.2ms?
Easily, but you would have to set your delays at 1/2 what you have. 500 RPM = 60ms, 50000 = 600 microSeconds.
delayMicroseconds(600);
Point your tach at a florescent or LED light fixture, if your mains frequency is 60 Hz you should see 7200, if 50 Hz, 6000.
n00b
July 23, 2019, 6:18pm
3
JCA34F:
Does your tach have a visible light sensor or an infra red sensor?
Visible light
JCA34F:
Easily, but you would have to set your delays at 1/2 what you have. 500 RPM = 60ms, 50000 = 600 microSeconds.
delayMicroseconds(600);
Point your tach at a florescent or LED light fixture, if your mains frequency is 60 Hz you should see 7200, if 50, 6000.
So.....like this?
void setup () {
pinMode (9,OUTPUT);
pinMode (10,OUTPUT);
pinMode (11,OUTPUT);
pinMode (12,OUTPUT);
}
void loop () {
digitalWrite(9, HIGH); // 5RPM
delayMicroseconds (6000);
digitalWrite(9, LOW);
delayMicroseconds (6000);
digitalWrite(10, HIGH); //50RPM
delayMicroseconds (600);
digitalWrite(10, LOW);
delayMicroseconds (600);
digitalWrite(11, HIGH); //500RPM
delayMicroseconds (6);
digitalWrite(11, LOW);
delayMicroseconds (6);
digitalWrite(12, HIGH); //5000RPM
delayMicroseconds (0.6);
digitalWrite(12, LOW);
delayMicroseconds (0.6);
}
JCA34F
July 23, 2019, 10:47pm
4
void setup () {
pinMode (9,OUTPUT);
pinMode (10,OUTPUT);
pinMode (11,OUTPUT);
pinMode (12,OUTPUT);
}
void loop () {
digitalWrite(9, HIGH); // 5RPM
delay (6000);
digitalWrite(9, LOW);
delay(6000);
digitalWrite(10, HIGH); //50RPM
delay (600);
digitalWrite(10, LOW);
delay (600);
digitalWrite(11, HIGH); //500RPM
delay (60);
digitalWrite(11, LOW);
delay (60);
digitalWrite(12, HIGH); //5000RPM
delay (6);
digitalWrite(12, LOW);
delay (6);
}
If you want an LED for 50 thousand RPM, the blink rate would be:
1 / (50000 / 60 * 2) = 0.6 ms, but you can't get fractions of a milli, so use micros (millis / 1000).
digitalWrite(pin, HIGH); //50000RPM
delayMicroseconds (600);
digitalWrite(pin, LOW);
delayMicroseconds (600);