BLDC motor control using PIC16F877

Status
Not open for further replies.

adityasreekumar

New Member
How can i control the speed of a bldc motor using pwm signals from a pic16f877... i onle need to decrease and increase the speed, no need of bidirectional control....
 
You don't really need pwm it takes four outputs for most of them I have used this for testing use a adc pin like Porta.0
and four outputs on PORTb 0to 3

set up adc to give a result 0 to 255

Code:
dim i as result      //alias to adc result 
dim pin1 as PORTB.0  //alias for port pins
dim pin2 as PORTB.1
dim pin3 as PORTB.2
dim pin4 as PORTB.3
PORTB = %00000000  // sets portb low
TRISB = %00000000  // sets portb to outputs 
while true       // start of loop
       pin1 = 1     // sets high
          delayms(i) // i changes as you change potentiometer changing the delay 
       pin1 = 0
       pin2 = 1
          delayms(i)
       pin2 = 0
       pin3 = 1
          delayms(i)
       pin3 = 0
       pin4 = 1
          delayms(i)
       pin4 = 0
wend   // end of loop will keep looping as long as true
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…