I am trying to obtain a linear sinusoidal motion with a very precise frequency (error max of 2%) by using a captive linear stepper motor (NEMA 14).
I made up a device able to provide a linear motion up to 3mm. It is possible to select the amplitude of the motion (amplitude of the sine) with a resolution of 0,1mm. Moreover, it is possible to select three different values of motion frequency: 1, 2 and 3Hz.
My hardware consists essentially of: Aurduino DUE (with a TFT display) + Driver A4988 + stepper motor
To obtain the sinusoidal motion, I change the delay time after each step of the motor by using the function dalayMicroseconds(). The delay values are computed by following a sinusoidal law.
There are no problems about the amplitude of the motion.
The probleme is that I always obtain a motion that is slower than the imposed one. The error seems to be random and too much high although I take into account the delay due to the program execution. For istance, instead of 2 Hz I obtain 1,7 Hz (measured by a LVDT sensor).
What could be the problem??