1. 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.
    Dismiss Notice

BLDC motor speed control...

Discussion in 'Microcontrollers' started by koolguy, Jun 23, 2013.

  1. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
  2. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    168
    Location:
    Toronto, Canada
    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: Jul 6, 2013
  3. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    Hi,


    its Atmel atmega 8au 1137d
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,803
    Likes:
    135
    Location:
    morristown,tn

    You do know that you may be sending data to fast for the Atmel atmega 8au to read it.
     
  6. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,163
    Likes:
    909
    Location:
    Rochdale UK
    Have you tried this?
     
  7. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,803
    Likes:
    135
    Location:
    morristown,tn
    Service and Support
    Service and support for this product are available from Robokits India. The Robokits Web site
    (http://www.robokits.co.in) maintains current contact information for all Robokits products.
     
  8. bryan1

    bryan1 Well-Known Member

    Joined:
    Aug 4, 2004
    Messages:
    1,679
    Likes:
    46
    Location:
    Adelaide Hills Sth Oz
    maybe the OP may be better served learning the phrase " Would you like a poppadom with your order sir".......
     
    • Like Like x 3
  9. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    how to slow the data??

    yes, it is working well ..
     
  10. Brian Griffin

    Brian Griffin Member

    Joined:
    May 23, 2013
    Messages:
    49
    Likes:
    8
    Location:
    Kuala Lumpur
    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: Jul 6, 2013
  11. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    At what baund rate, manual does not have any info....
     
  12. picbits

    picbits Well-Known Member

    Joined:
    Jan 29, 2007
    Messages:
    2,003
    Likes:
    95
    Location:
    Northants, United Kingdom
    Experiment or contact the manufacturer and ask.
     
  13. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,803
    Likes:
    135
    Location:
    morristown,tn
    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
     
  14. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    Hi again,

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


    Code (text):

    #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;

    }
     
  15. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    168
    Location:
    Toronto, Canada
    I couldn't find any proper documentation on that site.
     
  16. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    but its working....................
     
  17. tvtech

    tvtech Well-Known Member Most Helpful Member

    Joined:
    Mar 27, 2010
    Messages:
    3,166
    Likes:
    348
    Location:
    South Africa
  18. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
  19. tvtech

    tvtech Well-Known Member Most Helpful Member

    Joined:
    Mar 27, 2010
    Messages:
    3,166
    Likes:
    348
    Location:
    South Africa
    None at all. If you are happy with the result of all your hard work than good for you :D

    Regards,
    tvtech
     
  20. koolguy

    koolguy Active Member

    Joined:
    Aug 24, 2010
    Messages:
    2,196
    Likes:
    9
    No, i learning with testing if u want to give suggestion u can..
     
  21. misterT

    misterT Well-Known Member Most Helpful Member

    Joined:
    Apr 19, 2010
    Messages:
    2,697
    Likes:
    368
    Location:
    Finland
    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.
     

Share This Page