Posted by bill whitley at 2/14/2001 5:39 PM EST
Student on team #70, Auto City Bandits, from Powers Catholic High School and Kettering University.
Can anyone double check this code? Tell me if it will work.
if p3_wheel > 240 then relay5_fwd = 1
if p3_wheel 240 then JUMP2
relay5_fwd = 0
relay5_rev = 0
JUMP2:
if p4_wheel > 240 then relay6_fwd = 1
if p4_wheel 240 then JUMP3
relay6_fwd = 0
relay6_rev = 0
JUMP3:
I am concerned about ending the IF THEN statements.
Posted by bill whitley at 2/14/2001 5:43 PM EST
Student on team #70, Auto City Bandits, from Powers Catholic High School and Kettering University.
In Reply to: PBASIC HELP, ASAP!!
Posted by bill whitley on 2/14/2001 5:39 PM EST:
By default, does joystick 1 (y axis) control PWM 1?
also, do joysticks 2-4 operate the same way? (y axis controls PWM?)
Bill
Team #70
“Who needs an EE or CE when you have chiefdelphi.com?”
Posted by bill whitley at 2/14/2001 5:47 PM EST
Student on team #70, Auto City Bandits, from Powers Catholic High School and Kettering University.
In Reply to: MORE PBASIC HELP, ASAP!!
Posted by bill whitley on 2/14/2001 5:43 PM EST:
Is this necessary???
PWM1 = p1_y
PWM2 = p2_y
PMW3 = p3_y
PWM4 = p4_y
Do we need to define PWM1 as a var byte?
Posted by Joe Ross at 2/14/2001 6:22 PM EST
Engineer on team #330, Beach Bot, from Hope Chapel Academy and NASA/JPL , J&F Machine, and Raytheon.
In Reply to: EVEN MORE PBASIC HELP, ASAP!!
Posted by bill whitley on 2/14/2001 5:47 PM EST:
: Is this necessary???
: PWM1 = p1_y
: PWM2 = p2_y
: PMW3 = p3_y
: PWM4 = p4_y
: Do we need to define PWM1 as a var byte?
If you are using the default program then you don’t need to do this. It is handled in the serout command.
Posted by Stephen at 2/14/2001 10:15 PM EST
Other on team #122, NASA Knights, from Grafton High School (Robotics team is at NHGS) and NASA.
In Reply to: EVEN MORE PBASIC HELP, ASAP!!
Posted by bill whitley on 2/14/2001 5:47 PM EST:
I recomend you not make PWM1(or any PWM) a variable. It just, simply put, wastes those 26 variables. Just go to the serout command, and where PWM1 is, just put p1_y. This also works for other things, I’ll give you one more example. We have a servo, that will be 156 when nothing is pressed (closed position), and 10 when p1_sw_top is pressed (open position), instead of wasting a variable and putting an again wasteful if loop in, I just went to the serout command, and at PWM4 wrote
((p1_sw_top ^ 1)*146)+10
hope that helped, if you need any more help, feel free to e-mail me at [email protected]
: Is this necessary???
: PWM1 = p1_y
: PWM2 = p2_y
: PMW3 = p3_y
: PWM4 = p4_y
: Do we need to define PWM1 as a var byte?
Posted by Nate Smith at 2/15/2001 12:02 PM EST
Other on team #66, Frostbite, from Willow Run High School and GM Powertrain.
In Reply to: Re: EVEN MORE PBASIC HELP, ASAP!!
Posted by Stephen on 2/14/2001 10:15 PM EST:
: I recomend you not make PWM1(or any PWM) a variable. It just, simply put, wastes those 26 variables. Just go to the serout command, and where PWM1 is, just put p1_y. This also works for other things, I’ll give you one more example. We have a servo, that will be 156 when nothing is pressed (closed position), and 10 when p1_sw_top is pressed (open position), instead of wasting a variable and putting an again wasteful if loop in, I just went to the serout command, and at PWM4 wrote
: ((p1_sw_top ^ 1)*146)+10
While I agree that in some cases, it is easiest to just put the variable(in the case of PWM1 = p1_y) or maybe a SHORT formula directly in the serout command, I’ve also seen some code in my workings with the Innovation First controller that takes several lines to accomplish(i.e. smooth the joystick input, implement a dead zone, etc., etc…) that would be a NIGHTMARE to try and code all into the serout. And even if it can be shortened enough to warrant putting it in the serout, which is easier to quickly understand(i.e. making a quick fix between matches)?
- PWM4 = ((p1_sw_top ^ 1) * 148)+10
OR
- serout USERCPU,OUTBAUD, [255,255,p1_y,relayA,p2_y,p3_y,((p1_sw_top ^ 1) * 148)+10,p4_y,p1_x,p2_x,p3_x,p4_x,p1_wheel,p2_wheel,p3_wheel,p4_wheel,127,127,127,127]
As a 3rd semester CS major, I have very quickly learned the importance of easy-to-understand code, even if it results in a slightly larger or smaller program.
Just my thoughts…
Nate
Posted by Stephen at 2/15/2001 6:26 PM EST
Other on team #122, NASA Knights, from Grafton High School (Robotics team is at NHGS) and NASA.
In Reply to: Something to be said for readable code…
Posted by Nate Smith on 2/15/2001 12:02 PM EST:
I agree with you in that one should write clean code, but when one starts to run out of the alloted 26 variables, clean code becomes less important and working code becomes the major line of thought. Just my opinions, I don’t know what they teach to CS majors (I’m only a freshman in highschool), but I imagine that when they do teach you things, they don’t teach them on the premise that you are restricted in your variable space.
Posted by Nate Smith at 2/15/2001 6:55 PM EST
Other on team #66, Frostbite, from Willow Run High School and GM Powertrain.
In Reply to: Re: Something to be said for readable code…
Posted by Stephen on 2/15/2001 6:26 PM EST:
: I agree with you in that one should write clean code, but when one starts to run out of the alloted 26 variables, clean code becomes less important and working code becomes the major line of thought. Just my opinions, I don’t know what they teach to CS majors (I’m only a freshman in highschool), but I imagine that when they do teach you things, they don’t teach them on the premise that you are restricted in your variable space.
Actually, a project that I had in my assembler class last semester was half graded based on size, with the smallest program getting all the points, and then going from there…you’d be surprised what ideas people came up with in order to shave a few bytes off their programs…
And a little more on topic, remember that you don’t necessarily have 26 variables, but rather 26 bytes…so if you can get away with using a nibble or even a bit for something(not a PWM output obviously, but for some other things) then that gives you a little more room to play with…and don’t forget those ever-helpful aliases…
Nate
Posted by Dung Cao at 2/15/2001 7:59 AM EST
Engineer on team #397 from Flint Southwestern Academy and Delphi Automotive - E&C.
In Reply to: EVEN MORE PBASIC HELP, ASAP!!
Posted by bill whitley on 2/14/2001 5:47 PM EST:
I just notice that you are in the Flint area. There are 6 teams in the area more than willing to help. I’m from team 397 (also in Flint). Email me or the team and we’ll provide any assitance with programming you may have.
[email protected]
Posted by Joe Ross at 2/14/2001 6:20 PM EST
Engineer on team #330, Beach Bot, from Hope Chapel Academy and NASA/JPL , J&F Machine, and Raytheon.
In Reply to: MORE PBASIC HELP, ASAP!!
Posted by bill whitley on 2/14/2001 5:43 PM EST:
: By default, does joystick 1 (y axis) control PWM 1?
: also, do joysticks 2-4 operate the same way? (y axis controls PWM?)
Yes, but it can easily be changed by changing the serout command if that doesn’t work for you.
Posted by Joe Ross at 2/14/2001 6:18 PM EST
Engineer on team #330, Beach Bot, from Hope Chapel Academy and NASA/JPL , J&F Machine, and Raytheon.
In Reply to: PBASIC HELP, ASAP!!
Posted by bill whitley on 2/14/2001 5:39 PM EST:
: Can anyone double check this code? Tell me if it will work.
: if p3_wheel > 240 then relay5_fwd = 1
: if p3_wheel 240 then JUMP2
: relay5_fwd = 0
: relay5_rev = 0
: JUMP2:
: if p4_wheel > 240 then relay6_fwd = 1
: if p4_wheel 240 then JUMP3
: relay6_fwd = 0
: relay6_rev = 0
: JUMP3:
: I am concerned about ending the IF THEN statements.
The code should tokenize, but it may not do what you want 
The if-then statements look ok, except that I’m not sure that you want to use an “and”. The way the code is written now, all the relays will always be set to 0 because p3_wheel and p4_wheel can never be less than 15 AND more than 240. It looks like you want an OR which says if p3_wheel is either less than 15 OR greater than 240, goto the code for p4_wheel.
The symbol for OR in PBASIC is “|”. If you replace the “&” with “|” you should be OK.
Posted by Ed Sparks at 2/14/2001 7:45 PM EST
Engineer on team #34, The Rockets, from Bob Jones High / New Century High and DaimlerChrysler.
In Reply to: PBASIC HELP, ASAP!!
Posted by bill whitley on 2/14/2001 5:39 PM EST:
Bill,
If you find that you are still in big trouble with the programming after repeated attempts, post some detailed information about:
-
How you wired the devices to the controller
i.e. Left Wheel -> PWM1
Right Wheel -> PWM2
Compressor -> relay1
Pressure Switch -> rc_sw1
etc.
-
How you expect the 'bot to act given a program
-
Pictures of the 'bot
-
Which Operator Interface devices you want to use
i.e. Joystick 1(X&Y) operates drive system
Joystick 2(Y) operates arm
Joystick 1 (Trigger) operates ball claw
etc.
-
Which events you plan to attend (so we can find you if any of us are at the same event).
I’m sure this community will make every effort to get you going because:
-
We want you to have FUN ! We DON’T want you to start developing ulsers this early in life.
-
We care that you make points (we want them too after all).
-
We aren’t challenged enough with just one robot to build 
Not to sound like a wise guy but it kind of sounds like you COULD use an Engineer about now …
I’ll be at the Houston, KSC, and National events.
Posted by Joe Johnson at 2/15/2001 9:11 AM EST
Engineer on team #47, Chief Delphi, from Pontiac Central High School and Delphi Automotive Systems.
In Reply to: Suggestion
Posted by Ed Sparks on 2/14/2001 7:45 PM EST:
Ed has some great advice about how to ask a question about PBASIC.
Let me build on that.
Basically, if you want us to help debug some code, you have to help us understand what the code is supposed to be doing.
SO…
Tell us what INPUTS you have
Tell us what OUTPUTS you want to change
Tell us what FUNCTIONS you are trying top accomplish
This information will make the life of the would-be helper a lot simpler and, more importantly, it will make the advice you get more likely to be helpful.
Good luck.
Joe J.