Robot Arm - Trouble Controlling servos with Propeller Servo Controller
compuwiz
Posts: 20
Hello, I'm Matt and I've built a robot arm for science fair. It is controlled with a scale arm with potentiometers.
The Propeller chip reads the potentiometer with the MCP3202 ADC converter, scales the value to a servo width and then tells the Propeller Servo Controller to move that servo to that position.
The trouble is the base servo works fine, as I move the potentiometer on the control arm, the base servo moves itself to the same position. But when I try to do the same thing with the next servo on the arm (J1) which is the same model servo, it twitches uncontrollably. If I run it with PSCI it functions perfectly. If I run J1 with the Base servo code, it runs perfectly. If I run the Base servo with the J1 code it twitches uncontrollably and though I can debug the position of the J1 potentiometer, the arm does not move to that location. The trouble is, about 70% of the time I turn the arm on and load code, it doesn't function at all. The servo just stays in one position. The main trouble is that the Pot positions for J1 is not being passed to the servos, even though it's being done the exact same way that the base servo is being positioned, and it can be successfully displayed with the parallax serial terminal.
In Summary
Works: Base servo, J1 running Base servo code, J1 controller with PSCI
Doesn't Work: J1 running J1 code, Base servo controller with J1 code
The power is 5v at 18 A coming from a computer power supply, it runs through a 3.3v regulator to power the propeller, a 5v regulator to power the connection between the propeller and the Propeller Servo Control Board and the raw 5v 18 A is fed into the servo power connection.
Science fair is on Friday, thus, help is extremely appreciated.
ServoControllerSerial.spinMain.spinReadPots.spin
The Propeller chip reads the potentiometer with the MCP3202 ADC converter, scales the value to a servo width and then tells the Propeller Servo Controller to move that servo to that position.
The trouble is the base servo works fine, as I move the potentiometer on the control arm, the base servo moves itself to the same position. But when I try to do the same thing with the next servo on the arm (J1) which is the same model servo, it twitches uncontrollably. If I run it with PSCI it functions perfectly. If I run J1 with the Base servo code, it runs perfectly. If I run the Base servo with the J1 code it twitches uncontrollably and though I can debug the position of the J1 potentiometer, the arm does not move to that location. The trouble is, about 70% of the time I turn the arm on and load code, it doesn't function at all. The servo just stays in one position. The main trouble is that the Pot positions for J1 is not being passed to the servos, even though it's being done the exact same way that the base servo is being positioned, and it can be successfully displayed with the parallax serial terminal.
In Summary
Works: Base servo, J1 running Base servo code, J1 controller with PSCI
Doesn't Work: J1 running J1 code, Base servo controller with J1 code
The power is 5v at 18 A coming from a computer power supply, it runs through a 3.3v regulator to power the propeller, a 5v regulator to power the connection between the propeller and the Propeller Servo Control Board and the raw 5v 18 A is fed into the servo power connection.
Science fair is on Friday, thus, help is extremely appreciated.
ServoControllerSerial.spinMain.spinReadPots.spin
Comments
Any ideas?
As I don't have a MCP3202 handy I cannot build up your setup.
I took a first look into your code and below you find my thoughts.
Can you post your debug-output when reading in ALL pot-values?
What I can see in your code is that setting servoposition of J1 is done with a ramp-value of zero while base is done with a ramp-value of 15
Did you try J1 with a ramp-value of 15?
If you set your scaling and limit-values of J1 to the same values as base
do you really get the same pot-values from the base-pot and the J1-pot?
The method setpos of the servo-controller-serial-object cuts the parameter value POSITION which is a long
into two bytes
did you check if the value of POSITION does not exceed 2^16 - 1 = 65635?
If it does exceed this value the transforming to byte0 and byte1 results in strange values
To narrow down the problem you have to make almost everything constant.
This means:
send base a real readpot-value
instead of sending the servocontroller-board a calculated value of J1-readPot,
for testing and analysing send servo J1 a HARDCODED and VALID value to see if this works.
If this works start varying this value or switching the value for and back between two values
that are still VALID values for PSC.
Add debug-code that reads BACK the position-value by using the GETPOS-method
best regards
Stefan
The servo now moves to where I want it to, the only interesting part is that the servo is supposed to operate on a 900 us to 2100 us pulse width but instead, the low end is 350 and the highend is 1175. Whereas with PSCI, the lowend is still 900 and the highend is 2100.