Electric Vehicle C

User avatar
sachleen
Exalted Member
Exalted Member
Posts: 215
Joined: April 10th, 2007, 8:31 pm
Division: Grad
State: CA
Has thanked: 0
Been thanked: 0
Contact:

Re: Electric Vehicle C

Post by sachleen » March 27th, 2009, 9:09 pm

Paradox21 wrote:
tehkubix wrote:
Paradox21 wrote:I am using a Lego NXT and my vehicle is built out of legos. My biggest problem is that the vehicle curves. I am using solid axles and all my wheels are the same size. I am not entirely sure what is causing it to curve. Has anyone else had this problem with legos? Can anyone tell me how to fix it?
aiming it straight at 10m, how many cm is it off left/right? If its only a few, you need to just launch in a manner where it curves back so it stops while its on the center line.

Anyway, my comp is tomorrow, not much time left, a lot of work to do...
If I line it up ideally then over a 10 meter course it goes about 5cm to the right of the line and ends 5cm left of the line. It is really bad.
It does both? one run it goes to the right, one run to the left? How are you aligning it before starting it? If you just have a basic home-made sight like I do (two pieces of plastic with holes in them, look through them and line up with a target) you can shoot a laser through it and see if that lines up properly. What I did last year was take a ring stand and a clamp and clamp the laser at the right height to it. That way, the laser was ALWAYS pointing the same direction and I would move my car around until I saw the dot of the laser go through both holes and hit the center line of my target. If you can do that, you can make a better observation of which way its going off and by how much.

gh
Admin Emeritus
Admin Emeritus
Posts: 323
Joined: October 22nd, 2003, 5:47 pm
Division: Grad
State: NY
Location: CA
Has thanked: 0
Been thanked: 0
Contact:

Re: Electric Vehicle C

Post by gh » March 27th, 2009, 9:47 pm

Obviously, the laser thing is for practice, since it's illegal without a doubt under the current rules. I also used a laser while testing, but it was to see how much my EV curved when it ran down the track.

You can learn microcontroller programming and electronics the way I did, but that would also involve a number of years of stumbling trial and error plus wasted parts and time.

If you just have zero knowledge of anything related to this, I wonder recommend you start with a BASIC Stamp 2 from Parallax. Their What's a Microcontroller set and BOE-bot kit both use that microcontroller, but are rather expensive. I actually started with a Toddler walking robot (no longer sold) from Parallax and then recouped the cost of it by winning a coding contest of theirs, but again, that's not exactly the best way to go about learning.

Despite the cost, the thing that's really attractive about the BS2 is the brain dead programming interface it uses, as well as the fantastically simple documentation/text it includes (you can download the manual/tutorial/book they include to see how it's like). This program will blink toggle the voltage on a pin on and off at one second intervals:

Code: Select all

blink:
    HIGH 7
    PAUSE 1000
    LOW 7
    PAUSE 1000
GOTO blink
*The HIGH and LOW instructions will just set the voltage at the pin numbered by the number that the instruction is followed by. The PAUSE instruction just pauses execution for a certain number of milliseconds.

The gist of it is that you have a LED or something hooked up to the seventh I/O pin on the BS2 chip. You flash this program on the chip using the software and stuff they give you when you buy the kit, power it on, and it'll just execute that line by line, and you can follow the flow of the program by eye. You'd be able to get the LED to blink every two seconds this way.

The BS2 has a pretty powerful set of instructions (like the HIGH, LOW, PAUSE, etc. lines above) and you can go pretty far with it, including reading from a number of sensors with a variety of interfaces and can control motors, servos, etc. It's also limited in a lot of ways, like the number of I/O pins, speed, and transparency, but you don't really need any of that when starting out.
“Rather fail with honor than succeed by fraud.” —Sophocles
If you are looking to give help or get help:
[wiki][/wiki] > Forum post > > PM > Email
Don't forget the Image Gallery, the , and the list of Exalted User medals.

gh
Admin Emeritus
Admin Emeritus
Posts: 323
Joined: October 22nd, 2003, 5:47 pm
Division: Grad
State: NY
Location: CA
Has thanked: 0
Been thanked: 0
Contact:

Re: Electric Vehicle C

Post by gh » March 27th, 2009, 10:56 pm

Anyways, after I cut my teeth on the BS2, I realized that while it was great to learn on, there are a lot of technical deficiencies with it. For one thing, the BASIC programming language it uses is quick to learn, but isn't very advanced in terms of the sort of code structure you can have. The BS2 is also pretty limited in memory size and speed.

Most of these deficiencies aren't caused by the BS2 itself. It's because the BS2 is not a chip unto itself, but a platform based on a microcontroller called a PIC from Microchip, Inc. and software written by Parallax. The software essentially hides a lot of the nasty details of microcontroller programming inside a learner-friendly set of tools and a BASIC programming language interface. Hiding all the nasty bits also means hiding a lot of the functionality as well as making the BS2 exorbitantly expensive.

The next logical step for me was to go lower level, and work directly with the PIC microcontroller from Microchip. These are dirt cheap (free as samples if you ask Microchip nicely, or still just dollars each), and contains more functionality than you know what to do with. I mean, going straight to the hardware meant that it was several thousand times faster (!!!), you had way more space and memory to your own programs, and you could write your programs in whatever language you liked (though it was usually C, BASIC, or assembly). However, it also meant that you had to write a lot of the software yourself, you needed a PIC chip programmer (to download programs to your PICs), and there wasn't exactly a manual like Parallax had to walk you through everything. Also, knowing C (I learned it when I was a freshman) was pretty important, I think.

I started with a PIC 16F88 (free sample), which was a much fancier and more powerful version of the PIC the BS2 is based off of, before switching to the 18F2550 (free), which was a huge step up in both complexity and performance, and finally to the PIC 24HJ128GP502 (...free.) chip, which is in a whole other ballpark, and is what I used for my EV. I used a PICKit 2 programmer ($35) to load programs from my computer to the chips as well as to debug them.

The 24HJ128GP502 has way more horsepower than anyone would need for EV, but it was basically just very nice to use when you've had the experience to deal with a beast like it. For example, it allows me to set up timer interrupts to execute pieces of code at regular intervals (very useful for the speed controlling portion of it), and handles controlling the servo I used to propel my EV just by loading some numbers into some registers. I also use a really high resolution rotary encoder (a type of sensor that senses angular motion), which generates a huge number of ticks per revolution. The 24HJ128GP502 happens to have an interrupt that lets me run some code whenever a tick is output by the encoder, without ever missing any of the 1000 generated per revolution of the wheels.

Basically, using a high performance microcontroller like a PIC24H really simplified the code I had to write with advanced features like a ton of interrupts, reconfigurable pins, hardware peripherals, etc. At the same time, it really complicated my life because I had to spend two years learning what the heck they were out of 400-page long datasheets. I started with te 24H this SO season, but it sucked because I found exactly one tutorial on the web, which I had to correct as I went through it (yeah... dunno why I was doing this on Christmas >.>), and one book, which was pretty legit.

Anyways, moving away from that rant. A high school student who's taking some comp sci in school and has a competent mentor should be able to become reasonably proficient in microcontrollers by starting straight off with either of the following set of tools:
a) PIC 18F2550 microcontroller/PICKit 3 programmer/MPLAB IDE/Microchip C18 C compiler
b) AVR ATmega168 microcontroller/USBtinyISP programmer/IDE of choice/AVR GCC compiler and toolchain
Obviously, I can't really say what manuals, tutorials, development board or whatever people should be using because those probably vary from person to person, and because I haven't exactly been looking for those. All I can say is that Google can help you... a lot.

If you're less hardcore (don't know how to program or can't jump straight into registers, UARTs, config fuses and all that), you might want to stick to the Arduino or BS2 platforms, which are designed for the beginner.

Don't use Vex. It's retarded; you'll pay through the nose for it; you won't get anything out of it afterwards; and you'll still be stuck with Vex instead of getting somewhere more advanced with it.
Also, if you think the cRIO used by US FIRST this year is decent for anything, then I can arrange for us to have a personal cage fight. We can do this bare knuckles... or with knives. Your pick.
“Rather fail with honor than succeed by fraud.” —Sophocles
If you are looking to give help or get help:
[wiki][/wiki] > Forum post > > PM > Email
Don't forget the Image Gallery, the , and the list of Exalted User medals.

Paradox21
Staff Emeritus
Staff Emeritus
Posts: 395
Joined: January 11th, 2009, 7:10 am
Division: Grad
Has thanked: 0
Been thanked: 0

Re: Electric Vehicle C

Post by Paradox21 » March 28th, 2009, 7:06 am

tehkubix wrote:
Paradox21 wrote:
tehkubix wrote: Anyway, my comp is tomorrow, not much time left, a lot of work to do...
If I line it up ideally then over a 10 meter course it goes about 5cm to the right of the line and ends 5cm left of the line. It is really bad.
It does both? one run it goes to the right, one run to the left? How are you aligning it before starting it? If you just have a basic home-made sight like I do (two pieces of plastic with holes in them, look through them and line up with a target) you can shoot a laser through it and see if that lines up properly. What I did last year was take a ring stand and a clamp and clamp the laser at the right height to it. That way, the laser was ALWAYS pointing the same direction and I would move my car around until I saw the dot of the laser go through both holes and hit the center line of my target. If you can do that, you can make a better observation of which way its going off and by how much.
I am using a hunting scope to line up the vehicle and it consistently arcs wide to the right before returning to the line and arcing off to the left. This has been happening for a few months.

Flavorflav
Member
Member
Posts: 1376
Joined: February 5th, 2006, 7:06 am
Division: Grad
State: NY
Has thanked: 0
Been thanked: 1 time

Re: Electric Vehicle C

Post by Flavorflav » March 28th, 2009, 7:47 am

It sounds like it simply steers left and you have been compensating by aiming right. You would be much better off moving your aim point until it no longer goes to the right of the line at all and making it go straight by adjusting the alignment of your axles. You want to increase the distance between the two left wheels, or decrease that between the two right wheels.

Paradox21
Staff Emeritus
Staff Emeritus
Posts: 395
Joined: January 11th, 2009, 7:10 am
Division: Grad
Has thanked: 0
Been thanked: 0

Re: Electric Vehicle C

Post by Paradox21 » March 28th, 2009, 7:55 am

Flavorflav wrote:It sounds like it simply steers left and you have been compensating by aiming right. You would be much better off moving your aim point until it no longer goes to the right of the line at all and making it go straight by adjusting the alignment of your axles. You want to increase the distance between the two left wheels, or decrease that between the two right wheels.
But how would I do that with legos? Maybe make a custom lego piece with 1 hole slightly closer in or out to put the axle through? It might take alot of trial and error to get it right.

gh
Admin Emeritus
Admin Emeritus
Posts: 323
Joined: October 22nd, 2003, 5:47 pm
Division: Grad
State: NY
Location: CA
Has thanked: 0
Been thanked: 0
Contact:

Re: Electric Vehicle C

Post by gh » March 28th, 2009, 8:09 am

You probably have the scope's aim point too far to the left, so the vehicle is pointing a bit to the right when you aim straight ahead. Then it probably starts curving to the left.
“Rather fail with honor than succeed by fraud.” —Sophocles
If you are looking to give help or get help:
[wiki][/wiki] > Forum post > > PM > Email
Don't forget the Image Gallery, the , and the list of Exalted User medals.

Flavorflav
Member
Member
Posts: 1376
Joined: February 5th, 2006, 7:06 am
Division: Grad
State: NY
Has thanked: 0
Been thanked: 1 time

Re: Electric Vehicle C

Post by Flavorflav » March 28th, 2009, 8:39 am

Paradox21 wrote:
Flavorflav wrote:It sounds like it simply steers left and you have been compensating by aiming right. You would be much better off moving your aim point until it no longer goes to the right of the line at all and making it go straight by adjusting the alignment of your axles. You want to increase the distance between the two left wheels, or decrease that between the two right wheels.
But how would I do that with legos? Maybe make a custom lego piece with 1 hole slightly closer in or out to put the axle through? It might take alot of trial and error to get it right.
I have never worked with lego robotics, so I don't know how hard this would be to do, but you have to introduce some non-lego components. It would probably be easiest to use a non-lego axle mount for one axle and build in an adjustment to it.

Paradox21
Staff Emeritus
Staff Emeritus
Posts: 395
Joined: January 11th, 2009, 7:10 am
Division: Grad
Has thanked: 0
Been thanked: 0

Re: Electric Vehicle C

Post by Paradox21 » March 28th, 2009, 4:15 pm

gh wrote:You probably have the scope's aim point too far to the left, so the vehicle is pointing a bit to the right when you aim straight ahead. Then it probably starts curving to the left.
That is exactly right. The scope is easy to fix but the curving is really difficult.

User avatar
sachleen
Exalted Member
Exalted Member
Posts: 215
Joined: April 10th, 2007, 8:31 pm
Division: Grad
State: CA
Has thanked: 0
Been thanked: 0
Contact:

Re: Electric Vehicle C

Post by sachleen » March 28th, 2009, 6:16 pm

So I had my regional comp today. I don't know the exact scores but my time was 0.2s off and my car was 1.9cm (FAIL!!!) away from the center of the target. The laptop I use to program it was running the trial version of RobotC and for some reason the system date changed making it expire. Good thing I had been practicing that exact distance before and it was already set to it so I just had to go in, tell them the time and launch. Because of a useless laptop, I couldn't adjust the distance at all so that hurt me quite a bit since it was about .5cm (maybe less) away from the actual finish line. Second place and I were really really really close. I mean, my time was only .2 seconds off and had I been able to correct the distance score I could have beat them. Also, seeing that your tool just fails 10m before you have to go messes you up mentally. That's on top of the bridge failure we almost had that ruined my day.

/rant

Post Reply

Return to “2009 Build Events”

Who is online

Users browsing this forum: No registered users and 1 guest