[resolved] Servo32v7 issue
kuroneko
Posts: 3,623
ATM I can't reach Parallax's support site so I dump this here. While I had a look at [thread=147151]this issue[/thread] it occurred to me to check the Servo32v7 object as well, just in case. Same problem.
What it boils down to is that an unsigned value is compared against another one with carry set being the exit condition (e.g. ZoneLoop in the servo object). It's fine as long as the first value is not the biggest one possible ($FFFFFFFF). This however can happen when the IOupdate loop is entered at a specific time and the hub window is aligned accordingly. In this case the object locks up (verified). I also have a feeling that the ZoneLoop may suffer from an overflow issue, e.g. temp = -30, tempcntn = -40 (no carry), tempcntn+1 = +40 (no carry). That needs to be verified.
What it boils down to is that an unsigned value is compared against another one with carry set being the exit condition (e.g. ZoneLoop in the servo object). It's fine as long as the first value is not the biggest one possible ($FFFFFFFF). This however can happen when the IOupdate loop is entered at a specific time and the hub window is aligned accordingly. In this case the object locks up (verified). I also have a feeling that the ZoneLoop may suffer from an overflow issue, e.g. temp = -30, tempcntn = -40 (no carry), tempcntn+1 = +40 (no carry). That needs to be verified.
Comments
Thank you
-Beau Schwabe
Note that I picked this error case because it was the easiest one to generate. There are 3 more zones to deal with which have their own reference points.
There is already provision in the code to account for this cnt rollover "glitch"... Is the NoGlitch value being set correctly in your code?
Wouldn't it be easier to apply some limits in code instead of picking odd looking values in the constant section?
https://drive.google.com/folderview?id=0B0DJmXrvrE-IemxSdktUTmZHd2s&usp=sharing
History:
Version 1 - initial concept
Version 2 - (03-08-2006) Beta release
Version 3 - (11-04-2007) Improved servo resolution to 1uS
Version 4 - (05-03-2009) Ability to disable a servo channel
and remove channel preset requirement
Version 5 - (05-08-2009) Added ramping ability
Version 6 - (07-18-2009) Fixed slight timing skew in ZoneLoop and
fixed overhead timing latency in ZoneCore
Version 7 - (08-18-2009) Fixed servo jitter in ramping function when
servo reached it's target position
Version 8 - (12-20-2010) Added PUB method to retrieve servo position
Version 9 - (04-05-2013) cnt rollover issue corrected with ZonePeriod
by setting up Counter A and using the Phase
accumulator instead of the cnt
Note: This also eliminates the need to setup
a 'NoGlitch' variable
I'm getting an error message from the Google link.
Thanks for fixing this. I use Servo32 in a lot of my projects.
@kuroneko, Thanks for catching this error.
http://forums.parallax.com/showthread.php/147219-CODE-UPDATE-Servo32v9?p=1175076#post1175076
BTW) Google link in post #9 above fixed
Thank you.