Log in

View Full Version : PBasic Question


Melissa H.
06-10-2002, 20:53
I'm new to programming PBasic...though I know a little of C and C++(very minimal though :( ) I was wondering, how can I start learning PBasic and/or find out more on this programming language?

Anything would be helpful!:D

rbayer
06-10-2002, 21:27
My advice would be to grab the default code from InnovationFIRST's website (http://www.innovationfirst.com) and go through it line-by-line until you understand it.

After that, I'd try playing around with my emulator (http://FIRSTprograms.tripod.com/Programs.htm) and see what comes out. If you ever run into problems, post them here and you'll get an answer in a few hours at the most.

Also, if you feel like a challenge, here is the code we used last year: http://FIRSTprograms.tripod.com/cog2002.txt

Ian W.
06-10-2002, 21:34
Originally posted by rbayer
My advice would be to grab the default code from InnovationFIRST's website (http://www.innovationfirst.com) and go through it line-by-line until you understand it.


what he said. that's what i did, and considering i had about 2 hours to learn it, i did pretty good.

Melissa H.
07-10-2002, 07:12
Thanks for the help!!! The http://www.innovationfirst.com was probably the most helpful (with the default program and all....:D )

Matt Reiland
07-10-2002, 15:30
Here is some Swerve code broken into processor slots if you get bored.

Hopefully your team can get the edu robot to try out or get your hands on a IFI controller. For right now the emulator is great also.

Thanks for the hard work rbayer!

PBasic is not that hard but living in the hardware limitations is more difficult.

f22flyboy
31-10-2002, 14:19
Originally posted by rbayer


Also, if you feel like a challenge, here is the code we used last year: http://FIRSTprograms.tripod.com/cog2002.txt

I get most of it, but I am confused by this line:


if ((gear_shifting=1) and (gear_count=10)) then shift


do you have to press the top button of your joystick 10 times to shift?

I'm still learning this code so if this is a stupid question feel free to flame me.

Matt Reiland
31-10-2002, 14:45
Originally posted by f22flyboy


I get most of it, but I am confused by this line:


if ((gear_shifting=1) and (gear_count=10)) then shift


do you have to press the top button of your joystick 10 times to shift?



My best guess for the code is you have to press the top button to shift gears which will stop both drive motors while the shift takes place, they increment a counter for a delay (gear_count) when it increments to 10 the shift takes place (relay lowGear toggles) when gear_count hits 40 it looks like the section gets skipped over

BUt I am not sure where gear_shifting ever gets reset back to zero after the first initialization.?

f22flyboy
31-10-2002, 14:55
Do you have any idea how long it would be? Does is there a preset time for counter-type variables, or does it depend on the rest of your program?

f22flyboy
31-10-2002, 15:00
startShift:
leftDrive=127
rightDrive=127
gear_shifting=1
gear_count=0




also what is this here for?

p1_sw_top_prev=p1_sw_top

I see that it sets p1_sw_top_prev=0 but why not just say that?

SlamminSammy
31-10-2002, 15:17
Originally posted by f22flyboy

p1_sw_top_prev=p1_sw_top

I see that it sets p1_sw_top_prev=0 but why not just say that?

The gear_count is a delay to prevent damage to the gearbox and I think the p1_sw_top_prev=p1_sw_top resets the input and as for not setting it equal to zero, the button may not have started in the zero (off) position.

Anyway, Rob will be back in an hour and explain everything.

Matt Reiland
31-10-2002, 15:20
Originally posted by f22flyboy
startShift:
leftDrive=127
rightDrive=127
gear_shifting=1
gear_count=0




also what is this here for?

p1_sw_top_prev=p1_sw_top

I see that it sets p1_sw_top_prev=0 but why not just say that?

As for time, it will depend on the program length and the number of processor 'slots' you are using. The longer the program scan, the slower the delay will be.

Gear Count =0 will set up a fresh delay since it increments to 40 and stops incrementing until the next time a gear shift is requested. Gear Count would be at 40 coming into that statement

p1_sw_top_prev=p1_sw_top
this type of statement is useful for storing the value of the switch on the previous scan and checking the current state against what you had before to see if a change has taken place, kind of a 1-shot since after the current scan they will both agree again

f22flyboy
31-10-2002, 15:27
Can someone on this team tell us about how long the delay is?

Matt Reiland
31-10-2002, 16:05
This is from the archives I assume it to be close

close enough for govt work...
Posted by control guy at 1/29/2001 10:29 AM EST


Student on team #250 from HVCC.


In Reply to: Re: PBASIC Loop Speed?
Posted by Lloyd Burns on 1/28/2001 4:38 AM EST:



The program loops are roughly 1/40 sec. Although, the time between loops can vary if you lose signal momentarily. Also, depending on your code, a program loop may take longer some times around than other times. Such as if you had many strings of if statements and you're having the program go here, then here, then here, etc., etc. Hope this helps.

rbayer
31-10-2002, 16:46
Ok, I'm back (sort of). Actually, I'm sitting in my CSci class right now, but I don't really feel like listening, so I'm responding here.

The p1_sw_top_prev=p1_sw_top does exactly what Matt said, it stores the state for the next loop. Since almost no one can press and release a button within 1/40th of a second, we need to make sure that it is actually a "new" button press and not just someones finger left on the switch from earlier. This lets us use the top switch as a toggle. I.e. each time you press it, the gear we are in changes.

As for the timing, it ends up being about 1.5-2 seconds from the time you press the button to the time you can drive again. That is for the full 40 loops. The 10 loop part takes approx. 1/4 as long.

If you can understand this type of time-delay, you have a very good grasp on PBASIC as this type of looping isn't overly intuitive.

Anyway, let me know if there are any other sections that are unclear or don't make sense.

--Rob

SlamminSammy
31-10-2002, 22:38
Originally posted by f22flyboy
Can someone on this team tell us about how long the delay is?

Just plug the code into RoboEmu and see for yourself!

f22flyboy
01-11-2002, 09:45
Ahh the sadness of the macintosh

:(

Melissa H.
12-11-2002, 15:00
Will there be a default program with the edubot? (If this makes any sense...):confused:

rbayer
12-11-2002, 15:10
yes, and its already posted if you want to take a look:

http://www.innovationfirst.com/FIRSTRobotics/documentation.htm

Matt Krass
12-11-2002, 18:30
Actually, I'm sitting in my CSci class right now, but I don't really feel like listening, so I'm responding here.

Uh, this may seem dumb, but remember I'm a ninth grader :D So, how did you log in from a class?

Melissa H.
12-11-2002, 18:46
I'm assuming CSci = Computer Science. . .

Melissa H.
12-11-2002, 18:55
Sorry about my prior statement being a little random...but maybe that's how you can log in from class...Computer Science class...possibly? ( I was wondering the same thing...)

rbayer
12-11-2002, 21:07
My laptop has a .11b card and the U of MN has a wireless network. Given that I'm sitting smack dab in the middle of 2.5 hour lecture right now, my wireless card saves my sanity.

Also, some of my classes are actually in computer labs, so sometimes I just use the computer sitting in front of me.

(In case you're even more confused now, I am still a high-school senior, I just take most of my classes at the U)

Melissa H.
13-11-2002, 16:38
How many classes is "most of my classes"?!? (Sorry if this is way off topic...):)

rbayer
14-11-2002, 00:11
3 of the 4.

I take spanish at my high school, and physics, computer science, and Modern Fiction at the U.

Next semester it will be all 4: math, physics, computer science, another computer science.

Melissa H.
14-11-2002, 17:26
(Sorry again...off topic) Two Computer Science classes?:confused:

rbayer
14-11-2002, 18:58
Yes.

1. "Discrete Structures of Computer Science"--its actually more math than CSci, but it's still considered a CSci class.
2. "Machine Architecture and Organization"--basically assembly and OS design.

Other than that:
3. Calc IV
4. Calc-based physics II--electricity and magnetism

f22flyboy
15-11-2002, 09:58
How is your school system set up?

We are required to take core courses (English, Government, Math, Science) our senior year.

rbayer
15-11-2002, 10:33
We just have requirements that we have to do at some point during grades 9-12. I managed to finish everything by halfway though my Junior year, so I basically get to do whatever I want.

Melissa H.
17-11-2002, 18:53
Originally posted by rbayer
We just have requirements that we have to do at some point during grades 9-12. I managed to finish everything by halfway though my Junior year, so I basically get to do whatever I want.

Our school's set up like that too...only we have too many requirements to get through before we can even consider taking the classes we want...<sigh> There goes computer programming, CAD, and computer science...not to mention computer applications.... for this year...and next year...and possibly even the year after.:(