BLDC motor speed control...

Status
Not open for further replies.
Note to self, do not buy poorly documented kits without schematics from Robokits India.

Anyway, what's the part number of the big IC on the H bridge controller board?
 
Last edited:
You do know that you may be sending data to fast for the Atmel atmega 8au to read it.
 

Have you tried this?
 
You need to adjust the I2C clock speed. It's in the SSPADD register. Take out the PIC16F877A datasheet and read the calculation part for the I2C speed.

You can try 5kHz at the start. Or, look at the manual for the motor controller.
 
Last edited:
I don't see it being 400khz it's probably using arduino code which the libraries are much slower then that start slow as picbits said Experiment
 
Experiment

Hi again,

The BLDC is working perfect now and i have added ADC control..


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), I2cSTOP(void);	
void i2c_Wait(void);
adc();
void main(void){
 TRISA = 0xff ;
ADCON1=0b00000000;
ADCON0=0b10000001;//000 = channel 0, (RA0/AN0)
	ADIF=0;
	TRISC3=1; //direction to input have be changed
	TRISC4=1;

TRISC5=0;
RC5=0;
RC5=1;

__delay_ms(500);
RC5=0;
 
unsigned int a;

while(1){

 a=adc();
   I2C_init();
__delay_ms(50);
	I2C_start();

	I2C_write(0x12);//esc default addr

	I2C_write(a);//testing speed 0-255

   I2cSTOP();



}





}
 
 
 
 
void I2C_init(void)
	{
  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)
{
    i2c_Wait();
    SEN=1;
}
 
 void I2C_write(char x){
	i2c_Wait();	
SSPBUF=x;
 
 
 
		}
 
void i2c_Wait(void){
    while((SSPCON2 & 0X1F || (SSPSTAT & 0X04)));
}
 
void I2cSTOP(void)
{
    i2c_Wait();
    PEN=1;
}


adc(){

	
	__delay_us(10);
GO_DONE=1;
	__delay_us(10);

return ADRESH;

}
 
None at all. If you are happy with the result of all your hard work than good for you

Regards,
tvtech
 
No, i learning with testing if u want to give suggestion u can..

Learning from mistakes is the most efficient way of learning. I suggest you try to learn from errors and mistakes. When things are not working, try to understand why.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…