Hi folks,
I’m trying to drive a linear actuator (Firgelli PQ12) with a Wixel and the TB6612FNG. What’s happening is that no matter what PWM I send to the 6612, I’m only getting 1.5v out to the actuator (and the VMOT is getting the full 12v from the power supply).
I know the PQ12 is good, since I can connect the 12v leads directly to it and get fast motion (and this happens with multiple PQ12s). When the program (below) runs, I do get actuator motion (it extends and then retracts in a cycle), but it’s very slow and appears to stall occasionally for several seconds at a time. I think this is only due to the low output voltage from the 6612. I have also replaced the 6612 with another unit and the same behavior occurs.
Connections:
Wixel TB6612
GND GND
VALT VCC (5v from USB)
P0_0 None (position feedback from PQ12 - hi/low reference is tied to Wixel VALT and GND, so 0-5v)
P1_0 PWMA
P1_6 AIN2
P1_7 AIN1
3V3 !STBY (always driven high)
None AOUT1 -> motor lead pin 2
None AOUT2 -> motor lead pin 3
Program:
#include <cc2511_types.h>
#include <cc2511_map.h>
#include <servo.h>
#include <wixel.h>
#include <usb.h>
#include <usb_com.h>
#include <gpio.h>
#include <adc.h>
int32 CODE param_servo_speed = 4500;
uint16 position_readback; // analog voltage on pin P0_0
uint8 direction; // 1 if extending, 2 if retracting, 0 if not moving, 3 if already moved and stopped
// Here we define what pins we will be using for servos. Our choice is:
// Servo 0 = P1_0
// Servo 1 = P1_1
uint8 CODE servo_pins[] = {10, 11};
void myServosInit()
{
// Start the servo library.
servosStart((uint8 XDATA *)servo_pins, sizeof(servo_pins));
// Set the speed of servo 0
servoSetSpeed(0, 1000);
}
void myGPIOInit()
{
// set up pins P1_6 and P1_7 as digital output pins
setDigitalOutput(16, 0); // drive P1_6 LOW
setDigitalOutput(17, 0); // drive P1_7 LOW
}
void updateServos()
{
// first, check position
position_readback = adcRead(0);
// which way are we going?
switch(direction)
{
case 0: // not moving yet, start extending
direction = 1;
setDigitalOutput(17, 0);
setDigitalOutput(16, 1);
break;
case 1: // extending
if (position_readback <= 250) //>= 1750)
{
// reached end of travel, turn around and retract
direction = 2;
setDigitalOutput(16, 0);
setDigitalOutput(17, 1);
}
else
{
// keep going
setDigitalOutput(17, 0);
setDigitalOutput(16, 1);
}
break;
case 2: // retracting
if (position_readback >= 1750) //<= 250)
{
// reached end of travel, start over
direction = 1;
setDigitalOutput(17, 0);
setDigitalOutput(16, 1);
}
else
{
// keep going
setDigitalOutput(16, 0);
setDigitalOutput(17, 1);
}
break;
case 3:
//case 3: // finished, do not move
default:
setDigitalOutput(17, 0);
setDigitalOutput(16, 0);
break;
}
servoSetTarget(0, param_servo_speed); // set speed of servo movement via PWM
if (getMs() >> 10 & 1)
{
// For 2048 ms, the code in this block will be called.
// Then for the next 2048 ms, the code in the "else" block will be called.
// The pattern repeats every 4096 ms.
LED_YELLOW(0);
}
else
{
LED_YELLOW(1);
}
}
void main()
{
systemInit();
usbInit();
myServosInit();
myGPIOInit();
while(1)
{
boardService();
usbComService();
usbShowStatusWithGreenLed();
updateServos();
receiveCommands();
// The red LED will be on if any of the servos are moving.
LED_RED(servosMoving());
}
}
Any idea what I’m missing here?