So I am building my new Mechanical TV and been working out the motor speed control.
The MTV has a Nipkow disk and instead of using an optical sensor like my last build, I am using a hall effect sensor which I hope cleans things up.
I have a GW Instek SFG-1013 Function Generator and I connected to Pin 2 of the Arduino Uno. I set the function generator to 12.5Hz and setup an interrupt on the Arduino.
The code is at the bottom of this post.
The Arduino is reporting 80,052 +/- a tiny bit. However, I expected 80,000. The reason I am doing this is to make sure I have a solid method of counting the motor speed so that if I get a lot of errors when I use my Hall Effect sensor I can most likely figure it is something on the sensor's end and not the Arduino.
I realize that 52 microseconds are nothing to be concerned about. I would probably accept 200+/- m/s. I just wonder if this is to be expected? Are Function generators that accurate? Mine was fairly cheap... think like $170 or so.
Thanks,
Peter J. Fischel
- 20200924_174243.jpg (133.9 KiB) Viewed 9164 times
- 20200924_174318.jpg (176.96 KiB) Viewed 9164 times
void setup()
{
Serial.begin(9600);
pinMode(hallPin,INPUT);
attachInterrupt(digitalPinToInterrupt(hallPin), hallInterrupt, RISING);
lastPulseTime = micros();
}
void loop()
{
Serial.println(delta);
delay(500);
}
void hallInterrupt()
{
pulseTime = micros();
delta = pulseTime - lastPulseTime;
lastPulseTime = pulseTime;
}
Peter J. Fischel
Mechanical TV Fan, Programmer and Tinkerer.