05-26-2009, 07:39 AM
|
#1431 (permalink)
|
EcoModding Lurker
Join Date: Feb 2009
Location: Jacksonville, Florida
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
Quote:
Originally Posted by dcb
Hope I'm not intruding, but here is an outline of how I might handle interrupts (just using bytes for example)
|
Nope, not intruding.... just interrupting....
|
|
|
Today
|
|
|
Other popular topics in this forum...
|
|
|
05-26-2009, 08:19 AM
|
#1432 (permalink)
|
needs more cowbell
Join Date: Feb 2008
Location: ÿ
Posts: 5,038
Thanks: 158
Thanked 269 Times in 212 Posts
|
Quote:
Originally Posted by dlaing
dcb,
I really like your code for the ISR's.
It looks like Paul has the ADC clock at 1MHz (which means he should only use 8 bits of the result). Other than the first result the ADC takes 13 ADC cycles, or about 13us. So we can read the current for every ISR with plenty of time for everything else.
|
Sorry about the 10khz part, thanks for the catch. that was a different platform (arduino @ a fixed 10bit adc). You shouldn't miss any timer1 body invocations in that case.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
|
|
|
05-26-2009, 08:51 AM
|
#1433 (permalink)
|
EcoModding Lurker
Join Date: May 2009
Location: Bucharest,RO and Copenhagen,DK
Posts: 42
Thanks: 0
Thanked 1 Time in 1 Post
|
dcb,
There is smth funny with the adc channel selection code. Why do you use 0, 1 and 2 ADDed into the mux. Shouldn't we use 1,2 and 4 bitwise OR to the MUX ?
|
|
|
05-26-2009, 09:06 AM
|
#1434 (permalink)
|
needs more cowbell
Join Date: Feb 2008
Location: ÿ
Posts: 5,038
Thanks: 158
Thanked 269 Times in 212 Posts
|
It shouldn't matter (assuming the existing code works). ORing is the same as adding if the relevant bits start at zero anyway. I was replicating the existing code a "bit" .
PHP Code:
void ReadTemperature(void) {... ADMUX &= (128+64+32+16); // = 11110000. So, this sets MUX to 0000, and leaves the top 4 bits unchanged. ADMUX++; // This sets MUX to 0001, setting the A/D converter input to PIN 24, the temperature monitor. ...
void ReadThrottle(void) {... ADMUX &= (128+64+32+16); ...
void ReadCurrent(void) {... ADMUX &= (128+64+32+16); // = 11110000. So, this sets MUX to 0000, and leaves the top 4 bits unchanged. ADMUX+=2; // This sets MUX to 0002, setting the A/D converter input to PIN 25, the current monitor ...
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
Last edited by dcb; 05-26-2009 at 09:21 AM..
|
|
|
05-26-2009, 10:48 AM
|
#1435 (permalink)
|
PaulH
Join Date: Feb 2008
Location: Maricopa, AZ (sort of. Actually outside of town)
Posts: 3,832
Thanks: 1,362
Thanked 1,202 Times in 765 Posts
|
If there will be plenty of time for everything else, I'd like to slow down the A/D clock, because the LEM current transducer has pretty poor resolution for its output. For example, on the LEM 300, a current from 0 to 300 amps corresponds to an output of 2.5v to 2.5v + 0.625v. All the smooth driving is based on current being proportional to throttle position. If I get 32 possible values for outputs in the range 0 to 300 amps... Wait! That's when the circular buffer probably comes in handy. I get a much larger range of currents that way. Maybe I could do 500 kHz sample rate if there's time. (A/D prescaler of 32 instead of 16)
P.S.: Sorry about the nonstandard way of setting A/D channel for conversion. It's sort of like I was on a desert island, and was just programming as if there were no standards at all, just reading the ridiculous 308 page documentation and making stuff up as I went.
|
|
|
05-26-2009, 11:34 AM
|
#1436 (permalink)
|
Master EcoModder
Join Date: Apr 2009
Location: Charlton MA, USA
Posts: 463
Thanks: 31
Thanked 183 Times in 94 Posts
|
Ok, So I have been working on this for a few days now. It is a program to access the controllers settings from a windows based computer using the serial port. It is only graphical right now as there is nothing set up on the controller as far as I know for accessing the settings. I included 3 rolling graphs to display throttle, current and temp. Should be helpful. You can change the read speed as well. Hope you enjoy. Once paul finish's the pi loop stuff hopefully he can implement the serial stuff. I was thinking we can create profiles for different voltages and motor combinations that allow for best performance.
Again, Enjoy.
-Adam
|
|
|
05-26-2009, 11:45 AM
|
#1437 (permalink)
|
needs more cowbell
Join Date: Feb 2008
Location: ÿ
Posts: 5,038
Thanks: 158
Thanked 269 Times in 212 Posts
|
talk to me adam, does it have to be windows only? I'm pretty good with a serial port in java. Maybe time for a separate thread for user interface stuff that is looming (maybe built in display, standalone is nice)?
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
Last edited by dcb; 05-26-2009 at 11:52 AM..
|
|
|
05-26-2009, 11:52 AM
|
#1438 (permalink)
|
Master EcoModder
Join Date: Apr 2009
Location: Charlton MA, USA
Posts: 463
Thanks: 31
Thanked 183 Times in 94 Posts
|
OOO Java, That would be cool. I would much rather use my Mac. lol. What do you mean by built in display? Like a dash console? I was thinking about something like that for my car. I will start a new thread soon about interface options for the Cougar controller.
-Adam
|
|
|
05-26-2009, 11:53 AM
|
#1439 (permalink)
|
Master EcoModder
Join Date: Jun 2008
Location: London, Ontario
Posts: 1,096
Thanks: 0
Thanked 17 Times in 14 Posts
|
There must be off the shelf interrupt driven uart modules for this mpu... If you'd like I can detail a good com protocol for flexible and reliable data delivery.
|
|
|
05-26-2009, 11:57 AM
|
#1440 (permalink)
|
needs more cowbell
Join Date: Feb 2008
Location: ÿ
Posts: 5,038
Thanks: 158
Thanked 269 Times in 212 Posts
|
The atmegas have onboard uart (with interrupts), so I don't know what it would add, unless I'm missing something.
What might be cool is a "standard" lcd display (2x16 char or whatever) with a couple buttons and rs232 interface, kind of a "dumb terminal" for embedded use.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
|
|
|
|