View Single Post
Old 02-10-2009, 09:36 AM   #375 (permalink)
MazdaMatt
Master EcoModder
 
Join Date: Jun 2008
Location: London, Ontario
Posts: 1,096

2k2Prot5 - '02 Mazda Protege5
90 day: 33.82 mpg (US)
Thanks: 0
Thanked 17 Times in 14 Posts
Paul, you don't really need to do that if you can set up some serial communication to the board. It is generally very easy to do that. At work we generally use a USB to TTL converter from FTDI Chip Home Page. The TTL end of it connects directly to the cpu.

So here's the plan:
1 - set up a 1 second timer, a large array (as large as you can with that chip) and a fake_throttle variable set to 0.
2 - when the 1 second timer expires, set the fake_throttle = whatever 1V input would be read by the ADC.
3 - when the fake_throttle value != 0, put the control system output into the next spot in the array.
4 - when you have reached the end of the array, shut down your pwm and begin a serial communication routine that will spit out the whole array from the serial port.
5 - on your PC use some kind of port monitor, these are a good way of getting a stream of data in a copy/paste-able form, then drop it into excel for analysis.

For this data to be worthwhile, you need to be sure that your PI control is happening at a known interval, not just in the main loop. It is completely impossible to tune a PI controller that executes in the main loop because timing will always be different.

I hate to say that i'm too busy, but i am... i am really looking forward to punching some code on my own motor control - there is a set of "scrap" boards here at work that are basically just a coldfire processor with a bunch of IO. (really, i want to use them to make an AC motor control, but the PI could be transferable)
  Reply With Quote