|
|
View previous topic :: View next topic |
Author |
Message |
Almasri
Joined: 17 Aug 2005 Posts: 8
|
Servo Controller PARALLAX |
Posted: Mon Nov 07, 2005 3:39 pm |
|
|
Hi,
i want to control 12 servo motors using a PIC16F877A, the only servo controller i found and i bought was the (parallax servo controller), i have connected the servo controller to the PIC board using an RS232 cable, now i have to send signals to the Servo board to get the motors starting:
according to their manual
Each position command is comprised
of a header, three parameters: C, R, and PW, and a command terminator.
The Header: �!SC� is the header. The header signifies to all devices on the same wire that this is a command for a Servo Controller.
if i want to pass it to the PIC i have to USe PUTC() is that correct..??
and how can i pass a command which is readable by the servo controller such as the "!SC" ...???
did anybody ever came across this controller and is it possible to provide me with a simple example
thank you very MUCH |
|
|
Ttelmah Guest
|
|
Posted: Tue Nov 08, 2005 5:18 am |
|
|
Much easier to use printf, than putc. Putc, passes a single character, or a 'constant' string. Printf, generates formatted output strings.
The parallax 'move' command for example, requires 'channel', 'ramp', and then the position as two bytes. An example of a function to send this might be:
Code: |
#define INVALID_SERVO (1)
#define INVALID_POSITION (2)
#define INVALID_RAMP (3)
#define OK (4)
int8 move_to(int16 position, int8 servo_number, int8 ramp) {
if (servo_number >= 32) {
//Maximum servo number is '31', with two units attached
return INVALID_SERVO;
//error return
}
if (position < 250l || position 1250l) {
//Here the position is outside the allowed range
return INVALID_POSITION;
}
if (ramp>63) {
//Here the ramp parameter is invalid
return INVALID_RAMP;
}
printf("!SC%1c%1c%1c%1c/R",servo_number,ramp,make8(position,0),make8(position,1));
return OK;
}
|
As shown here, the function tests the values for being 'legitimate', but does not attempt to read back a status from the remote unit (the move command does not itself return anything).
You need to setup the serial to be using 2400bps, before sending this.
Best Wishes |
|
|
Almasri
Joined: 17 Aug 2005 Posts: 8
|
|
Posted: Tue Nov 08, 2005 3:16 pm |
|
|
when i tried it the motor stalled , don't i have to include a termination command as they mentioned in PARALLAX CR $0D
so in pic PCw it should look like
printf("!SC%1c%1c%1c%1c/R",servo_number1,ramp,make8(position,0),make8(position,1), 0x0D); |
|
|
Ttelmah Guest
|
|
Posted: Tue Nov 08, 2005 3:38 pm |
|
|
No.
The problem is that I typed the wrong '\'. I am on a different keyboard to normal, and it has some keys swapped.
\R, is a C standard code for a 'carriage return' (0x0D).
There are a number of such codes.
If the motor stalls then you need to change the ramp rate. This is described in the data sheet.
Best Wishes |
|
|
Almasri
Joined: 17 Aug 2005 Posts: 8
|
|
Posted: Tue Nov 08, 2005 3:55 pm |
|
|
thanks for your fast reply , its still stallin, well another problem , when i connected 2 of them they all moved and stalled looks like it doesn't matter which motor i choose they all move ,, i think this problem is from the (3-conductor cable to stereo (RS232)), i m going to try another cable |
|
|
Almasri
Joined: 17 Aug 2005 Posts: 8
|
|
Posted: Tue Nov 08, 2005 4:15 pm |
|
|
Hi Ttelmah
can you please confirm that my program is right, i am trying to make the motor turn ... from one postion to another ....
this is my first experience with PARALLAX and before checking the rs232 cable i wanted to confirm this with you
thanks alot
Code: | #include <16f877a.h>
#device ICD=TRUE
#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=20000000)
#use rs232(baud=2400, xmit=PIN_C6, rcv=PIN_C7) // Jumpers: 8 to 11, 7 to 12
main() {
int16 position1=12501;
int16 position=2501; // 250 to 1250 0-180 deg
int8 servo_number=1; //0-15 servo to use or channel to use
int8 ramp=20; // ramping parameter 0-63
while (TRUE){
printf("!SC%1c%1c%1c%1c/R",servo_number1,ramp,make8(position,0),make8(position,1));
delay_ms(1000);
printf("!SC%1c%1c%1c%1c/R",servo_number1,ramp,make8(position1,0),make8(position1,1));
delay_ms(1000);
}
} |
i would really appreciate it ....
thanks |
|
|
Ttelmah Guest
|
|
Posted: Wed Nov 09, 2005 3:14 am |
|
|
Two problems. The first problem is your two position declarations. You need:
int16 position1=1250L;
int16 position=250L; // 250 to 1250 0-180 deg
Notice the 'L', not '1'. You are trying to move the servo to impossible positions. The driver only accepts values from 250 to 1250. 'L' makes sure the compiler knows you are dealing with a 'Long' value, while an extra '1' makes it into an impossibly large value!.
In this case, because the value is directly put into a 'Long', the declaration is not really needed. I had it in my 'tests', because with the 250 in particular, it is worth making absolutely 'sure' that the compiler knows what you want. The lower case 'l', is very difficult on some fonts/screens, to 'tell' from a '1'.
You still show a '/R', not a '\R'. You need the latter.
Best Wishes |
|
|
Almasri
Joined: 17 Aug 2005 Posts: 8
|
|
Posted: Wed Nov 09, 2005 2:47 pm |
|
|
Thanks for the help ,,
i changed the RS232 wire and resolder everything in place, unfortunatly still the same problem
when i try that and connect more motors all of them stall, even when i connect one its stalls,
Given that i am only calling one servo motor, (same code you have corrected for me)
i have tried ramps between 0 and 63, i doubled check the voltage and current on motors and board, nothing changed
motors that i am using are HS-700BB
any idea what could be the cause..???
thank you again for your help |
|
|
Almasri
Joined: 17 Aug 2005 Posts: 8
|
|
Posted: Thu Nov 10, 2005 1:29 pm |
|
|
By the way that was another question for you Ttelmah
and how did u connect your pic to the Parallax board was it RS232 through the 3-conductor wire or USB
thanks again |
|
|
Almasri
Joined: 17 Aug 2005 Posts: 8
|
|
Posted: Thu Nov 10, 2005 9:05 pm |
|
|
anybody got a website that can help me ...??
or any other resources..? |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|