|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
2002 FRC Controller...
Hey I'm working on repairing all my team's old robots back to working condition for robot demonstrations and driver practice. The problem i am facing is these controllers now use BASIC programming. Now i understand most of it but im still stuck on one part of it. the PWMs...
This robot is a 3 wheeled robot usin rocking gearshift. When in low gear, all 3 wheels and powered. When in High gear the back 2 wheels are not powered, and the front one drives the robot. Steering uses one motor and a potentiometer. When programmed correctly, the steering will react and mimic the joystick like an RC car would (servo). We also have a Mini Krunch which has a servo and motor onboard that runs off the port 3 X and Y axis I am working on linking the first 3 PWMs to Port 1 Y axis. thats easy. and the Steering motor to PWM4. But i dont see where to link that, or how to add the potentiometer into this. And then after that... how do i tell it to not power the rear motors while in high gear? I read all the documents about Legacy and all that, but i just dont understand it... Thank you to anyone who can help me with this!!! |
|
#2
|
|||||
|
|||||
|
Re: 2002 FRC Controller...
Draw yourself a flowchart of what you what to happen.
The code will depend a little on what version of pBasic you’re using. In 2002 there was an if-then statement but no if-then-else. 2003 introduced the if-then-else, so nowadays it’s easier to code up. Turning off the motors when in high gear would look something like: Code:
pwm1 = p1_y
pwm2 = p1_y
pwm3 = p1_y
If gear < High then skipit
pwm2 = 127
pwm3 = 127
skipit:
For steering I imagine you’d want to force your potentiometer reading to match your joystick steering axis (making sure the pot is mechanically at 127 when the wheel is straight forward. Here is a simple way, but you'd have to play with the values for pwm4 so it didn't turn too quickly, overshoot, and start thrashing back n forth. P.S. It's also nice to have some mechanical drag on the steering, so it holds it's position a little and isn't just waggling loosely. Code:
pwm4 = 127 If pot < p1_x then pwm4 = 100 If pot > p1_x then pwm4 = 155 Last edited by Mark McLeod : 15-07-2008 at 14:30. |
|
#3
|
||||
|
||||
|
Re: 2002 FRC Controller...
Well im not too sure i need to worry about the victors, The wheels are indirectly powered. They are inflated tires and giant rollers come down and push on them to power them. When it switches to high gear, it ricks with 3 pistons, removing force from the rear wheels and pushing a larger roller on the front wheel.
Ok thanks! that pretty much addresses all my problems. I'll add that and then go out and test it Thursday when im at the school. One more thing..... do i need to edit or change the Serout line? again Thanks so much! Last edited by gallo26 : 15-07-2008 at 10:31. |
|
#4
|
|||||
|
|||||
|
Re: 2002 FRC Controller...
You shouldn't have to change Serout. The pwm's should already be there.
P.S. I saw your victor comment. Wherever you have your code to move the rollers up and down you can probably drop in your victor control as well. Last edited by Mark McLeod : 15-07-2008 at 10:48. |
|
#5
|
||||
|
||||
|
Re: 2002 FRC Controller...
Yeah ok, that works. Can i limit the PWMs by saying something like...
Code:
'---------- PWM outputs Limited ------------------------------------------------------------------------------ '------------------------------------------------------------------------------------------------------------- if relay2_fwd = 1 then next1: PWM2 = 127 next1: if relay2_fwd = 1 then next2: PWM3 = 127 next2: if relay2_fwd = 0 then next3: PWM2 = p1_y next3: if relay2_fwd = 0 then next4: PWM3 = p1_y next 4: |
|
#6
|
|||||
|
|||||
|
Re: 2002 FRC Controller...
Yep, that'll work.
That's the older pBasic style, so it's demonstrating one way to work around not having an if-then-else statement. There are several ways to do it. This is a shorter way to do the same thing: Code:
PWM2 = p1_y if relay2_fwd = 1 then next1: PWM2 = 127 next1: |
|
#7
|
||||
|
||||
|
Re: 2002 FRC Controller...
o ok. lol yeah that looks a lot easier!
Now one thing i was just mentioned, we want to add Emergency Stop buttons. In pBASIC how to i say When i press this button p2_sw_aux1, the robot is disabled until i do a powercycle? |
|
#8
|
|||||
|
|||||
|
Re: 2002 FRC Controller...
You want to create a software "latch" that remembers the emergency stop button was pushed.
Up at the top declare a variable that will be your latch. Code:
emergency_stop VAR byte ' Stop until power cycle Code:
emergency_stop = 0 Code:
If p2_sw_aux1 = 1 then emergency_stop = 1 Then immediately before your Serout, test emergency_stop and turn everything off. Code:
If emergency_stop = 0 then nevermind:
PWM1 = 0
PWM2 = 0
'and so on (also decide how you want your relays set)
nevermind:
Another way to do it would be to prevent the regular Serout from being called at all by wrapping it with your emergency_stop check and the Master controller will shut everything down for you. This'll force the "Basic Run Err" light to come on in about a tenth of a second. Code:
If emergency_stop = 1 then nevermind:
Serout(...
nevermind:
Last edited by Mark McLeod : 15-07-2008 at 14:33. |
|
#9
|
||||
|
||||
|
Re: 2002 FRC Controller...
wow thanks!!!! as you can tell i'm not really the programming type, but i decided to work on it before the next meeting so we can run tests with it.
You have been such a big help thanks!!! ![]() |
|
#10
|
||||
|
||||
|
Re: 2002 FRC Controller...
Sorry to bother you again, but i finally finished what i needed to do with the code thanks to your help. but now im getting an error. When i do a Syntax Check i get an
Quote:
Code:
PWM1 = p1_y Thanks again for helping me! |
|
#11
|
|||||
|
|||||
|
Re: 2002 FRC Controller...
The PWM1,2,3,4 that you're using need to be declare just like we declared "emergency_stop" in an earlier post.
Looking at the default code I'm guessing you started with, I spoke too quickly about not needing to change the Serout command. You don't have to change it, but you might want to so that it's clearer. --------------- In the default code you're using, the "PWM" variables don't really exist. PWMx is used only in comments and have not been declared. (comment lines start with a '). These two lines are at the bottom: Code:
' Serout USERCPU, OUTBAUD, [255,255,(PWM1),relayA,(PWM2),relayB,(PWM3),(PWM4),(PWM5),(PWM6),(PWM7),(PWM8),(PWM9),(PWM10),(PWM11),(PWM12),(PWM13),(PWM14),(PWM15),(PWM16)] Serout USERCPU, OUTBAUD, [255,255,p1_y,relayA,p2_y,relayB,p3_y,p4_y,p1_x,p2_x,p3_x,p4_x,p1_wheel,p2_wheel,p3_wheel,p4_wheel] The default code actually reuses existing variables to hold the pwm values it wants to send. For instance, p3_y is used here is these lines straight from the default: Code:
if rc_sw5 = 0 then next1:
p3_y = p3_y MAX 127
next1:
----------- If you do go with declaring the PWMs you started with, then I'd recommend just copying the working line of code and commenting out the original line ('). Then just replace p1_y, etc with the four PWM variables you're using. Last edited by Mark McLeod : 15-07-2008 at 21:10. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| FRC Robot Controller Broke | animemanga197 | Kit & Additional Hardware | 6 | 02-02-2008 18:12 |
| FRC Robot Controller/Speed Controller | RoarRoar | Control System | 3 | 17-01-2008 10:41 |
| Amount of power drawn by FRC controller? | Teger | Electrical | 6 | 08-01-2007 17:39 |
| FRC 2002 Very Fast Ball Collector | groves | Technical Discussion | 13 | 12-01-2006 15:54 |
| 2003's FRC Robot Controller | ahmed | Programming | 7 | 18-12-2003 22:43 |