Arduino set parameters

Thread Starter

JulesP

Joined Dec 7, 2018
383
I am ready to start using a sketch that has been pre-written for use with a BLDC motor (see attached txt file) but will probably want to make adjustments to the min duty cycle which is set near the top of the sketch. Is there any reason why I can’t set the minimum to 25 (10%) for greater power control? Also, given that a sensorless motor doesn’t operate well at low rpm, what are the optimum settings for duty cycle and delay to get it up to speed?

Thanks
 

Attachments

ericgibbs

Joined Jan 29, 2010
18,766
hi JP,
I would suggest that best approach would be to test the motor with the drive shaft loaded and unloaded.
In the sketch you could add a Serial.output line to monitor and get a rough idea of the rate of RPM change.

E
 

Thread Starter

JulesP

Joined Dec 7, 2018
383
hi JP,
I would suggest that best approach would be to test the motor with the drive shaft loaded and unloaded.
In the sketch you could add a Serial.output line to monitor and get a rough idea of the rate of RPM change.

E
Not sure how to format that line but I get the idea. I think what you’re saying is that how the motor responds under load and no load conditions will indicate the minimum duty cycle that will work. What about at startup; how best to determine the duty cycle then and any delay before the back emf sensing kicks in?
 

ericgibbs

Joined Jan 29, 2010
18,766
hi,
As you can see I have run your sketch , unfortunately I do not have a BLDC on the bench.
What type of load are you driving with the BLDC.?
Does it have to start up at 245/255 in a given time.

E
 

Thread Starter

JulesP

Joined Dec 7, 2018
383
hi,
As you can see I have run your sketch , unfortunately I do not have a BLDC on the bench.
What type of load are you driving with the BLDC.?
Does it have to start up at 245/255 in a given time.

E
My intention is to measure the maximum torque the shaft can produce using a classical dynamometer approach.

According the the attached part of the sketch, and I may well be reading this wrong, for 5000us the duty cycle at start up is set to 100/255? I can’t see where else it specifies the duty cycle at start up and I’m not familiar with what ramping up of the duty cycle would be best. I’m thinking that once it’s up to sufficient rpm to receive the back emf correctly, then it would run on about 60% duty but you may have some typical data for the operation of a typical BLDC e.g. input power vs torque?8EB6E439-CDBE-4030-BF8D-96EBD26AB8BD.png
 

Thread Starter

JulesP

Joined Dec 7, 2018
383

ericgibbs

Joined Jan 29, 2010
18,766
hi
Clip:
void loop() {
SET_PWM_DUTY(PWM_START_DUTY); // Setup starting PWM with duty cycle = PWM_START_DUTY
i = 10000; //5000 // i =10,000 uSec ie: 10mS
// Motor start
while(i > 100) { //100
delayMicroseconds(i); // i =10,000 uSec
 

ericgibbs

Joined Jan 29, 2010
18,766
hi,
Replace the void loop code, use the Serial monitor, note dec by 20 of 'i'.

void loop() {
SET_PWM_DUTY(PWM_START_DUTY); // Setup starting PWM with duty cycle = PWM_START_DUTY
i = 10000; //5000
// Motor start
while(i > 100) { //100
delayMicroseconds(i);
bldc_move();
bldc_step++;
Serial.print("%=" + String(bldc_step) + ",i= ");
bldc_step %= 6;
Serial.println(i);
i = i - 20; //20
}
 

Thread Starter

JulesP

Joined Dec 7, 2018
383
hi,
Replace the void loop code, use the Serial monitor, note dec by 20 of 'i'.

void loop() {
SET_PWM_DUTY(PWM_START_DUTY); // Setup starting PWM with duty cycle = PWM_START_DUTY
i = 10000; //5000
// Motor start
while(i > 100) { //100
delayMicroseconds(i);
bldc_move();
bldc_step++;
Serial.print("%=" + String(bldc_step) + ",i= ");
bldc_step %= 6;
Serial.println(i);
i = i - 20; //20
}
Thank you.

I thought anything after // was comments so when it says :i = 10000; //5000 what does the 5000 mean?

Also, for the serial print statement, does that just print out the %duty cycle from a specific output pin?
 

ericgibbs

Joined Jan 29, 2010
18,766
hi JP,
The //5000 is a Commented out alternative delay value, the sketch author has possibly tried while testing.
E

Clip:
#define PWM_MIN_DUTY 25 //120
#define PWM_START_DUTY 245 //180

for(i = 0; i < 350; i++) { //10 350
 

Thread Starter

JulesP

Joined Dec 7, 2018
383
hi JP,
The //5000 is a Commented out alternative delay value, the sketch author has possibly tried while testing.
E

Clip:
#define PWM_MIN_DUTY 25 //120
#define PWM_START_DUTY 245 //180

for(i = 0; i < 350; i++) { //10 350
So they make reference to some start point.

The graph you showed further back from your test run, if I read that correctly it’s showing duty cycle on Y axis (max 255) and time in us on X axis and the power to the motor starts at maximum and drops to a minimum after about 220us then ramps up to a maximum again? This shows the range of duty cycle that is possible but not necessarily what will be used in actual running?

I’ve found what seems like a useful guide to understanding what each step of the sketch is doing. I don’t intend to learn how to programme but rather how to tweet lines to get the best out of the motor.

JC1914D2A-5D86-4205-ADC1-674C689A96D3.png
 

ericgibbs

Joined Jan 29, 2010
18,766
hi,
The Ramp Up/Down, I used a wire to ground either A0 or A1 on the Ardunio UNO, in order to check the sketch.

Regarding tweaking the timing, you could attach potentiometers to say A2 and A3 as analog inputs, which Set the delays.
By adjusting the pots you could vary the delays in real time, also use Serial.print to show the value of the delay.
In that way you could find optimum values for the delays etc ...

I will read your posted guide.

E


Update:
Read this multi link page, video's etc for BLDC with Arduino.
https://www.google.com/search?client=firefox-b-d&q=arduino+bldc+motor+control
 
Last edited:

Thread Starter

JulesP

Joined Dec 7, 2018
383
hi,
The Ramp Up/Down, I used a wire to ground either A0 or A1 on the Ardunio UNO, in order to check the sketch.

Regarding tweaking the timing, you could attach potentiometers to say A2 and A3 as analog inputs, which Set the delays.
By adjusting the pots you could vary the delays in real time, also use Serial.print to show the value of the delay.
In that way you could find optimum values for the delays etc ...

I will read your posted guide.

E


Update:
Read this multi link page, video's etc for BLDC with Arduino.
https://www.google.com/search?client=firefox-b-d&q=arduino+bldc+motor+control
That’s all very helpful, thanks. Are we talking 500R pots or 0-10k ones?
 

ericgibbs

Joined Jan 29, 2010
18,766
hi,
I use 10k's, keeps the current loading on the Arduino +5V low.
Do you have a project concept sketch you could post, showing the interconnections.?
E
 

pmd34

Joined Feb 22, 2014
527
Hmm I'm a bit suspicious about your motor, the one in the photo and link is just a standard stepper motor as I have some just like it and it has too many wires for a simple 3 phase motor!
 

Thread Starter

JulesP

Joined Dec 7, 2018
383
hi,
I use 10k's, keeps the current loading on the Arduino +5V low.
Do you have a project concept sketch you could post, showing the interconnections.?
E
Yes as the H bridge is completed and I have nearly finished the power supply. I will draw a circuit showing the pots and run it by you as I can’t build without it. Here are the modules so far and I could fit some pots on front of Arduino box ok.
I’ll put some drawings together over next few days.

5FD15D3B-A34A-45B9-85DA-B66983B5EB9D.jpeg6686FEE5-28A9-40B0-8C3B-AF770977E335.jpeg
 
Last edited:

Thread Starter

JulesP

Joined Dec 7, 2018
383
Hmm I'm a bit suspicious about your motor, the one in the photo and link is just a standard stepper motor as I have some just like it and it has too many wires for a simple 3 phase motor!
It’s advertised as a straightforward BLDC. I think the 8 wires are 3 for the UVW windings, 3 for the three Hall sensors and 2 for the power to the Hall sensors (see attached) but at the moment I’m not using the sensors. So I just use the thicker green, blue and yellow wires.

F1278163-BA93-4E87-9409-0018454DE4E9.jpeg
 
Last edited:
Top