Hello.
I've been working on an encoder [1] simulation using PIO and right now in order to move e.g. 100000 steps, I'm doing the following:
1. Based on my required frequency I calculate the time it will take to run the number of steps
2. Start the SM (which generates the A,B signals)
3. Sleep until time is up
4. Stop the SM
However this is not very accurate, and the resulting step is only approximately my required number of steps.
I'm looking for a suggestion of how to get exactly the number of steps required. Is it somehow possible to launch the SM for a fixed number of cycles?
Another related question I thought about is how to simulate acceleration and decelaration, which means continuously increasing the frequency of the SM. But if I really need this it is probably enough to loop over a number of time points, stand and stop the SM, and increase the frequency each time.
[1] https://en.wikipedia.org/wiki/Incremental_encoder,
I've been working on an encoder [1] simulation using PIO and right now in order to move e.g. 100000 steps, I'm doing the following:
1. Based on my required frequency I calculate the time it will take to run the number of steps
2. Start the SM (which generates the A,B signals)
3. Sleep until time is up
4. Stop the SM
However this is not very accurate, and the resulting step is only approximately my required number of steps.
I'm looking for a suggestion of how to get exactly the number of steps required. Is it somehow possible to launch the SM for a fixed number of cycles?
Another related question I thought about is how to simulate acceleration and decelaration, which means continuously increasing the frequency of the SM. But if I really need this it is probably enough to loop over a number of time points, stand and stop the SM, and increase the frequency each time.
[1] https://en.wikipedia.org/wiki/Incremental_encoder,
Statistics: Posted by dov — Sat May 04, 2024 3:14 am