Go Down

Topic: Reading signal frequency (Read 5 times) previous topic - next topic

tuxduino


Mainly to see if the libraries were interfering with the internal setup. Didn't you notice some headers missing?


Ooops, I didn't notice the OP was mixing lcd and Serial print()s :P  Taking away every (non-strictly necessary) lib and using only Serial.print()s is a good debugging suggestion.

comsat

thank you for the reply.....i try the code suggest by bubulindo and it seems the output still the same. The weird is when i try unconnected the signal input from pin 8, there is still output and the value is 49-50

tuxduino


thank you for the reply.....i try the code suggest by bubulindo and it seems the output still the same. The weird is when i try unconnected the signal input from pin 8, there is still output and the value is 49-50


Then you should make sure pin 8 is the right one to use.

AWOL

I'd scrap the speed calculation, put an "analogWrite" into "setup" on a spare PWM pin set to a 50% duty cycle, and see if you can measure the PWM frequency of around 490Hz by connecting the PWM pin to your input pin..
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

tmd3


... the output keep going around 49-51 and it not change although i change the frequency from the signal generator.

... when i try unconnected the signal input from pin 8, there is still output and the value is 49-50.

It looks like pin 8, ICP1, the Input Capture pin for timer0/counter0, is open-circuited, and it sees only power frequency noise.  An easy way to test this is to connect a high-value resistor - like maybe 100k - between pin 8 and either ground and VCC, ort turn on the internal pullup resistor for pin 8.  If ICP1 has no signal connected, then FreqMeasure.available() should never return true.  You'll probably want to add some diagnostic code to tell you that it doesn't ever come true, rather than simply waiting to see if nothing happens.  Save millis() in setup, and after each look at  FreqMeasure.available(), check to see if a second has passed; if it has, Serial.print() something to tell you so, and save millis() again.

Check your frequency generator.  It may have a button that disconnects its output.  If it's disconnected, all you have connected to ICP1 is an antenna to pick up noise.

Go Up