by netphaze » Thu Nov 12, 2009 4:43 pm
by netphaze
Thu Nov 12, 2009 4:43 pm
I currently have 4 AX-12 servos connected to a Sanguino MCU through the full-duplex to half-duplex circuit that is described in the AX-12 manual. Sanguino uses the Arduino environment. I have 4 FSRs connected to the controller, each one controlling its own servo.
I had all four servos working perfectly in response to input from the FSRs, and then I turned the power supply off, did some other work, and came back. When I turned it back on, one of the servos was not responding. I hadn't changed anything with the circuit or code. I disconnected all the others and tried to set its position. Nothing. I tried a reset. Nothing. Can't communicate with it. This happened again later with another servo. Not sure what's going on here.
I'm using the Bioloid library from Arbotix:
http://code.google.com/p/arbotix/wiki/BioloidController
Here is my code:
- Code: Select all
#include <ax12>
#include <BioloidController>
//Two variables to check if the servo serial line is receiving or transmiting
boolean Transmit = true; //True Tx is active, False Rx is active
int Direction = 0; // Digital pin for direction port
int FSR_Pin[5] = {0, 1, 2, 3}; // analog pins FSRs connect to
int FSR_Output[5]; // the analog reading from the FSR resistor divider
int FSROutputSum = 0;
int ForceMin = 600; // minimum FSR reading to actuate motor
int MaxPos[5] = {700, 400, 700, 700}; // max position for each servo
int MinPos[5] = {650, 350, 650, 650}; // min position for each servo
int ServoID[5] = {1, 2, 3, 4}; // IDs of servos
int ServoPos[5] = {650, 350, 650, 650}; // current position of servos
void setup()
{
digitalWrite(Direction, HIGH);
pinMode(Direction,OUTPUT); //Set direction port as an output
for(int i=0;i<=3;i++){
SetSpeed(ServoID[i], 100); // set all servos to speed of 100
}
}
void loop(){
while(Transmit){
FSROutputSum = 0;
for(int i=0;i<3> ForceMin){ // if an FSR is being pressed
FSROutputSum = 0;
for(int i=0;i<3> ForceMin){ // actuate appropriate motor
if(ServoPos[i] == MaxPos[i]){
ServoPos[i] = MinPos[i];
}
else{
ServoPos[i] = MaxPos[i];
}
SetPosition(ServoID[i], ServoPos[i]);
delay(250);
}
FSR_Output[i] = analogRead(FSR_Pin[i]); // read FSRs again
FSROutputSum += FSR_Output[i];
}
}
}
}
[/url]
I currently have 4 AX-12 servos connected to a Sanguino MCU through the full-duplex to half-duplex circuit that is described in the AX-12 manual. Sanguino uses the Arduino environment. I have 4 FSRs connected to the controller, each one controlling its own servo.
I had all four servos working perfectly in response to input from the FSRs, and then I turned the power supply off, did some other work, and came back. When I turned it back on, one of the servos was not responding. I hadn't changed anything with the circuit or code. I disconnected all the others and tried to set its position. Nothing. I tried a reset. Nothing. Can't communicate with it. This happened again later with another servo. Not sure what's going on here.
I'm using the Bioloid library from Arbotix:
http://code.google.com/p/arbotix/wiki/BioloidController
Here is my code:
- Code: Select all
#include <ax12>
#include <BioloidController>
//Two variables to check if the servo serial line is receiving or transmiting
boolean Transmit = true; //True Tx is active, False Rx is active
int Direction = 0; // Digital pin for direction port
int FSR_Pin[5] = {0, 1, 2, 3}; // analog pins FSRs connect to
int FSR_Output[5]; // the analog reading from the FSR resistor divider
int FSROutputSum = 0;
int ForceMin = 600; // minimum FSR reading to actuate motor
int MaxPos[5] = {700, 400, 700, 700}; // max position for each servo
int MinPos[5] = {650, 350, 650, 650}; // min position for each servo
int ServoID[5] = {1, 2, 3, 4}; // IDs of servos
int ServoPos[5] = {650, 350, 650, 650}; // current position of servos
void setup()
{
digitalWrite(Direction, HIGH);
pinMode(Direction,OUTPUT); //Set direction port as an output
for(int i=0;i<=3;i++){
SetSpeed(ServoID[i], 100); // set all servos to speed of 100
}
}
void loop(){
while(Transmit){
FSROutputSum = 0;
for(int i=0;i<3> ForceMin){ // if an FSR is being pressed
FSROutputSum = 0;
for(int i=0;i<3> ForceMin){ // actuate appropriate motor
if(ServoPos[i] == MaxPos[i]){
ServoPos[i] = MinPos[i];
}
else{
ServoPos[i] = MaxPos[i];
}
SetPosition(ServoID[i], ServoPos[i]);
delay(250);
}
FSR_Output[i] = analogRead(FSR_Pin[i]); // read FSRs again
FSROutputSum += FSR_Output[i];
}
}
}
}
[/url]