Pages: [1]   Go Down
Author Topic: Change pwm freq. and get a faster analog read  (Read 986 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 308
Posts: 26474
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: June 06, 2011, 10:39:12 am by AWOL » Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: