updating variable
I'm trying to figure out how to update the variable for pulsewidthp. in the top half the pulsewidth is figured, in the bottom half (separate cog) i'm trying to calculate if the pulsewidth is increasing or decreasing by getting the pulsewidth as "old" wait a short time and "new" and seeing which is greater. pulsewidthp is in the var section as a long. this seems like it should work, but it doesn't. Are there any code examples in spin for ramping pwm using an r/c controller. the ones i've found are in pasm. I would like to understand how to make it work rather than borrow one that works. thanks-mike
repeat
waitpeq(%000, |< 2, 0) ' wait for Pin 2 to go low '
waitpeq(%100, |< 2, 0) 'Wait for Pin 2 to go high '
startpulsep:=cnt '
waitpeq(%000, |< 2, 0) ' wait for Pin 2 to go low '
endpulsep:=cnt ' read pulse width from receiver
waitpeq(%100, |< 2, 0) 'Wait for Pin 2 to go high
pulsewidthp:=endpulsep-startpulsep
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''below is in a separate cog
pulsewidthp:=old
waitcnt(2000+cnt)
pulsewidthp:=new
if pulsewidthp<120000 and new<old
repeat y from 0 to 1
phsb:=-x
waitcnt(20000+cnt)
x++
x<#=full 'full is equal to 8000 in the con section
