|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#7
|
||||
|
||||
|
for those of you who only speak PBasic, here is our code for closed loop steering - it uses the one joystick code to control the motors. Yaw is the signal from the Gyro (BTW the gyro was upside down on our bot)
'---------- 1 Joystick Drive --------------------------------------------------------- '********************Gyro yaw rate closed loop steering *************************** 'compairs gyro signal to p1_x steering command to close the steering loop if p1_sw_top=0 then gyro_override 'when button is pressed then close loop AD: 'line following code jumps into here yaw_error = (((2127 + p1_x - yaw) Min 2000 Max 2254)-2000) yaw_command =(((1873 + yaw_error + yaw_error) Min 2000 Max 2254) -2000) goto gyro_end gyro_override: yaw_command=p1_x gyro_end: '************************************************* *********************** ' This code mixes the Y and X axis on Port 1 to allow one joystick drive. ' Joystick forward = Robot forward ' Joystick backward = Robot reverse ' Joystick right = Robot rotates right ' Joystick left = Robot rotates left ' Connect the left drive motors to PWM15 and/or PWM16 ' Connect the right drive motors to PWM13 and/or PWM14 'NOTE: p1_x = 0 at full right, 255 at full left drive_R = (((1873 + p1_y + yaw_command) Min 2000 Max 2254) - 2000) drive_L = (((2127 + p1_y - yaw_command) Min 2000 Max 2254) - 2000) |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| gyro code | odin892 | Programming | 2 | 08-04-2003 14:50 |
| Team 469 and the Gyro | archiver | 2001 | 0 | 24-06-2002 02:57 |
| This Gyro is driving me crazy! | archiver | 2001 | 2 | 23-06-2002 23:35 |
| Is any team using the gyro chip? | Ragin_Kage | Kit & Additional Hardware | 4 | 10-04-2002 12:11 |
| Have YOU used the gyro chip? | FotoPlasma | Technical Discussion | 10 | 31-01-2002 13:26 |