09-27-2016 12:02 PM - edited 09-27-2016 12:06 PM
I need to generate a sine wave based on the output of a shaft encoder. The encoder is rotated at a constant angular velocity, so the encoder's output is a sawtooth signal from 0-5V (0-360 degrees).
When I take the sine of this signal, I get a "spasm" that corresponds to every falling edge of the sawtooth, though the sine slightly lags the encoder:
I understand how the spasm occurs: sin() sees an angle drop back (CW around the unit circle) from 360 deg down to 0 deg so for a second sin() outputs the same or preceding value. However, I don't know why the spasm occurs.
I didn't have this issue a couple of months ago when I ran this exact same code. The encoder would still output a sawtooth signal, but the proceeding sin() would behave as if the value of the encoder transitioned smoothly from 360 to 0 degrees. That is, sin(shaft encoder output) = perfect sinusoid.
Could a sampling rate or timing issue cause the spasms?
If not, is there a way to force LabVIEW to ignore the falling edge other than a filter? That is, does LabVIEW/DAQmx have a setting to change the signal reconstruction of the ADC so it doesn't confuse the sine() function? (I know I'm getting hand-wavy here)
I know this issue could fall under signal conditioning, but I posted it here because I think I'm not sampling correctly.
09-27-2016 12:32 PM
Not likely to be primarily a sampling rate or timing issue. Looks more like a non-ideal sensor. The original signal isn't a very clean looking sawtooth. There's a small flattish spot at the top of the ramp and there are transient spikes during the transition back to 0.
Is this a continuous rotation potentiometer?
-Kevin P
09-27-2016 02:00 PM
Hi Kevin,
I'm using one of these magnetic rotary encoders.
http://www.usdigital.com/products/encoders/absolute/rotary/kit/MAE3
They are pretty robust sensors; however, the encoder is in a setup with a lot of noise (1 electric motor, 1 RC-servo, and a 6-axis load cell).
To that end, I simulated a sawtooth + sin() in LabVIEW, and I didn't get the same errant response as my physical setup.
This is leading me to think that the spikes are causing the sinusoid spasms.