Jump to content
fyaman66

TM4C1294XL PWM for BLDC Motor without delays

Recommended Posts

Hello,

 

I wrote a very simple PWM Code for my Brushless DC Motor (incl. ESC) and it works very good (I don't use any Potentiometers.):

 

 

int motorPin = PF_1;

void setup() {
      pinMode(motorPin, OUTPUT);
}

void loop() {

 analogWrite(motorPin, HIGH);
 delayMicroseconds(1000);
 
 analogWrite(motorPin, LOW);
 delayMicroseconds(19000);
}

 

I need 50Hz (1/50=20us). The Motor breaks when the first delay is "1000us" and the second is "19000us".

The Motor arrives highspeed when the first delay is "2000us" and the second is "18000us" 

So my dutycycle should be between 5 - 10%

 

What i need is this PWM Signal without any delays. Is there any way to create a PWM without delays?

 

Thank you very much.

 

greetings,

Yaman

Share this post


Link to post
Share on other sites

@@fyaman66

 

You do not appear to be using analogWrite correctly.  The general form is analogWrite(pin, value) where value is the duty cycle from 0 (off) to 255 (always on).  When you specify HIGH you are making the value 1 or barely on.  It may be you meant to use digitalWrite to create PWM.  As LRA says, using delay doesn't make much sense here.

 

Read this thread and see if it does what you are trying to do:  http://forum.43oh.com/topic/5765-analogwrite-precision-question/

Share this post


Link to post
Share on other sites

I don't get why you are even using delays.

 

Could you please explain a bit on that? Maybe with a time diagram of the signals?

Hi,

i use the delays to determine the frequency of 50hz (total delay = 20us -> 1/50hz)

and also to determine the duty cycle between 5% - 10% (this is the range where the bldc Motor starts to spin)

Share this post


Link to post
Share on other sites

Hello,

 

@Fmilburn

 

Thanks alot. I found the solution in the link you posted :D

 

this worked for me:

#include <wiring_analog.c>

 

void setup() {

     pinMode(PL_4, OUTPUT);

     PWMWrite(PL_4,1000,50,50); // PWMWrite(PINnumber, number of steps, dutycycle, frequency);

}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...