I have a mechatronic device which has a couple of 'jog' buttons, these are working nicely on a interrupt. The interrupt code fires on level change then checks the value - corresponding code sections send a command to the PRU via /dev/rpmsg_pru31.
Part of the command sent is a numeric value representing the frequency of the pru_ecap PWM generation (this connects to an AC servo motor 'step' input)...
As you can now see, press the button, the motor moves, release the button & the frequency command sent is reduced to '0' and the PRU code stops the pwm generation.
What I've been playing around with today is making this a ramped (accelerated) jog. I can put a loop inside the interrupt code that increases the value of the numeric value, works fine, but I would like to delay the loop so the acceleration is more gradual. I've played around with a setTimeout function inside the loop, doesn't work.
I've moved this delayed loop to a separate function outside of the ISR. Inside the ISR I just loop in a do->while until the ramp generation code has incremented the value to a maximum, I then cancel the interval timer - this doesn't work either.
Is there a better way to do this that I've overlooked?