home *** CD-ROM | disk | FTP | other *** search
/ ifirobotics.com / www.ifirobotics.com.tar / www.ifirobotics.com / docs / isacc32-default-program+1stick.bsx < prev    next >
Text File  |  2007-12-18  |  18KB  |  515 lines

  1. ' PROGRAM:    2000 Default Code with One Joystick Control RevNC
  2. ' Written by: Innovation First, Inc.
  3. ' Date:       03 Feb 00
  4. '
  5. ' Define BS2-SX Project Files
  6. '
  7. ' {$STAMP BS2SX}
  8.  
  9.  
  10.  
  11.  
  12. '========== DECLARE VARIABLES ================================================
  13. '=============================================================================
  14. '  Below is a list of declared input and output variables.  Comment or un-comment
  15. '  the variables as needed.  Declare any additional variables required in
  16. '  your main program loop.  Note that you may only use 26 total variables.
  17.  
  18.  
  19. '---------- Operator Interface (OI) - Analog Inputs --------------------------
  20.  
  21. p1_x        VAR byte    'Port 1, X-axis on Joystick
  22. p2_x        VAR byte    'Port 2, X-axis on Joystick
  23. p3_x        VAR byte    'Port 3, X-axis on Joystick
  24. p4_x        VAR byte    'Port 4, X-axis on Joystick
  25.  
  26. p1_y        VAR byte    'Port 1, Y-axis on Joystick
  27. p2_y        VAR byte    'Port 2, Y-axis on Joystick
  28. p3_y        VAR byte    'Port 3, Y-axis on Joystick
  29. p4_y        VAR byte    'Port 4, Y-axis on Joystick
  30.  
  31. p1_wheel    VAR byte    'Port 1, Wheel on Joystick
  32. p2_wheel    VAR byte    'Port 2, Wheel on Joystick
  33. p3_wheel    VAR byte    'Port 3, Wheel on Joystick
  34. p4_wheel    VAR byte    'Port 4, Wheel on Joystick
  35.  
  36. 'p1_aux    VAR byte    'Port 1, Aux on Joystick
  37. 'p2_aux    VAR byte    'Port 2, Aux on Joystick
  38. 'p3_aux    VAR byte    'Port 3, Aux on Joystick
  39. 'p4_aux    VAR byte    'Port 4, Aux on Joystick
  40.  
  41. PWM1        Var byte    'Modified output for PWM1    <----ADDED
  42. PWM2        Var byte    'Modified output for PWM2    <----ADDED
  43.  
  44. '---------- Operator Interface - Digital Inputs ------------------------------
  45.  
  46. oi_swA    VAR byte    'OI Digital Switch Inputs 1 thru 8
  47. oi_swB    VAR byte    'OI Digital Switch Inputs 9 thru 16
  48.  
  49.  
  50. '---------- Robot Controller (RC) - Analog Inputs ----------------------------
  51.  
  52. 'sensor1    VAR byte    'RC Analog Input 1, connector pin 2
  53. 'sensor2    VAR byte    'RC Analog Input 2, connector pin 16
  54. 'sensor3    VAR byte    'RC Analog Input 3, connector pin 5
  55. 'sensor4    VAR byte    'RC Analog Input 4, connector pin 19
  56. 'sensor5    VAR byte    'RC Analog Input 5, connector pin 8
  57. 'sensor6    VAR byte    'RC Analog Input 6, connector pin 22
  58. 'sensor7    VAR byte    'RC Analog Input 7, connector pin 11
  59. 'bat_volt    VAR byte    'RC Analog Input 8, hardwired to the Battery
  60.                 'Vin = ((4.7/14.7)* Battery voltage)-0.4
  61.                 'Binary Battery Voltage = (Vin/5.0 V)*255
  62.  
  63.  
  64. '---------- Robot Controller - Digital Inputs --------------------------------
  65.  
  66. rc_swA    VAR byte    'RC Digital Inputs 1 thru 8
  67. rc_swB    VAR byte    'RC Digital Inputs 9 thru 16
  68.  
  69.  
  70. '---------- Robot Controller - Digital Outputs -------------------------------
  71.  
  72. relayA    VAR byte
  73. relayB    VAR byte
  74.  
  75.  
  76. '---------- Misc. ------------------------------------------------------------
  77.  
  78. PB_mode    VAR byte
  79. 'packet_num    VAR byte
  80. 'delta_t    VAR byte
  81.  
  82.  
  83.  
  84.  
  85. '========== DEFINE ALIASES ===================================================
  86. '=============================================================================
  87. '  Aliases are variables which are sub-divisions of variables defined
  88. '  above.  Aliases don't require any additional RAM.
  89.  
  90.  
  91. '---------- Aliases for each OI switch input ---------------------------------
  92. '  Below are aliases for the digital inputs located on the Operator Interface.
  93. '  Ports 1 & 3 have their inputs duplicated in ports 4 & 2 respectively.  The 
  94. '  inputs from ports 1 & 3 may be disabled via the 'Disable' dip switch 
  95. '  located on the Operator Interface.  See Users Manual for details.
  96.  
  97. p1_sw_trig    VAR oi_swA.bit0    'Joystick Trigger Button,    same as Port4 pin5 
  98. p1_sw_top    VAR oi_swA.bit1    'Joystick Top Button,        same as Port4 pin8
  99. p1_sw_aux1    VAR oi_swA.bit2    'Aux input,                same as Port4 pin9
  100. p1_sw_aux2    VAR oi_swA.bit3    'Aux input,                same as Port4 pin15
  101.  
  102. p3_sw_trig    VAR oi_swA.bit4    'Joystick Trigger Button,    same as Port2 pin5 
  103. p3_sw_top    VAR oi_swA.bit5    'Joystick Top Button,        same as Port2 pin8
  104. p3_sw_aux1    VAR oi_swA.bit6    'Aux input,                same as Port2 pin9
  105. p3_sw_aux2    VAR oi_swA.bit7    'Aux input,                same as Port2 pin15
  106.  
  107. p2_sw_trig    VAR oi_swB.bit0    'Joystick Trigger Button
  108. p2_sw_top    VAR oi_swB.bit1    'Joystick Top Button
  109. p2_sw_aux1    VAR oi_swB.bit2    'Aux input
  110. p2_sw_aux2    VAR oi_swB.bit3    'Aux input
  111.  
  112. p4_sw_trig    VAR oi_swB.bit4    'Joystick Trigger Button
  113. p4_sw_top    VAR oi_swB.bit5    'Joystick Top Button
  114. p4_sw_aux1    VAR oi_swB.bit6    'Aux input
  115. p4_sw_aux2    VAR oi_swB.bit7    'Aux input
  116.  
  117.  
  118. '---------- Aliases for each RC switch input ---------------------------------
  119. '  Below are aliases for the digital inputs located on the Robot Controller.
  120.  
  121. rc_sw1    VAR rc_swA.bit0
  122. rc_sw2    VAR rc_swA.bit1
  123. rc_sw3    VAR rc_swA.bit2
  124. rc_sw4    VAR rc_swA.bit3
  125. rc_sw5    VAR rc_swA.bit4
  126. rc_sw6    VAR rc_swA.bit5
  127. rc_sw7    VAR rc_swA.bit6
  128. rc_sw8    VAR rc_swA.bit7
  129. rc_sw9    VAR rc_swB.bit0
  130. rc_sw10    VAR rc_swB.bit1
  131. rc_sw11    VAR rc_swB.bit2
  132. rc_sw12    VAR rc_swB.bit3
  133. rc_sw13    VAR rc_swB.bit4
  134. rc_sw14    VAR rc_swB.bit5
  135. rc_sw15    VAR rc_swB.bit6
  136. rc_sw16    VAR rc_swB.bit7
  137.  
  138.  
  139. '---------- Aliases for each RC Relay outputs ---------------------------------
  140. '  Below are aliases for the relay outputs located on the Robot Controller.
  141.  
  142. relay1_fwd    VAR RelayA.bit0
  143. relay1_rev    VAR RelayA.bit1
  144. relay2_fwd    VAR RelayA.bit2
  145. relay2_rev    VAR RelayA.bit3
  146. relay3_fwd    VAR RelayA.bit4
  147. relay3_rev    VAR RelayA.bit5
  148. relay4_fwd    VAR RelayA.bit6
  149. relay4_rev    VAR RelayA.bit7
  150.  
  151. relay5_fwd    VAR RelayB.bit0
  152. relay5_rev    VAR RelayB.bit1
  153. relay6_fwd    VAR RelayB.bit2
  154. relay6_rev    VAR RelayB.bit3
  155. relay7_fwd    VAR RelayB.bit4
  156. relay7_rev    VAR RelayB.bit5
  157. relay8_fwd    VAR RelayB.bit6
  158. relay8_rev    VAR RelayB.bit7
  159.  
  160.  
  161. '---------- Aliases for the Pbasic Mode Byte (PB_mode) -----------------------
  162. '  The last bit of the PB_mode byte (aliased as comp_mode) indicates the status
  163. '  of the Competition Control, either Enabled or Disabled.  This indicates the
  164. '  starting and stopping of rounds at the competitions.  Comp_mode is the same
  165. '  as the "Disabled" LED on the Operator Interface.
  166. '  Comp_mode = 1 for Enabled, 0 for Disabled.
  167.  
  168. comp_mode        VAR PB_mode.bit7
  169.  
  170.  
  171.  
  172.  
  173. '========= DEFINE CONSTANTS FOR INITIALIZATION ===============================
  174. '=============================================================================
  175. '  The initialization code is used to select the input data used by PBASIC.
  176. '  The Master micro-processor (uP) sends the data you select to the BS2SX
  177. '  PBASIC uP.  You may select up to 26 constants, corresponding
  178. '  to 26 variables, from the 32 available to you.  Make sure that you have 
  179. '  variables for all the bytes recieved in the serin command.
  180. '
  181. '  The constants below have a "c_" prefix, as compared to the variables that 
  182. '  they will represent.
  183. '
  184. '  Set the Constants below to 1 for each data byte you want to recieve.
  185. '  Set the Constants below to 0 for the unneeded data bytes.
  186.  
  187.  
  188. '---------- Set the Initialization constants you want to read ----------------
  189.  
  190. c_p1_y        CON    1
  191. c_p2_y        CON    1
  192. c_p3_y        CON    1
  193. c_p4_y        CON    1
  194.  
  195. c_p1_x        CON    1
  196. c_p2_x        CON    1
  197. c_p3_x        CON    1
  198. c_p4_x        CON    1
  199.  
  200. c_p1_wheel        CON    1
  201. c_p2_wheel        CON    1
  202. c_p3_wheel        CON    1
  203. c_p4_wheel        CON    1
  204.  
  205. c_p1_aux        CON    0
  206. c_p2_aux        CON    0
  207. c_p3_aux        CON    0
  208. c_p4_aux        CON    0
  209.  
  210. c_oi_swA        CON    1
  211. c_oi_swB        CON    1
  212.  
  213. c_sensor1        CON    0
  214. c_sensor2        CON    0
  215. c_sensor3        CON    0
  216. c_sensor4        CON    0
  217. c_sensor5        CON    0
  218. c_sensor6        CON    0
  219. c_sensor7        CON    0
  220. c_batt_volt        CON    0
  221.  
  222. c_rc_swA        CON    1
  223. c_rc_swB        CON    1
  224.  
  225. c_delta_t        CON    0
  226. c_PB_mode        CON    1
  227. c_packet_num    CON    0
  228. c_res01        CON    0
  229.  
  230.  
  231. '---------- Initialization Constant VOLTAGE - USER DEFINED -------------------
  232. '  This is the 'Low Battery' detect voltage.  The 'Low Battery' LED will
  233. '  blink when the voltage drops below this value.
  234. '  Basically set VOLTAGE = INT ((DESIRED FLASH VOLTAGE + 0.4) * 16.3)
  235. '  Example, for a 10 Volt trigger, set Voltage eq 170.
  236.  
  237. dataInitVolt    CON 153    '9.0 Volts
  238.  
  239.  
  240.  
  241.  
  242. '========== DEFINE CONSTANTS (DO NOT CHANGE) =================================
  243. '=============================================================================
  244. ' Baud rate for communications with User CPU
  245. OUTBAUD    CON    20    ' (62500, 8N1, Noninverted)
  246. INBAUD    CON    20    ' (62500, 8N1, Noninverted)
  247.  
  248. USERCPU    CON 4
  249. FPIN        CON 1
  250. COMA        CON 1
  251. COMB        CON 2
  252. COMC        CON 3
  253.  
  254.  
  255.  
  256.  
  257. '========== MAIN PROGRAM =====================================================
  258. '=============================================================================
  259.  
  260. '---------- Input & Output Declarations --------------------------------------
  261.  
  262. Output    COMB
  263. Input        COMA
  264. Input        COMC
  265.  
  266. Output    7    'define Basic Run LED on RC => out7
  267.  
  268. Output      8    'define Robot Feedback LED => out8    => PWM1 Green
  269. Output      9    'define Robot Feedback LED => out9    => PWM1 Red
  270. Output      10    'define Robot Feedback LED => out10    => PWM2 Green
  271. Output      11    'define Robot Feedback LED => out11 => PWM2 Red
  272. Output      12    'define Robot Feedback LED => out12 => Relay1 Red
  273. Output      13    'define Robot Feedback LED => out13 => Relay1 Green
  274. Output      14    'define Robot Feedback LED => out14 => Relay2 Red
  275. Output      15    'define Robot Feedback LED => out15 => Relay2 Green
  276.  
  277.  
  278. '---------- Initialize Inputs & Outputs --------------------------------------
  279.  
  280. Out7  = 1        'Basic Run LED on RC
  281. Out8  = 0        'PWM1 LED - Green
  282. Out9  = 0        'PWM1 LED - Red
  283. Out10 = 0        'PWM2 LED - Green
  284. Out11 = 0        'PWM2 LED - Red
  285. Out12 = 0        'Relay1 LED - Red
  286. Out13 = 0        'Relay1 LED - Green
  287. Out14 = 0        'Relay2 LED - Red
  288. Out15 = 0        'Relay2 LED - Green
  289.  
  290. p1_x = 127        'Port 1, X-axis on Joystick
  291. p2_x = 127        'Port 2, X-axis on Joystick
  292. p3_x = 127        'Port 3, X-axis on Joystick
  293. p4_x = 127        'Port 4, X-axis on Joystick
  294.  
  295. p1_y = 127        'Port 1, Y-axis on Joystick
  296. p2_y = 127        'Port 2, Y-axis on Joystick
  297. p3_y = 127        'Port 3, Y-axis on Joystick
  298. p4_y = 127        'Port 4, Y-axis on Joystick
  299.  
  300. p1_wheel = 127    'Port 1, Wheel on Joystick
  301. p2_wheel = 127    'Port 2, Wheel on Joystick
  302. p3_wheel = 127    'Port 3, Wheel on Joystick
  303. p4_wheel = 127    'Port 4, Wheel on Joystick
  304.  
  305. 'p1_aux = 127    'Port 1, Aux Analog
  306. 'p2_aux = 127    'Port 2, Aux Analog
  307. 'p3_aux = 127    'Port 3, Aux Analog
  308. 'p4_aux = 127    'Port 4, Aux Analog
  309.  
  310.  
  311.  
  312.  
  313. '========== PBASIC - MASTER uP INITIALIZATION ROUTINE ========================
  314. '=============================================================================
  315. '  DO NOT CHANGE THIS!  DO NOT MOVE THIS!
  316. '  The init routine sends 5 bytes to the Master uP, defining which data bytes to receive.
  317. '  1)  Collect init.
  318. '  2)  Lower the COMA line, which is the clk line for the shift out command.
  319. '  3)  Lower COMB line to tell pic that we are ready to send init data.
  320. '  4)  Wait for pic to lower the COMC line, signaling pic is ready for data.
  321. '  5)  Now send out init dat to pic, all 5 bytes.
  322. '  6)  Now set direction and levels for the COMA and COMB pins.
  323.  
  324. tempA        CON    c_p3_x <<1 + c_p4_x <<1 + c_p1_x <<1 + c_p2_x <<1 + c_rc_swB
  325. dataInitA    CON    tempA <<1 + c_rc_swA <<1 + c_oi_swB <<1 + c_oi_swA
  326. tempB        CON    c_sensor4 <<1 + c_sensor3 <<1 + c_p1_y <<1 + c_p2_y <<1 + c_sensor2
  327. dataInitB    CON    tempB <<1 + c_sensor1 <<1 + c_packet_num <<1 + c_PB_mode
  328. tempC        CON    c_batt_volt <<1 + c_sensor7 <<1 + c_p1_wheel <<1 + c_p2_wheel <<1 + c_sensor6
  329. dataInitC    CON    tempC <<1 + c_sensor5 <<1 + c_p3_y <<1 + c_p4_y
  330. tempD        CON    c_res01 <<1 + c_delta_t <<1 + c_p3_aux <<1 + c_p4_aux <<1 + c_p1_aux
  331. dataInitD    CON    tempD <<1 + c_p2_aux  <<1 + c_p3_wheel <<1 + c_p4_wheel
  332.  
  333. Output    COMA
  334. low        COMA
  335. low        COMB
  336. Wait_init:    if IN3 = 1 then Wait_init:
  337. Shiftout    COMB,COMA,1, [dataInitA,dataInitB,dataInitC,dataInitD,dataInitVolt]
  338. Input        COMA
  339. high        COMB
  340.  
  341.  
  342.  
  343.  
  344. '========== MAIN LOOP ========================================================
  345. '=============================================================================
  346.  
  347. MainLoop:
  348.  
  349.  
  350. '---------- Serin Command - Get Data from Master uP --------------------------
  351. '  Construct the "serin" command using the following rules:
  352. '  1) There must be one variable for every input defined in the "Define Constants for Init" section.
  353. '  2) The order must match the order in the EXAMPLE SERIN COMMAND below.
  354. '  3) The total number of all variables may not exceed 26.
  355. '  4) Only use one "Serin" command.
  356. '  5) The Serin command must occupy one line.
  357. '
  358. '  If you see a BASIC INIT ERR on the Robot Controller after programming and pressing RESET, then
  359. '  there is a problem with the Serin command below.  Check the number of variables.  A BASIC INIT ERR
  360. '  will not occur if you have the variables in the wrong order, however your code will not work correctly.
  361. '
  362. '  EXAMPLE SERIN COMMAND
  363. '  This example exceed the 26 variable limit and is not on one line:
  364. '
  365. '  Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,sensor1,
  366. '                     sensor2,p2_y,p1_y,sensor3,sensor4,p4_y,p3_y,sensor5,sensor6,p2_wheel,p1_wheel,
  367. '                     sensor7,sensor8,p4_wheel,p3_wheel,p2_aux,p1_aux,p4_aux,p3_aux,delta_t,res01]
  368. '
  369.    Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
  370.  
  371.  
  372. '---------- Blink BASIC RUN LED ----------------------------------------------
  373. Toggle 7            'Basic Run LED on the RC is toggled ON/OFF every loop.
  374.  
  375.  
  376.  
  377.  
  378. '========== PERFORM OPERATIONS ===============================================
  379. '  Add your custom code here.
  380. '  Delete any of the following sections below (except for Output Data) as desired.
  381.  
  382.  
  383. '---------- Buttons to Relays ------------------------------------------------
  384.  
  385. '  The &  used below is the PBASIC symbol for AND
  386. '  The &~ used below is the PBASIC symbol for AND NOT
  387.  
  388. relay1_fwd = p1_sw_trig &~ rc_sw1     'Port 1 Trigger = Relay 1 Forward
  389.                         'Relay 1 wont go Forward if rc_sw1 is ON
  390.  
  391. relay1_rev = p1_sw_top &~ rc_sw2     'Port 1 Thumb = Relay 1 Reverse
  392.                         'Relay 1 wont go Reverse if rc_sw2 is ON
  393.  
  394. relay2_fwd = p2_sw_trig &~ rc_sw3     'Port 2 Trigger = Relay 2 Forward
  395.                         'Relay 2 wont go Forward if rc_sw3 is ON
  396.  
  397. relay2_rev = p2_sw_top &~ rc_sw4     'Port 2 Thumb = Relay 2 Reverse
  398.                         'Relay 2 wont go Reverse if rc_sw4 is ON
  399.  
  400. relay3_fwd = p3_sw_trig            'Port 3 Trigger = Relay 3 Forward
  401. relay3_rev = p3_sw_top             'Port 3 Thumb   = Relay 3 Reverse
  402. relay4_fwd = p4_sw_trig            'Port 4 Trigger = Relay 4 Forward
  403. relay4_rev = p4_sw_top             'Port 4 Thumb   = Relay 4 Reverse
  404.  
  405.  
  406. relay5_fwd = p1_sw_aux1            'Port 1 Aux1 = Relay 5 Forward
  407. relay5_rev = p1_sw_aux2            'Port 1 Aux2 = Relay 5 Forward
  408. relay6_fwd = p3_sw_aux1            'Port 3 Aux1 = Relay 6 Forward
  409. relay6_rev = p3_sw_aux2            'Port 3 Aux2 = Relay 6 Forward
  410. relay7_fwd = p4_sw_aux1            'Port 4 Aux1 = Relay 7 Forward
  411. relay7_rev = p4_sw_aux2            'Port 4 Aux2 = Relay 7 Reverse
  412. relay8_fwd = 1                'Relay 8 always Forward
  413. relay8_rev = 0                'Relay 8 always Forward
  414.  
  415. '---------- Feedback LEDs for PWM1, PWM2 -------------------------------------
  416.  
  417. 'Out8  =   p1_y/216        'LED is ON when Victor883 full forward  <---REMOVED
  418. 'Out9  = ~(p1_y/56  max 1)    'LED is ON when Victor883 full reverse  <---REMOVED
  419. 'Out10 =   p2_y/216        'LED is ON when Victor883 full forward  <---REMOVED
  420. 'Out11 = ~(p2_y/56  max 1)    'LED is ON when Victor883 full reverse  <---REMOVED
  421.  
  422. '---------- Feedback LEDs for Relay1, Relay2 ---------------------------------
  423.  
  424. Out13 = relay1_fwd        'LED is ON when Relay 1 is Forward
  425. Out12 = relay1_rev        'LED is ON when Relay 1 is Reverse
  426. Out15 = relay2_fwd        'LED is ON when Relay 2 is Forward
  427. Out14 = relay2_rev        'LED is ON when Relay 2 is Reverse
  428.  
  429.  
  430. '---------- PWM outputs Limited by Limit Switches  ---------------------------
  431.  
  432. if rc_sw5 = 0 then next1:
  433.     p3_y = p3_y MAX 127
  434. next1:
  435.  
  436. if rc_sw6 = 0 then next2:
  437.     p3_y = p3_y MIN 127
  438. next2:
  439.  
  440. if rc_sw7 = 0 then next3:
  441.     p4_y = p4_y MAX 127
  442. next3:
  443.  
  444. if rc_sw8 = 0 then next4:
  445.     p4_y = p4_y MIN 127
  446. next4:
  447.  
  448. if rc_sw9 = 0 then next5:
  449.     p1_wheel = p1_wheel MAX 127
  450. next5:
  451.  
  452. if rc_sw10 = 0 then next6:
  453.     p1_wheel = p1_wheel MIN 127
  454. next6:
  455.  
  456. if rc_sw11 = 0 then next7:
  457.     p2_wheel = p2_wheel MAX 127
  458. next7:
  459.  
  460. if rc_sw12 = 0 then next8:
  461.     p2_wheel = p2_wheel MIN 127
  462. next8:
  463.  
  464. if rc_sw13 = 0 then next9:
  465.     p3_wheel = p3_wheel MAX 127
  466. next9:
  467.  
  468. if rc_sw14 = 0 then next10:
  469.     p3_wheel = p3_wheel MIN 127
  470. next10:
  471.  
  472. if rc_sw15 = 0 then next11:
  473.     p4_wheel = p4_wheel MAX 127
  474. next11:
  475.  
  476. if rc_sw16 = 0 then next12:
  477.     p4_wheel = p4_wheel MIN 127
  478. next12:
  479.  
  480.  
  481. '---------- TANK DRIVE + Feedback LEDs for PWM1, PWM2 -------------------------
  482. '  This section modified the output of PWM1, and PWM 2 for control from one
  483. '  joystick (Port 1).  The Out8 thru Out11 lines control the Feedback LEDs.
  484. '    Y-axis controls speed.
  485. '    X-axis turns.
  486. '    PWM1 - Left motor.
  487. '    PWM2 - Right motor.
  488.  
  489. PWM1 = (((2000 + p1_y - p1_x + 127) Min 2000 Max 2254) - 2000)        '<---ADDED
  490. PWM2 = (((2000 + p1_y + p1_x - 127) Min 2000 Max 2254) - 2000)        '<---ADDED
  491.  
  492. Out8  =   pwm1/216        'LED is ON when Victor883 full forward    '<---ADDED
  493. Out9  = ~(pwm1/56  max 1)    'LED is ON when Victor883 full reverse    '<---ADDED
  494. Out10 =   pwm2/216        'LED is ON when Victor883 full forward    '<---ADDED
  495. Out11 = ~(pwm2/56  max 1)    'LED is ON when Victor883 full reverse    '<---ADDED
  496.  
  497.  
  498.  
  499. '========== OUTPUT DATA ======================================================
  500. '=============================================================================
  501. '  The Serout line sends data to the Output uP.  The Output uP passes this to each PWM 1-16
  502. '  and Relay 1-8.  The Output uP will not output data if there is no communication with the
  503. '  Operator Interface or if the Competition Mode is Disabled.  Do not delete any elements
  504. '  from the Serout array.  Set unused PWM outputs to 127.  Set unused relay outputs to 0.
  505. '
  506. '  Serout USERCPU, OUTBAUD, [255,255,(PWM1),relayA,(PWM2),relayB,(PWM3),(PWM4),(PWM5),(PWM6),(PWM7),(PWM8),(PWM9),(PWM10),(PWM11),(PWM12),(PWM13),(PWM14),(PWM15),(PWM16)]
  507.  
  508.    Serout USERCPU, OUTBAUD, [255,255,pwm1,relayA,pwm2,relayB,p3_y,p4_y,p1_x,p2_x,p3_x,p4_x,p1_wheel,p2_wheel,p3_wheel,p4_wheel,127,127,127,127]
  509. '  ^---ADDED PWM1,PWM2 TO SEROUT COMMAND ABOVE
  510.  
  511.  
  512. Goto MainLoop:
  513.  
  514.  
  515. Stop