Tuesday, April 27, 2010

Results / Updates / Victory!

Hello to all of my zero readers!

Yesterday (4-26) was the last day of classes.

The arduino-car was 'finished' and field tested for judging on Saturday (4-24).

The car successfully navigated to a point, and way-point functionality was also successfully tested/video'd.

Based on three electrical engineering/computer science faculty and one IEEE member: I won first place prize for the competition on my campus.


Anyway - since it is the end of semester I have not had a chance to update the blog. I worked through testing / etc. last week for this project then had: 2 papers / 1 project / 1 assignment due yesterday.

Now that classes are over and my schedule is more relaxed, I plan to make more updates of my past progress (videos and pictures were taken!) and then wrap-up the project.

I may even add a few more features through the next week or two depending on free-time.

tl;dr 1st place / more updates to come

Wednesday, April 21, 2010

Field Testing!

I know there are not any readers, but I hope someone reads this eventually :)

Anyway - today I was outside doing some field-testing.

I know I am really behind with photos, etc. They will be added! I have taken more photos and even some preliminary video.

Today I have learned more than I can imagine about the routing algorithm, and the car as a platform.

I have ran into many problems, come up with many solutions, and am still working.

The current problem is over-steering, and over correction. When the car turns too sharply, and GPS is polled a second later - it appears that the car was traveling no where towards the objective.

Since my algorithm is based on the current, previous, and final point - this is a huge problem.

It might make sense to let the algorithm be aware of previous steering, etc.

My current fix for this over-steer issue (which actually makes the car drive in circles..) is to just steer for a moment during "steer cycles" then hold straight.

So instead of turning right for one entire polling cycle (~1 second), I have it turn right for 200ms then go straight for 400ms, then poll again.

This way I adjust the projection of the 'ray'/ path slightly (hopefully by a few degrees).

We will see once I get back out there!

As a teaser, here is a video I made last night in my kitchen - it's just running code to cycle forward/backward/right/left.


Tuesday, April 20, 2010

Updates!

Today I cut a hole for the servo, and have begun assembling the 'platform'.

I tested the servo steering, and found the range for steering:
130 degrees to turn hard right
110 degrees for straight
90 degrees for hard left

Additionally I tested the motor controller on the car, with the car's battery supply - everything works so far!

I plan to pack everything up, and have the arduino accessible for programming.
Photos will be added to this post shortly.

Monday, April 19, 2010

9 * 1 = 57

Working on the algorithm, and getting the gps in a usable format.

Currently the arduino is saying:
9 * 1 = 57.

I am guessing that there is some strange type issues occurring, but can't be sure yet.

Be in touch!
(Oh also, I took some 'field data' aka ran around campus to find a smooth walkway to test.. photos to come, and maybe video in a day or two.)


Update:
When I converted the data from the serial stream of the GPS to an int - 48 was being added.
so when gps_value = 3:
int(gps_value) = 51

I know 48 is 110000 in binary - so the value isn't a 'surprise'.. im just not sure where it is coming from. Because it reads out to the serial-out of the arduino as gps_value = 3.

Oh well.. ONWARDS!
Coordinates now usable within a routing algorithm!



NEW UPDATE:
I didn't think of the ascii representation of the integers when they exist as a char.
For reference:
http://arduino.cc/en/Reference/ASCIIchart

This all makes 1000x more sense now -> for some reason I assumed that the data type was an int by default not a char :(
(I need to be getting more sleep this last week of classes doh!)

Sunday, April 18, 2010

Problems!

Ran into my first real speed bumps of the project...

For some reason the serial out data of the GPS unit was:
þ‹“µ¤S°»¬4‹“µ S°ƒ¬°±² S¬m»¤µ± ›¤°°°¬¤°°“¬ä “«#¬O¬m»¤“· ›¤ƒ²ý ‹“«¤S°£¬d‹“«¤S°Ë¬ä‹“«¤S°°lý°±²µ¤S°ƒ¬d‹“«#¬M¬m»¤“· ›¤°°´¬ä‹“«¤S°‹¬¤°±²m S°‹¬¤°±²µ S¬¬¶ c¬m#¬m»#ƒƒ›c4‹“«¤S°“¬¤°±²m S°£¬ ‹“«¤S


I had a clear view of the sky sitting outside in my back yard - normally I can get a fine signal near the window in my apartment. Status lights on the GPS module looked fine. I had a moment of panic thinking about how to fix this solution - perhaps the GPS module died, and I would have to have one shipped over-night. Or maybe it was a cable / arduino / connection issue. (Only one USB port of two on my Macbook Pro currently works...)

With 20 minutes wasted through troubleshooting - I decided to disconnect everything.
Soon after rewiring the GPS module to the Arduino I started seeing reasonable data coming off the serial port:


---------------
Time in UTC (HhMmSs): 212800.000
Status (A=OK,V=KO): A
Latitude: :)
Direction (N/S): N
Longitude: :)
Direction (E/W): W
Velocity in knots: 0.24
Heading in degrees: :)
Date UTC (DdMmAa): 180410
Magnetic degrees:
(E/W):



And then finally reloaded my own code to see:
---------------
Latitude: 1234.1234
Longitude: 01234.1234
---------------

Back in business - now time to further parse this data to an even more friendly format.

Note: Lat / Long have been modified for this posting :)

Friday, April 16, 2010

More Progress!

I was able to accomplish a number of tasks in the lab last night.
Here are some photos and descriptions:
The lab-setup from afar. Was measuring a few values before removing the out-of-box RC-Car controller.


-The H-Bridge is fully assembled, and tested with true 5v logic values, and an actual DC motor.



-All parts not necessary have been stripped from the RC Car

In the above photo, you can see parts from the front steering mechanism. The gear box, plastic arms, dc-motor. Additionally to the left, you can see the transmitter and receiver (which I might consider using as a wireless kill-switch -- but likely won't due to time constraints.)

-The servo for controlling steering has been retrofitted

-Full mock-up of the entire system has been completed

Below are photos of all parts on the physical platform (rc-car) and below the parts are laid out for show. The second photo shows all parts required to drive/steer the rc-car. GPS module, servo, motor, motor driver, micro-controller.





Todo:
1) Get basic routing algorithm working
--Grab latitude / longitude and perform logic
2) Assemble all physical components on the RC-Car body
3) Field Testing!

Thursday, April 15, 2010

In Lab Work

This post is just a teaser - currently in lab.. just did a simple mock-up of the motor-to servo modification.




There is a lot of 'hardware' (plastics / springs) to use the motor for steering. I am fairly sure this can be removed, since the servo will hold it's position fairly easily.

The only problem is form factor -- the servo housing is MUCH larger than the motor.



Maybe I'll make enough progress to make another post later / tomorrow :)

The Algorithm - 9 days left

I just realized I only have nine days to finish this project. *gulp*

Have to give some statement of the project next Tuesday -- so I should know if it's possible to finish by then.
(I am also working on this project for an IEEE sponsored competition on campus.. more details later. Flying under the radar in case of failiure :) )

Anyway - I drafted up my navigation algorithm at a high-level today on paper.

I did not consult any external resources to figure out this problem. I wanted to independently come up with a solution to this problem - and see if it might work. Future revisions might use commonly known algorithms - but for now maybe my thoughts will work.

At the highest level here is my algorithm for routing:

Given latitude / longitude as x, y:

You need two initial points:
Start: x1, y1
Finish: Xf, Yf

Based on the start - you move some distance, and sample the position.
This third location will be Xc, Yc (c is for current).

Based on x1, y1 and Xf, Yf, you can obtain the exact latitude and longitude of travel required.
The latitude X and longitude Y must be traveled to get from x1, y1 to Xf, Yf.

X, Y will always be the distance from your current position, to the final position Xf, Yf.

So the high level algorithm:

Starting at x1, y1 calculate the latitude (X) and longitude (Y) to the destination Xf, Yf.
Storing X, Y -> move some distance and acquire a new Xc, Yc.
Based on the new distances to destination X, Y -> calculate how much closer you are to the target.

You should move proportional to the initial X, Y ratio. If your unit of movement is greater than or less than the initially calculated ratio, you will need to steer to correct. (If you traveled too far in latitude, you want to travel less the next move -> so you will turn in the direction of longitude, etc.)

I am sure this is confusing to understand - it's hard to dump the thought. Once I have some code, I will post it.

In summary - based on the proportion of lat/lng traveled and the proportion from a previously known location to the target -> you can keep the car on course.

This will certainly lead to over corrections -> however steering can be based on the magnitude in difference of proportion. Hopefully I can retrofit the servo to control steering so that there are varying levels of left/right not just ON/OFF LEFT/RIGHT as it is out of the box.

Alright - that's all for now.. maybe I can take a photo of my notepad later!

Edit: Photo of notes added! I wrote this sitting outside in the nice weather today -- the bottom curvy line over the straight line is behavior I expect (in the best-case).

Monday, April 12, 2010

What has already been done

For this project, I plan to create a number of discrete components. At the highest level, they include:
-Interface with GPS
-Interface with a Motor
-Interface with Servo
-Controller for the system

These are all fairly straightforward to build considering many others have interfaced with this hardware set before. This project will really be a task of merging them together, while trying to keep costs low.

Before this blog, I did some initial preparation. This included testing my GPS module with the arduino, and building a basic h-bridge.

This is a photo showing the the GPS module, tied into a breadboard. Also visible is the IC that behaves as an H Bridge. I am using a L293DNE Quad Half-H Driver 16 dip IC. This part can drive my motor at up to 0.6A of current. Ideally I would have a 1A or 2A unit, but I am trying to use existing parts. This might be an issue down the road :)

Shown here is a photograph of the constructed H-Bridge. I could drive two motors off this IC, but will only require one.




And Finally everything tied together (with nice jumper wires! purchased because they make everything look so nice). This is 90% of the final hardware - the only parts missing are a servo, and motor.





Finally - this is a testing environment for in my apartment. I have the arduino with GPS unit and bread board in the window to pick up a good signal.


The Idea

I want to create a GPS Way-point driven remote controlled car.

Not too long ago I woke up one morning and thought of attempting this project. I knew that it was possible to interface an Arduino micro-controller with readily available GPS modules. I also knew that it would certainly be possible to interface the Arduino with an RC car.

The plan would be to use a basic feedback loop to control the direction of the car. At it's heart the logic of the microcontroller would be:
1) Where am I?
2) Where was I 1-2 second ago?
3) Where do I want to go?
4) According to where I am, and where I was - how does my course need to be adjusted?
5) Adjust steering, move forward, jump to step 1.

This is fairly simple logic, and I think it should be possible. There are a list of unknowns that could ruin this project:
-Accuracy of the GPS unit: some are accurate to 5m or ~16 feet! That's likely going to send the car into some curbs.
-The RC-Car platform: not wanting to spend much money means a cheap RC Car! This means steering will likely be terrible, no suspension, small wheels, minimal clearance, etc. etc.
-Others I haven't encountered yet.

So basically, I am going to try and tackle this project in just under two weeks.

As of today - I have a list of parts ordered, and have begun some initial work. I tore apart the RC Car, and begun planning other components of the project.

Posts to come will include:
-Parts list / detailed plan-of-attack
-Construction of an H-Bridge to control the RC Car's drive.
-Retrofitting of a servo to control the steering (rather than a primitive DC motor configuration)
-Interfacing of GPS unit
-Writing a drive algorithm

Finally - it might be worth mentioning that this is my first blog. Additionally I am a Computer Engineering student, so please be friendly regarding grammar, etc.

Here are some photos of the car / arduino. Hopefully I get better at including in-line images in future posts!