SHENZHEN I/O

SHENZHEN I/O

Otillräckligt med betyg
4 PHASE ROTARY ENCODER POSTION TRACKER
   
Utmärkelse
Favorit
Favoritmarkerad
Avfavoritmarkerad
Filstorlek
Lades upp
Uppdaterades
8.704 KB
12 apr, 2017 @ 16:08
14 apr, 2017 @ 7:05
2 ändringsnotiser ( visa )

Abonnera för att ladda ner
4 PHASE ROTARY ENCODER POSTION TRACKER

Beskrivning
Nice little real-world problem to solve. Can you successfully track position from a couple of square waves?
6 kommentarer
Xenofix 15 jul, 2020 @ 9:34 
cirdec 15 jul, 2020 @ 2:37 
No, it's just gen p0 0 1 to get the edges correct to do it in 5 lines of code/
cirdec 15 jul, 2020 @ 2:26 
I did it in 6 lines of code. It could be reduced to 5 by PGA edge detecting the set/reset signal from a gen p0 1 0 instead of gen p0 0 0; slp 1 https://gtm.steamproxy.vip/sharedfiles/filedetails/?id=2166755298
Skyfather  [skapare] 26 nov, 2019 @ 2:54 
Really?!?! Can we have a screenshot?
Xenofix 25 nov, 2019 @ 13:49 
Really nice puzzle. I've found a solution with only 5 lines of code!
Skyfather  [skapare] 13 apr, 2017 @ 19:35 
Proposed update for the explanatory text in-game. Comments welcome.

* A and B are Simple inputs connected to an incremental rotary encoder attached to a rotating shaft.
* Position is an XBus output used to transmit position, which has a valid range of -999 to +999.
* The rotary encoder produces square-waves, were 1 complete wave (peak-to-peak) equates to one shaft revolution.
* The A and B signals are 1/4 out-of-phase, i.e. if the shaft rotates clockwise, the A wave will proceed the B wave. For anti-clockwise rotation, the B wave will proceed the A wave. If the shaft is stationary, the states of A and B will remain constant with time.
* One quarter-turn of the shaft equates to a change in position of 1.
* The verification tab may help to visualise the problem. For this test case, the shaft is first rotated clockwise for 5 turns, and then anti-clockwise for 5 turns.