Hello,
For my current set up - I am using a qaudrature encoder and using an ISR (interrupt service routine) to check direction and set encoder counts on rising edges of one of the channels (master). I am developing a PID controller to move a DC motor (w/ gear box) (slave) also using a quadrature encoder to determine the encoder count using ISR at each rising edge of the one channels.
Slow motions work perfectly and the controller works well (both using a P controller and PID controller).
But I see two issues:
a) When I move the master quickly, the system becomes unstable and the error (between the 2 encoders, master and slave) permentantly increases, which in turns increases my signal indefintely.
which causes,
b) the main loop doesn't response accordingly, the Serial.print i get back every so often becomes lagged.
I have thought of some possibilities that is causing this and would like people opinions and suggestions:
- Data Types -
When the master side moves quickly the error increases quickly which in turns causes my unstability. Perhaps the error value overflows and screws up my controller. My current setting is keeping "float".
-ISR-
This lagging I am getting is interesting. I get a serial print every 800 iterations of the loop which is sufficient enough. During slow motions it works wonderfully but when I make a quick and fast motion the system becomes unstable and the motor runs forever. During this time the serial.print lags and I get readings at a slower rate. I feel like the instability causes a "fight" between the ISR of both encoders.
I am very stuck on this and would appreciate any advice.
Thanks community,
Danny
EDIT: Perhaps it is not -ISR-, since that is only used during master movment and the lagging is during a constant signal.