|
The RC program must loop through the "Do ... Loop" about once every 40 ms. It may be looosing sync with the OI with the time you are wasting, because, for each packet-loop, you're counting to 150, and for each count value you're sending a debug message and re-setting p1_y to a value without leaving your "count-loop". For each packet-loop. you're also doing the processing of the "Do ... Loop".
Now, the OI sends a new buch of values to the Serin line every few ms. each with a (no pun inteded) serial number, called a packet number which the default program ignores.
If you allow the RC to read packet_num (uncomment the declaration of packet_num near the end of declarations, near the start of the program, set c_packet_num CON 1 (changed from 0), and put packet_num in the correct place in the serin line) then you can store the packet number in a variable like "start_packet_num", and set p1_y to your value until you have gone 150 loops.
if auton_mode = 0 then fugeddabahtit
if packet_num = 0 then pack_count_zero = pack_count_zero + 1
'you have to declare the variables like pack_count_zero and temp (seen below)
if packet_num < start_packet_no then it_overflowed
temp = packet_num - start_packet_num
goto to checked_p_num
it_overflowed:
temp = (((2000 + packet_num + 256) - start_packet_num) - 2000)
'if the start_packet_num is more than 105, then in 150 loops it will roll over to a numer smaller than that. this cures the problem for loop counts of less than 256
checked_p_num:
if temp < 151 then p1_y = (your value)
fugeddabahtit:
BTW, 150 counts is only a few seconds in the above. I'm sure someone will call me a doddering old fool or worse for not remembering whether you get an update 25 or 40 times per second. A quick perusal of the 2003 OI manual yields no info.
|