3 ms·
If you want to do it in pio, one of solutions would be some elaborate series of jump instructions to detect what changed and then in which direction. Every jump
by yetihehe 6y ago
If you want to do it in pio, one of solutions would be some elaborate series of jump instructions to detect what changed and then in which direction. Every jump string would terminate with instruction sending direction to queue. Otherwise you could just output pins on every change into some array through dma and read that array on main processor and calculate current position in batched mode.
- MatthiasWandel 6y agoI guess the ting to do would be to somehow wait on a change on either line. Could be done with a wait on just one line if I only want half counts instead of quarter counts
- yetihehe 6y agoOr just continuously poll input pins and compare with scratch register. When anything changes, execute check logic. Probably best one is just waiting on pin changes and sending them to main processor for handling. I have multiple quadrature decoder in plans, but nothing started yet and this is approach I will be taking if no one makes anything better until then. When you check 16 pins for changes, you can easily handle 8 decoders with just one PIO state machine and some cunning decoding logic. I wouldn't be surprised, if someone implements quadrature decoding with hardware interpolator. It's one nice piece of hardware. You can do single cycle 2d texture mapping or rotozooming with that thing.