11-17-2017 05:30 AM
Hi,
As said in the title, I'm trying to generate a sine signal to drive a servomotor ( to represent the behavior of a cyclist). My idea is to sample the low frequency sine (+-2Hz) to get a sinusoidal torque command for the servomotor. The problem is that I ‘can’t generate a real-time sine wave.
As you can see on the video, when I change the frequency (F=vitesse de rotation manivelle/60), the reference signal goes crazy, as if the frequency increase way more than what I ask. I think this has something to do with “sampling info” which should change with the frequency but how? When I increase the “vitesse de rotation manivelle” of 1RPM this should increase the sine frequency of 1/60 Hz, we should barely see the difference.
Have someone any idea how to properly generate a real-time sinewave?
Here is the link of the video for a better quality: https://youtu.be/_rTSBj82Y7w
11-20-2017 09:36 AM
Hi Robin,
I think the sine wave you generate is completely fine, but you have got a little issue with the plotting.
The function keeps the phase of the generated sine wave. When you set the frequency to multiples of 1 (vitesse de rotation manivelle to multiples of 60), the waveform graph will exactly fit N oscillations. If you increase the frequency, it will fit just a bit more than N sinewaves and the plot starts to move (imagine an oscilloscope which is not exactly triggered to the oscillation).
I have attached some example how I would do it.