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

Friday, September 21, 2007

Friday, March 16, 2007

Update March 16 2007:

Just wanted to post a graph of my measured velocities ... or put another way, how well my PD loop is controlling my motors. The motors have been commanded to go 14. 14 = 14 ticks per 20 ms. I have 1000ppr encoders on 3" wheels so that's .1357"/20ms at that speed. Expanding that the bot is traveling 6.7 inches per second or 407.12 inches per minute or 33.9 feet per minute or just for grins .382 miles per hour :D

Anyway, notice the error is only +-1 tick. I may play with adding in an integral component. The graph shows the output of the bot being commanded to drive in a 10" square. The first step drives both motors forward, then stop (it even reverse the motors to effect a quicker stop) then left reverse, right forward to turn to the left 90 degrees, the forward ...

One other neat side affect is that the motors resist any change from the commanded speed. Put another way, if the robot is told to stop (left and right = 0) then if you try to push it, it will resist (actively turn on the motors in the reverse direction. Cool, but is a big battery drain as the current will shoot to 1.2 amps.

Finally, at this PD rate (50Hz) the fastest encoder speed is 18ticks/20 ms which equals 8.7 in/s or 43.6 ft/min or .49 mph :)


Onward,

Jay

Tuesday, March 13, 2007

Update March 13, 2007:

The BlueSMiRF is paying huge dividends in my ability to code and test. My PID function is working great and I have set it for 50Hz. I have expanded my interactive menu to allow me to command distances and angles to the bot. Last night I finally added a separate switch for the motors, and mounted the motor controller circuit. I’ve been using a 3S Lithium Polymer battery for my power source, and am thinking of getting a 4S to see how fast I can go.

My next task will be to add the SoundGin circuit and play with announcing the current command or some phrase. Then I want to add odometry calculations and command waypoints. Then add in the sonar and some prox sensors. I’m still having fun with the blue tooth though.

On the CNC front, I lucked out (or maybe not, time will tell) in winning a CNC kit for my mill off Ebay. I’ve ordered the last missing components from McMaster Carr (great prices and fair shipping) and plan to install it this weekend. In the mean time, I need to disassemble the ball nuts to make sure they are not missing any and to clean them. It’s be a waste of time to install it all only to have to take it apart due to an issue regarding the ball nuts … at least that’s the way I see it.

Onward,
Jay

Monday, February 26, 2007

Update 2/26/2007:

It's been a long time since I last posted. I have only one excuse CNC :) It's consumed me and my attention for 3 months now. What do I have to show for it? A mini mill, a wish list, a parts list, and an AWAOL machinist that was going to help me get there.

On the robotic front I got inspired to help the local college team again and thus worked on some A2D stuff for line sensors. I also spent 5 hours with them troubleshooting their LCD, braiding wires, and answering questions. The results: they were able to follow a line fairly well before the night was over. But, the system was a bit unstable if the angle to the line was too great the robot would run right over it. Thus we started discussing how to slave the wheel speeds together to truly go straight.

Enter PID (proportional integral derivative) loops and controls. Mobile Robotics implements a PI loop, while others using a PD (http://www.geology.smu.edu/~dpa-www/robots/doc/speedctl.txt). This weekend I typed out the code in the Mobile Robotics book modifying what I thought needed to be and letting her rip. Let me just say that I am using anti-phase PWM where 0 to 128 is reverse and 128 to 255 is forward with the duty cycle getting bigger the further you get from 128. Well, the robot did in fact slave the two motors together, but in opposite directions! When I added code to stop it after 4000 ticks (4 revolutions) the robot then when in a straight line. Great ... now why is it doing that?!

Long story short, I knocked together an Excel spreadsheet to simulate the result of the PI loop today. I had a multiplication error when trying to convert -100% <> 100% duty to and actual PWM value. DOH! On the otherhand, I changed over tot he PD loop David uses and now understand a lot better what is really going on. Can't wait to try it out later tonight.

Onward
Jay



A screenshot of my excel spreadsheet