Assembly help needed to modify Rotary Encoder
I'm trying to figure out how to set this object (using only one encoder) to a position after the program is already running. Some time back someone gave me a method to make the encoder count backwards by going backwards from AMask [ - 8] and modifying the opcode that was set to add to become sub.
I was wondering if such a method could be done to send in a position and overwrite the position value of the single encoder already running.
If you look at SetDir you can see the method that works to make the encoder count backwards. I tried to use the same idea in SetEncoder to do Amask := 5000 as a test set the value to a value first just to see if it can be modified. This just makes it go crazy. 12, 13 etc no luck. Can anyone think of a way to modify the position remotely by the main program? Thanks for any ideas.
:IPos add 0, Diff 'AMask[-8] ****Add/Sub to encoder position value wrlong 0, MPosAddr 'Write new position to main memory add IPosAddr, #1 'Increment encoder position addresses movd :IPos+0, IPosAddr movd :IPos+1, IPosAddr add MPosAddr, #4
:Next djnz Idx, #:UpdatePos 'Loop for each encoder
jmp #:Sample 'Loop forever
'Define Encoder Reading Cog's constants/variables
AMask long $55555555 'A bit mask
BMask long $AAAAAAAA 'B bit mask
MSB long $80000000 'MSB mask for current bit pair
Pin long 0 'First pin connected to first encoder
TotEnc long 0 'Total number of encoders
'IPosAddr long 16
Idx res 1 'Encoder index
St1 res 1 'Previous state
St2 res 1 'Current state
T1 res 1 'Temp 1
T2 res 1 'Temp 2
Diff res 1 'Difference, ie: -1, 0 or +1
IPosAddr res 1 'Address of current encoder position counter (Internal Memory)
MPosAddr res 1 'Address of current encoder position counter (Main Memory)
IntPos res 16
** sorry I can't figure out how to format this code to look right