This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DRV8830 motor control

Other Parts Discussed in Thread: DRV8830, CC2650STK, DRV8830EVM

Hi!

I would like to operate motor using  cc2650STK, drv8830, DC 6V 55RPM TS-32Gz370-69.

using IAR Embedded Workbench IDE

but it didn`t operate at all.... 

i using Api sensorTag adding drv8830.c and drv8830.h of applying the function to be called

I2C that the connection between mcu and motor driver I`m not sure.

How can I verify that the I2C communication between two modules? The settings that are in the source code

If it is how to fix

I will source attached.

#include "sensor_drv8830.h"
#include "sensor.h"
#include "bsp_i2c.h"

#define SENSOR_I2C_ADDRESS      DRV8830ADDR_NN

//  fault status
#define DRV8830_F_CLEAR         0x80

#define SENSOR_SELECT()     bspI2cSelect(BSP_I2C_INTERFACE_0,DRV8830ADDR_NN)
#define SENSOR_DESELECT()   bspI2cDeselect()

#define DRV8830ADDR_00          0xc0
#define DRV8830ADDR_0N          0xc2
#define DRV8830ADDR_01          0xc4
#define DRV8830ADDR_N0          0xc6
#define DRV8830ADDR_NN          0xc8 //write address jp2, jp3 is open
#define DRV8830ADDR_N1          0xca
#define DRV8830ADDR_10          0xcc
#define DRV8830ADDR_1N          0xce
#define DRV8830ADDR_11          0xd0
 
//  fault status
#define DRV8830_F_ILIMIT        0x10
#define DRV8830_F_OTS           0x08
#define DRV8830_F_UVLO          0x04
#define DRV8830_F_OCP           0x02
#define DRV8830_F_FAULT         0x01


//  motor status
#define DRV8830_FREE            0x00
#define DRV8830_CW              0x01
#define DRV8830_CCW             0x02
#define DRV8830_BREAK           0x03
 
//  register address
#define DRV8830_CONTROL         0x00
#define DRV8830_FAULT           0x01
 
//  voltage data
#define DRV8830_V_R48           0x06
#define DRV8830_V_R56           0x07
#define DRV8830_V_R64           0x08
#define DRV8830_V_R72           0x09
    // (no definition from 0.82V to 4.74V)
#define DRV8830_V_4R82          0x3c
#define DRV8830_V_4R90          0x3d
#define DRV8830_V_4R98          0x3e
#define DRV8830_V_5R06          0x3f
 
#define DRV8830_V_MIN           0x06
#define DRV8830_V_MAX           0x3f
#define DRV8830_V_RANGE         (DRV8830_V_MAX - DRV8830_V_MIN)
 
// Voltage Control
#define DRV8830_FREE            0x00
#define DRV8830_POSI            0x01
#define DRV8830_NEGA            0x02
#define DRV8830_BREAK           0x03


// Voltage table
#define TBL_OFFSET              0x06
#define TBL_SIZE                58
#define TBL_MAX_VALUE           (5.06f)
#define TBL_MIN_VALUE           (0.48f)
#define DATA_SIZE               2
/* Register length */
#define REGISTER_LENGTH                 2

static uint8_t buf[DATA_SIZE];
static uint16_t val;
//static bool success;

const float voltage_table [] = {
    0.48,    0.56,    0.64,    0.72,    0.80,    0.88,    0.96,    1.04,
    1.12,    1.20,    1.29,    1.37,    1.45,    1.53,    1.61,    1.69,
    1.77,    1.85,    1.93,    2.01,    2.09,    2.17,    2.25,    2.33,
    2.41,    2.49,    2.57,    2.65,    2.73,    2.81,    2.89,    2.97,
    3.05,    3.13,    3.21,    3.29,    3.37,    3.45,    3.53,    3.61,
    3.69,    3.77,    3.86,    3.94,    4.02,    4.10,    4.18,    4.26,
    4.34,    4.42,    4.50,    4.58,    4.66,    4.74,    4.82,    4.90,
    4.98,    5.06
};

bool sensorDrv8830Init(void){
  return sensorDrv8830Enable(true);
}

bool sensorDrv8830Enable(bool enable){  
  bool success;
  uint8_t pwm_rate = 0;

  if (!SENSOR_SELECT())
    return false;
  buf[0]=0x00;
  success = sensorReadReg(DRV8830_FAULT, &buf[0], REGISTER_LENGTH);
  
  val = DRV8830_F_CLEAR;
  success = sensorWriteReg(DRV8830_FAULT, (uint8_t *)&val, REGISTER_LENGTH);
  
  if(enable)
    val = DRV8830_CW;
  else
    val = DRV8830_FREE;
  success = sensorWriteReg(DRV8830_CONTROL, (uint8_t *)&val, REGISTER_LENGTH);
  
  
  pwm_rate = DRV8830_V_MAX;
  val = (pwm_rate << 2) + DRV8830_CW;
  success = sensorWriteReg(DRV8830_CONTROL, (uint8_t *)&val, REGISTER_LENGTH);
  
  SensorTag_blinkLed(Board_LED1,10);
  SENSOR_DESELECT();
  return success;
}


void sensorDrv8830Start(void)
{
}

  
void sensorDrv8830Speed(float speed) {
   uint8_t direction = 0;
   uint8_t pwm_rate = 0;
   uint8_t dt[2];
   
   bool  success;   

   if (speed == 0.0f ){
     pwm_rate = DRV8830_V_MIN;
     direction = DRV8830_FREE;
   } else if (speed > 0.0f){
     pwm_rate = (uint8_t)(DRV8830_V_RANGE * speed) + DRV8830_V_MIN;
     direction = DRV8830_CW;
   } else if (speed < 0.0f){
     speed *= -1;
     pwm_rate = (uint8_t)(DRV8830_V_RANGE * speed) + DRV8830_V_MIN;
     direction = DRV8830_CCW;
   }
   if (pwm_rate > DRV8830_V_MAX){
     pwm_rate = DRV8830_V_MAX;
   } else if (pwm_rate < DRV8830_V_MIN){
     pwm_rate = DRV8830_V_MIN;
   }

   dt[0] = DRV8830_CONTROL;
   dt[1] = (pwm_rate << 2) + direction;
//   success = sensorReadReg(DRV8830_CONTROL, (uint8_t *)&val,sizeof(val));
 //  if (success)
//   {
  //    if (!SENSOR_SELECT())
  //    return;
   SENSOR_SELECT();
   bspI2cWrite((uint8_t *)dt, 2);
   SENSOR_DESELECT();
   //}
}


void sensorDrv8830Voltage(float volt) {
   uint8_t direction = 0;
   uint8_t pwm_rate = 0;
   uint8_t dt[2];
   bool  success;
   success = sensorReadReg(DRV8830_CONTROL, (uint8_t *)&val,sizeof(val));
 
   if (volt < 0){
      direction = DRV8830_NEGA;
      volt *= -1;
   } else {
      direction = DRV8830_POSI; 
   }
   if (volt >= TBL_MAX_VALUE) {
      pwm_rate = TBL_SIZE + TBL_OFFSET - 1;
   } else {
      for (uint32_t i = 0; i < TBL_SIZE; i++){ 
         if (volt < voltage_table[i]) {
            //printf("n=%d, voltage_table[i]=%f\r\n", i, voltage_table[i]);
            if (i == 0){
               pwm_rate = 0;
               direction = DRV8830_FREE;
            } else {
               pwm_rate = i + TBL_OFFSET;
            }
            break;
         }
      } 
   }
   //printf("volt=%f, pwm=0x%x, dir=%d\r\n", volt, pwm_rate, direction);
   dt[0] = DRV8830_CONTROL;
   dt[1] = (pwm_rate << 2) + direction;
   if (success)
   {
      if (!SENSOR_SELECT())
      return;
      success = bspI2cWrite((uint8_t *)dt, 2);
      SENSOR_DESELECT();
   }
}
 
 
uint8_t sensorDrv8830Status() {
   uint8_t dt[2];
   bool  success;

   dt[0] = DRV8830_FAULT;
   success = sensorReadReg(DRV8830_CONTROL, (uint8_t *)&val,sizeof(val));
   
   if (success)
   {
      if (!SENSOR_SELECT())
      return dt[0];
   success = bspI2cWriteRead((uint8_t *)dt, 1, (uint8_t *)dt, 1);
   SENSOR_DESELECT();
   }
   return dt[0];
}
 
void sensorDrv8830Reset() {

   uint8_t dt[2];
   bool success;
   dt[0] = DRV8830_FAULT;
   dt[1] = DRV8830_F_CLEAR;
   
   if (success)
   {
      if (!SENSOR_SELECT())
      return;
   success = bspI2cWrite((uint8_t *)dt, 2);
   SENSOR_DESELECT();
   }
}

  • Hi Park,

    I am moving your post to the motor driver forum for better support for DRV devices.

  • Hi Park,

    Thank you for supplying pictures of your motor setup.

    Do you have a solid ground connection between the DRV8830EVM GND and the CC2650STK board GND? Without that the I2C signals will not be read properly by the DRV8830.

    Ensure the driver is correctly powered on with the VCC supply before initiating I2C commands.

    Your JP4 and JP5 configuration is correct for the I2C base address used in the supplied code.
  • Hi Park,

    Can you verify that the I2C bus is sending the correct signals on an oscope?


  • Thank you, I still see the reference is to difficult for me But I will try to become familiar with .

  • Thank you, I still see the reference is to difficult for me
    But I will try to become familiar with .
  • Hi Nick
    Oscilloscope there is still good but I do not know how to use it.
    This is difficult to do a lot of steps to enroll as a developer do this, letting you get the courage to answer .
    What ever the oscilloscope tip?
    keysight MSO-X 3104A mixed Signal Oscilloscope 1GHz 5GSa / s
    Thank for you kindness!!
  • hi Phil Beard
    GND and between my cc2650STK DRV8830 state is not connected. The power supply to the serial port on cc2650STK state and was connected to a battery DRV8830.
    Why is the solid ground connection? I wonder.
    thank you. Buy one board at ti seems to be a choice not regret it.
  • Hi Park,

    Without a ground connection between the CC260STK board and the DRV8830 board there isn't a complete circuit for the I2C communication.

    Unplug the USB power from the CC260STK board.

    In your picture supplied the Blue wire connected to the CC260STK should be the GND connection for that board. Try connecting the blue wire to the black test point labeled GND on the bottom front of the EVM.

    Make sure the motor is connected to the DRV8830 EVM.

    After making this connection power on the DRV8830 EVM then plug in the USB cable to the CC260STK board.
  • Phil Beard said:
    Hi Park,

    Without a ground connection between the CC260STK board and the DRV8830 board there isn't a complete circuit for the I2C communication.

    Unplug the USB power from the CC260STK board.

    In your picture supplied the Blue wire connected to the CC260STK should be the GND connection for that board. Try connecting the blue wire to the black test point labeled GND on the bottom front of the EVM.

    Make sure the motor is connected to the DRV8830 EVM.

    After making this connection power on the DRV8830EVM then plug in the USB cable to the CC260STK board.

    hi Phil Beard

    Thank you
    As was your advice. But it was not working.


    1. Do I need special settings such as open pins?

    2. Pin and sensor initiation process, I would like to know what made.

    3. The slave address of the driver drv8830 not checked when debugging.

    This is the content of the add watch 1 in IAR.
    The SENSOR_SELECT () in the drv8830.c a slave address that appears when a break point.
    It comes out 0xC8 is thought to normal, but did not.

    I look forward to your kind reply

    Thank you!!

  • Hi Park,

    All of the Jumpers should be removed from the board to get the I2C base address called in your C file (0xC8).

    Was the DRV8830 EVM powered on when you tried to read the base address?

    With both the CC260STK and DRV8830 powered on, can you measure the voltage on the SCL and SDA pins? These should both be pulled high while the I2C bus is idle.