View Single Post
  #6   Spotlight this post!  
Unread 23-06-2002, 22:46
archiver archiver is offline
Forum Archival System
#0047 (ChiefDelphi)
 
Join Date: May 2001
Location: Pontiac, MI
Posts: 21,214
archiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond reputearchiver has a reputation beyond repute
Re: Programing help...

Posted by Nate Smith.

Other on team #66, GM Powertrain/Ypsilanti HS/Willow Run HS, from Eastern Michigan University and GM Powertrain.

Posted on 1/23/2000 11:49 AM MST


In Reply to: Programing help... posted by Adam Anderson on 1/22/2000 2:07 PM MST:



Adam,
One possibility is the packet_num variable that you can retrieve from the Master uP in the robot controller. From my work with the dashboard port spec, which also uses this packet number, I can tell you that the number changes roughly 40 times a second. So, if you wanted to, for example, have a motor run for roughly six seconds, you could use code similar to this(using sample variables of course):
--------START PBASIC CODE---------
'Start Motor
if p3_sw_trig = 1 goto startmotor
goto skipstart
startmotor:
startpacket = packet_num
endpacket = packetnum + 240 '6sec x 40cyc/sec = 240
motorrunning = 1
relay3_fwd = 1
skipstart:
if motorrunning = 1 goto checkmotor
goto skipcheck
checkmotor:
if endpacket >= packet_num goto stopmotor
goto skipstop
stopmotor:
relay3_fwd = 0
motorrunning = 0
goto skipcheck
skipstop:
motorrunning = 1
relay3_fwd = 1
skipcheck:
---------END PBASIC CODE-----------
Note that you would have to declare motorrunning, startpacket, and endpacket at the top of your program, as well as uncomment the packet_num declaration and set c_packet_num equal to 1 in the DEFINE CONSTANTS FOR INITIALIZATION section. This code also only works for times up to roughly 6 seconds, after which the endpacket calculation would roll over 255 and the program would reach the desired packet number before the desired time frame is reached. Hope this helps...

Nate Smith


__________________
This message was archived from an earlier forum system. Some information may have been left out. Start new discussion in the current forums, and refer back to these threads when necessary.