Saturday, October 13, 2007

Lots of discoveries tonight!

Man what a day. I worked with the students today on getting the TIMER basics down, configuring their development platforms (WinAVR, AVR Studio, JTAG ICE), and learning how useful Excel is for calculating TIMER registers.

During all the back and forth, I had an epiphany. I was using code that limited my PID adjustment to +-100 (as in percent). I was using 10-bit PWM, but by limiting myself to (let's just look at forward speed) 100 possible values (out of 1024 (2^10)). Well that's still not totally true either. I'm using locked anti-phase PWM so only values above 512 generate forward motion. But I digress, I'm still only using 1/5 of the total values I could. So I modified my code and changed the limits to +-511. It works, and a lot better. Still need to tune the PID constants, but things are a lot smoother.

On a bad/disappointing note I ran my Lipo to 12.8V. Minimum is 12V (3V per cell) but I decided to check (for the first time since I had it) the individual cell voltages. Bad news:
  • cell 1 - 2.9V
  • cell 2 - 3.49V
  • cell 3 -3.02V
  • cell 4 - 3.34V
Wow, not good. My charger wouldn't even attempt to charge cell 1. Lipo charges are constant current, constant voltage chargers. I have a pretty sophisticated NiMh/NiCD/Pb charger. I set it for 2 NiMH and the charge current to .1A. I connected my DMM and monitored the voltage until it was 3.2V. Now the Lipo charger is charger that cell first. Only 3 more to go. Oh well, better than having to replace the pack.I'm not drawing huge currents or this could have been a lot worse.

From now on, I'm going to check balance every time.

Jay

Thursday, October 11, 2007

Video

As promised. A short video of my bot in action. The video starts with me showing the pattern function. I told it to drive a pattern with 5 vertices and sides that are 20" long. At this point I fix the speed at a mild rate. After the pattern completes I instruct it to drive 24" at full speed. You can really see the left steer. Then I instruct the bot to turn 360 degrees full speed.


Jay
Progress!

Last night I was able to connect to my robot, send commands, and receive output. This is huge (to me at least). Next step is to modify the receive code to parse out the data into arrays. Then to plot them. To do this, I will create a JPanel class that I can override the paintComponent function to do my bidding.

This weekend is a bachelor weekend so I hope to have it mapping by Sunday. At which time I'll do a video ... finally.



Onward,
Jay

Tuesday, October 09, 2007

More analysis

I wanted to see how accurate my bot is at this time. I took the output from the PID tests I did (see the graph below) and added odometry calculations and plotted the X and Y coordinates based on the data.



As you can see for 36" of travel my bot is off about .04". What else does this show ... that my left wheel leads the right wheel. Most interesting to me is that the the worse occasions of this steer is during velocity ramps. I may need to rethink my PID loop or add another component that can correct for this "steer". Then again, with an 8" diameter bot 40 thousandths of an inch doesn't seem that much ;)

I'm still working on my Java interface. I have made some progress (like getting the serial ports to enumerate and populate a JComboBox, redesigned the GUI layout) but I still need to get the serial listener portion to connect and communicate. I haven't had a big enough block of time to sit down and get my head around it though.

Onward,
Jay

Saturday, October 06, 2007

Version 1

Here is my plan for version 1 of my GUI.
My plan is this. I will have a thread that does nothing but parse the incoming serial stream into a multidimensional array. The array components will consist of:
  • time (this will be the value of the free-running timer from the AVR)
  • left commanded velocity
  • right commanded
  • left measured velocity
  • right measured velocity
  • left distance (though I may omit these and let the GUI calculate these two)
  • right distance
  • sonar reading
  • left PWM value (right now I'm set for 10-bit PWM, this might help me determine if I can use less resolution)
  • right PWM value
  • left PID proportional value (the I is silent :) )
  • right PID proportional value
  • left PID derivative value
  • right PID derivative value
I'll need to format the string in the most efficient manner so I'm thinking HEX

Stay tuned...

Friday, October 05, 2007

I need a GUI

Well, I want one for sure. I am tired of the 5 step process I'm using to capture my robot's output and plot it in Excel. Therefore, I'm starting work on a Java application that will plot the PID output, map the path the robot has taken, and allow interactivity with the robot.

A buddy said I should try Netbeans (it's been a while since I did any Java coding but GUI layout was a PITA). With Netbeans I am able to design my GUI and then plug in my processing code. The GUI design is slick. Netbeans also have a nice UI for keeping my code straight and has it's own CVS. Screen shots to come soon.

Jay

Thursday, October 04, 2007

I doubled my encoder resolution.

I modified my interrupt code to switch interrupt levels. On the Mega128 external interrupts 0-3 don't have the option of setting the interrupt level to both. Both meaning low to hi and hi to low edges. You get either or. So in my encoder code, I added a state variable to tell which was the last state. I'm only interrupting on the A channel but now I get double the interrupts by detecting both edges.

The good news it my resolution has improved to .0047" per tick. The bad news it, I have to re-tune my PID loop :(

Last night I decided to modify my motor control code to take in account how fast the bot is traveling, and how far it has left to go. The results are good and it has smoothed the ramping I had coded earlier. In fact, in hindsight, the previous code was too restrictive ... now the control is more adaptive. I know I keep promising a video, but there's always something I want to fix before showing it off. I'll do it tonight first thing before I enter another 3 hour coding stint.

As for the PID, have a look at last night's capture.

The thick red is the left encoder measurement, the dashed pink is the right encoder. The yellow (click the image to see a bigger version) is the commanded left velocity. As you can see, I have a lot of oscillation now as well as an overdamped response. I need to go back and refresh my memory on PID tuning and what do I need to do to clean this up. One more thing, the instruction was to drive the robot forward 36". It took about 4.8 seconds.

Jay

Tuesday, October 02, 2007

Some long overdue updates

Here is a screen shot of the Excel ploy of my PID output. Using my pattern code I told the bot the pattern had 12 verticies that were 5" long.

I'll post a video of it in action tonight.

Jay
I'm back!

I've completed the CNC conversion of my mill and have it sitting on my work bench. This means:
  1. I can work on CNC in A/C comfort versus the garage
  2. I have to be very mindful of "dust" on whatever I mill so I have only played with engraving wood
  3. I need to make an enclosure so I can keep it in the house
I am working with a new group of students from the university. They are motivated, bt they are also 17 and 18hours this semester ... we'll see how it goes but I am positive that they will have a mobile platform by December.

As for me, I need/want to improve my robot speed/positioning. My encoders are 1000PPR, If I can double, triple, or sextuple that I can increase my accuracy. I'm looking at replacing my motors and encoders with some new ones. The encoder will be mounted on the motor and I calculate 6000PPR with them. As a bonus they have a higher output RPM. The con is that they are 7.2V motors and my Lipo is 14V. I can control the peak voltage via PWM so it's not that big a concern. The other con is cost. We are talking $94.

I need to post a video of what my robot looks like now. It's been a while, but I wrote a program the takes input variables for side length and number of verticies. It then commands the robot to draw that shape based on the calculated angles and distances. It works ok, but one motor always lags the other. My peak speed is 20 ticks for the PID time period I chose (20ms IIRC). This means I can command the robot to go 0 to 20 ticks. This is too small of a range. With the new motors, the range would be 0 to 120.

Onward,
Jay