Go to Post A video is worth 30,000 words a second. - Thromgord [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 14-07-2008, 23:53
gallo26's Avatar
gallo26 gallo26 is offline
Team 79 Alumni
AKA: Bryan Gallo
FRC #0079 (Team KRUNCH)
Team Role: Alumni
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Largo, Florida
Posts: 113
gallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to all
Send a message via AIM to gallo26
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!!!
__________________
Team 79 Alumni '11- Present
Team 79 Driver '09, '10
Team 79 Senior CAD Designer '09, '10
Team 79 President '09
Team 79 Electrical Sub Team Leader '08, '09

  #2   Spotlight this post!  
Unread 15-07-2008, 10:05
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,801
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
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:
Make sure the victors are in coast though, otherwise, you'll be trying to drag rather than roll the rear wheels around.

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
A more sophisticated control would use the difference between where you want to be (p1_x) and where it currently is (pot) to slow down the steering motor as p1_x and pot get close. For example, pwm4 = (p1_x - pot) * 5 / 10, where you'd play with the value 5/10 until you slowed the response so it wouldn't overshoot and thrash. Just be aware of how pBasic deals with negative numbers.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 15-07-2008 at 14:30.
  #3   Spotlight this post!  
Unread 15-07-2008, 10:23
gallo26's Avatar
gallo26 gallo26 is offline
Team 79 Alumni
AKA: Bryan Gallo
FRC #0079 (Team KRUNCH)
Team Role: Alumni
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Largo, Florida
Posts: 113
gallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to all
Send a message via AIM to gallo26
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!
__________________
Team 79 Alumni '11- Present
Team 79 Driver '09, '10
Team 79 Senior CAD Designer '09, '10
Team 79 President '09
Team 79 Electrical Sub Team Leader '08, '09


Last edited by gallo26 : 15-07-2008 at 10:31.
  #4   Spotlight this post!  
Unread 15-07-2008, 10:26
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,801
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
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.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 15-07-2008 at 10:48.
  #5   Spotlight this post!  
Unread 15-07-2008, 10:52
gallo26's Avatar
gallo26 gallo26 is offline
Team 79 Alumni
AKA: Bryan Gallo
FRC #0079 (Team KRUNCH)
Team Role: Alumni
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Largo, Florida
Posts: 113
gallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to all
Send a message via AIM to gallo26
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:
I saw that in the default code for PWM limitations with limit switches. so i thought if i said whenever the High gear part of that relay is active.... that specific PWM is off
__________________
Team 79 Alumni '11- Present
Team 79 Driver '09, '10
Team 79 Senior CAD Designer '09, '10
Team 79 President '09
Team 79 Electrical Sub Team Leader '08, '09

  #6   Spotlight this post!  
Unread 15-07-2008, 10:58
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,801
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
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:
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #7   Spotlight this post!  
Unread 15-07-2008, 11:01
gallo26's Avatar
gallo26 gallo26 is offline
Team 79 Alumni
AKA: Bryan Gallo
FRC #0079 (Team KRUNCH)
Team Role: Alumni
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Largo, Florida
Posts: 113
gallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to all
Send a message via AIM to gallo26
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?
__________________
Team 79 Alumni '11- Present
Team 79 Driver '09, '10
Team 79 Senior CAD Designer '09, '10
Team 79 President '09
Team 79 Electrical Sub Team Leader '08, '09

  #8   Spotlight this post!  
Unread 15-07-2008, 11:16
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,801
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
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
Make sure you initialize it BEFORE your MainLoop:
Code:
emergency_stop = 0
Inside your main loop check p2_sw_aux1 to see if you should stop.
Code:
If p2_sw_aux1 = 1 then emergency_stop = 1
emergency_stop will only get set to 1. It never resets to 0 anywhere unless you power cycle.

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:
You could also put an alternate Serout command inside the If with 127's hardcoded in place of the PWM variables.

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:
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 15-07-2008 at 14:33.
  #9   Spotlight this post!  
Unread 15-07-2008, 11:26
gallo26's Avatar
gallo26 gallo26 is offline
Team 79 Alumni
AKA: Bryan Gallo
FRC #0079 (Team KRUNCH)
Team Role: Alumni
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Largo, Florida
Posts: 113
gallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to all
Send a message via AIM to gallo26
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!!!
__________________
Team 79 Alumni '11- Present
Team 79 Driver '09, '10
Team 79 Senior CAD Designer '09, '10
Team 79 President '09
Team 79 Electrical Sub Team Leader '08, '09

  #10   Spotlight this post!  
Unread 15-07-2008, 19:32
gallo26's Avatar
gallo26 gallo26 is offline
Team 79 Alumni
AKA: Bryan Gallo
FRC #0079 (Team KRUNCH)
Team Role: Alumni
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Largo, Florida
Posts: 113
gallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to allgallo26 is a name known to all
Send a message via AIM to gallo26
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:
Error 129-Expected ':' or end of-line
But it only does that for everyline i have that states
Code:
PWM1 = p1_y
or anything else with a PWM. what could be causing this?

Thanks again for helping me!
__________________
Team 79 Alumni '11- Present
Team 79 Driver '09, '10
Team 79 Senior CAD Designer '09, '10
Team 79 President '09
Team 79 Electrical Sub Team Leader '08, '09

  #11   Spotlight this post!  
Unread 15-07-2008, 20:38
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,801
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
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 first line is only a comment and the PWMs are just marking the fixed positions in the Serout call where you put the values that you want to send out to the motors. Position is everything in the Serout call. For example, see that (PWM1) is the third argument in the comment line. That means in the real line of code below it the value of p1_y, as the third argument, will be sent out to drive PWM1.

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:
p3_y is then used as the seventh argument in the Serout call, so it's holding the value for (PWM3).

-----------
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.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 15-07-2008 at 21:10.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


All times are GMT -5. The time now is 00:06.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi