
Originally Posted by
HenrikOlsson
Basically, the Position and the Setpoint variables are the only longs and the reason for PBPL.
The setpoint is calculated by adding or subtracting the number of steps that has arrived since the last servoloop. For the position I get the lower 16bits from the hardware QEI counter and the upper 16bits by keeping track of the number of over/underflows with the RollOver ISR.
If that's all there is ... it's a piece of cake for PBPW.
Man, I'm painting myself into a corner here....
I think not.
BTW, how come these two...
Code:
ByteVar1 = ByteVar1 + (ByteVar2 >> 2) ; <-- Long
ByteVar1 = ByteVar1 + (ByteVar2 >> 1) ; <-- Byte
...are treated different?
A single shift right compiles to a
Code:
BCF STATUS,C
RRF _ByteVar2,F
or, RRNCF for an 18F.
But for 2 or more shifts, it puts the value in a system reg, saves the number of bits to shift, then calls a library routine to actually do the shift. Therefore ... LONG.
Let me try to figure out the PBPW way. (should be easy)
I think all the info is already in this thread.
Anything missing that might help?
<br>
Bookmarks