Go Down

Topic: Change pwm freq. and get a faster analog read (Read 1 time) previous topic - next topic

Ludo91

Hey guys!
I asked a while ago about using Uncle Ardu to handle BLDC commutation, now the project is in its last steps (here http://endless-sphere.com/forums/viewtopic.php?f=30&t=26386 the main topic on EV forum and herehttp://code.google.com/p/dc-brushless-open-source-controller/ on google projects).

Now, I have two issues:


1) the analog read takes way too long. In this quote from the other forum you get an idea of it

Quote

no gas reading and no output rewriting: 20 000 ns per loop

gas reading and no output writing: 150 000 ns per loop ===>analo gread is SLOW!

no gas reading but output writing: 60 000 ns per loop

gas reading and output writing: 190 000 ns per loop

target was 40 000 ns per loop to go to 6 000 rpm with a 5% commutation delay


I`m perfectly fine with the output writing time but not with the analog read time. It is ok for first testing but too slow to be implemented every 5 loops or so to do real time current control (curr sensor gives analog value). i`ve been told there is a way to get analog reading way way faster, how to?? 130 000 ns for one analog read is not ok.



2) I need to slow dowm the Ardu`s PWM output to something between 8 and 16 kHz, how to?


thankyou!

PS: the project is open source (Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License), so if you want to join you are welcome!

cheers,
Ludovico



AWOL

#1
Jun 06, 2011, 05:30 pm Last Edit: Jun 06, 2011, 05:39 pm by AWOL Reason: 1
Quote
) I need to slow dowm the Ardu`s PWM output to something between 8 and 16 kHz, how to?

Do you mean you need to speed up the Arduino PWM to between 8 and 16kHz?

Is it the case that the conversion time for the analogRead is too slow, or is it just the dead time caused by it?
If you start an analogue conversion, you can go off, do some computations, then come back to see if the convestion is complete.
The code change is quite simple, and means you split "analogRead" into two parts
1) a mux setup and begin conversion
2) a non-blocking poll end-of-conversion
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Ludo91

yep! speed up to between 8 and 16 khz. How to? SOmething I can write in the setup part of the code to do so?

I don`t really get the thing about the analog read, I just know that when i add an analog read in the code the loop slows down about 130us per each analog read.... I ve been told i can make it way faster but idk how to

Go Up