Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

BLDC motor speed control...

Status
Not open for further replies.
Yes. What I can't understand is:

1) The example code configured the ports as input
2) I said: "configure the ports as inputs.. follow the example code
3) Ritesh configured the ports as output

I have changed it but now also it is not working.
 
both led on ESC is on.
What does that tell you? What are the LEDs for?
 
Motor wired wrong or something

LED Info
LED 1 – on when powered up and motor is in stand-by. Off when motor is running.
LED2 – blinks if there is a hardware error on start-up. Blinks 10 times if there is a short-circuit detected or abnormally high current through the circuit.
 
So what is LED2 doing? On permanently, or blinking once or 10 times?
 
From what I take you could use pwm to set speed using same
Pins
Potentiometer Test and Debug
The brushless motor and driver can be tested by connecting GND to the SCL pin and applying a fixed analog voltage from 0V to 5V on the SDA pin using a 1kohm – 100kohm potentiometer. The driver will enter test mode on start-up if SCL is connected to GND and start the motor at a speed depending on the voltage on the SDA pin. This can be used to simply test the functionality of the motor driver and the brushless motor.
 
Wonder what that means lol. Read the end of the manual it tells you that on power it will test the motor then if you don't turn it on both leds will end up on. To turn it on you can do what looks like 3 ways the easy way would be as i posted. Maybe thats to easy.

1. Solder thick wires for external power at the supply contacts V(+) and V(-) with the
correct polarity.
2. Connect the A, B and C contacts at output of driver MOSFETS to the terminals of your
brushless DC motor. Now power up the driver.
3. The brushless motor driver will enter a hardware test and produce tones through the
motor windings.
4. LED1 should be on and LED 2 should turn on in a couple of seconds after the test
5. Connect a PPM signal wire to the PPM contact and GND and 5V as required.
6. Alternately, connect the SDA and SCL lines to the I2C lines on a controller board. Make
sure you have pull-ups for the I2C lines on your board and remember to connect the GND
of the motor driver to the ground on the control board. Use the correct I2C address.
7. Send a speed byte over I2C or a PPM signal to get the motor to start-up and run at the
speed set
8. Alternately, connect the SCL line to logic low or ground and set a voltage between 0V to
5V on the SDA pin. Then power up or reset the driver circuit. The brushless DC motor will
be powered and will rotate at a speed proportional to the voltage on SDA.
I would go with number 8 and PWM the SDA pin .
 
Last edited:
But what is the problem with I2C..?

Have you ever used a simple LED to debug your code? Connect a LED to a free IO pin and try to find out at what point the code stops. I bet it is one of the I2C functions that makes the code halt.. find out which one.
 
But what is the problem with I2C..?
Forget I2C for now. Do as be80be suggested and first make sure the hardware is functioning properly. If it is, then you know the code is the problem.
 
I have connected PWM it was working but not so good, after maximum speed it does decrease with PWM and i don't like it ..
anyway i have tested the I2c it is networking i have added led in between for testing but no result found.


Code:
#include <htc.h>
__CONFIG(LVP_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS);
#define _XTAL_FREQ 20000000

#define SDATA RC4
#define SCLK RC3
void I2C_init(),I2C_start(void);I2C_write(char x);
void I2cSTOP();	

void main(void){
	
	TRISC3=1; //direction to input have be changed
	TRISC4=1;
TRISC0=0;
TRISC1=0;
TRISC2=0;
RC0=0;
RC1=0;
RC2=0;
__delay_ms(500);
    I2C_init();
__delay_ms(50);
	I2C_start();
RC0=1;
	I2C_write(0x12);//esc default addr
RC1=1;
	I2C_write(200);//testing speed 0-255
RC2=1;
   I2cSTOP();
while(1){

RC0=0;
RC1=0;
RC2=0;
__delay_ms(500);
RC0=1;
RC1=1;
RC2=1;
__delay_ms(500);
}
}




void I2C_init()
	{
  SSPCON = 0x38;      // set I2C master mode
 SSPCON2 = 0x00;
SSPADD = 0x0C;  //400KHZ  20MHz xtal
SSPSTAT|=0X80;
 PSPIF=0;      // clear SSPIF interrupt flag
 BCLIF=0;      // clear bus collision flag
}

void I2C_start(void){
	SEN=1;
	while(SEN);
	
	}
	
 I2C_write(char x){
		SSPBUF=x;
		while(BF);
while((SSPCON2 & 0X1F || (SSPSTAT & 0X04)));
		
		}
			
void I2cSTOP( ){
PEN=1;
while(PEN);
}
 
void I2C_init(),I2C_start(void);I2C_write(char x);
Can someone confirm this line (particularly the comma) is correct?
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top