Trying to measure a single pulse, which is bursted out every 50-300microseconds. The frequency of the pulse is 33kHz or period of 33 microseconds (sometimes the pulse might be 25kHz or as high as 40kHz which means the period is 25 microseconds).
We can change the pulse to a square wave and reduce it down to 4V on and zero volts off, but the measurement is still not always correct, it’s about 1 out of every 3 readings correct on the square wave and 1 out of 10 on the sin wave.
timeoutwait=100; // time to wait timeout to read a valid pulse
pauseTime=300; // time to wait until next pulse will be fired. lagtime between pulses
duration = pulseIn(pin, HIGH, timeoutwait);
I’ve played with adjusting the puseTime and timeoutwait but to no available in terms of getting the correct value every time.
I’m bench marketing vs an oscilloscope and we’ve set the signal to 25kHz and 400 microsecond pause, but I’m still getting a one out of three readings correct or even close.
Is there a better way than pulseIn?
Should I have the square wave be higher than 4 volts for the peak on the square wave?