View Single Post
  #20   Spotlight this post!  
Unread 01-02-2003, 15:29
Mike537Strategy Mike537Strategy is offline
Registered User
#0537 (Charger Robotics)
 
Join Date: Jan 2003
Location: Sussex Wisconsin
Posts: 25
Mike537Strategy is an unknown quantity at this point
I'm trying to use the original timer code from the first thread in a simple dead reckoning pattern. My code has the time calculator directly after the SERIN, has 2 lines of code changing the wheel numbers for the SEROUT, then the SEROUT. It loops this until realtime = whatever time I want. It goes forward, turns right, forward, right, forward, right, then forward. The problem is that after the first forward (Which works perfectly), it just turns right until I turn off the robot. Any ideas why? The variables are the same as the default, delta_t is declared and set to 1 in intilization. The forums aren't being nice and the SERINs are all on one line in the actual code.

Code:
do
   Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
   time = time + delta_t + 1
   if time > 38 then
      time = time - 38
      realtime = realtime + 1
   endif
   p1_y = 254
   p2_y = 254
   Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
			     127,127,127,127]
loop until realtime = 2
do
   Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
   p1_y = 254
   p2_y = 0
   time = time + delta_t + 1
   if time > 38 then
      time = time - 38
      realtime = realtime + 1
   endif
   Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
			     127,127,127,127]
loop until realtime = 1
do
   Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
   time = time + delta_t + 1
   if time > 38 then
      time = time - 38
      realtime = realtime + 1
   endif
   p1_y = 254
   p2_y = 254
   Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
			     127,127,127,127]
loop until realtime = 2
do
   Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
   p1_y = 254
   p2_y = 0
   time = time + delta_t + 1
   if time > 38 then
      time = time - 38
      realtime = realtime + 1
   endif
   Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
			     127,127,127,127]
loop until realtime = 1
do
   Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
   time = time + delta_t + 1
   if time > 38 then
      time = time - 38
      realtime = realtime + 1
   endif
   p1_y = 254
   p2_y = 254
   Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
			     127,127,127,127]
loop until realtime = 2
do
   Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
   p1_y = 254
   p2_y = 0
   time = time + delta_t + 1
   if time > 38 then
      time = time - 38
      realtime = realtime + 1
   endif
   Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
			     127,127,127,127]
loop until realtime = 1
do
   Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
   time = time + delta_t + 1
   if time > 38 then
      time = time - 38
      realtime = realtime + 1
   endif
   p1_y = 254
   p2_y = 254
   Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
			     127,127,127,127]
loop until realtime = 2
__________________
"Charging into the future, one game at a time." - Team 537 motto