the issue is not recieving the commands, when it updates the servos instead of going to the desired position, it goes to the exact opposite position then when i put in the opposite position it goes to the correct position.
Is there a formula or equation to go from angle measure to servo position number for the PSC?? i know that 750 is the center position so... yeah -Signol01
Yes, but I think you need to set the positions or angles.
Also, with 6 channels, your servos must be connected to channels 0 to 5.
initChannel just fills some private arrays. No commands are sent to the psc.
setAngle() and setPosition() move the servos. Below I have used the values
you used in version IV of your program.
··· control.initChannel(0,250,1250,(short)52428); ··· control.initChannel(1,250,1250,(short)52428); ··· control.initChannel(2,250,1250,(short)52428); ··· control.initChannel(3,250,1250,(short)52428); ··· control.initChannel(4,250,1250,(short)52428); ··· control.initChannel(5,250,1250,(short)52428); ··· control.setPosition(0,0,1500); //move directly to home position ··· control.setPosition(1,0,2500); ··· control.setPosition(2,0,2500); ··· control.setPosition(3,0,1500); ··· control.setPosition(4,0,1500); ··· control.setPosition(5,0,1500);
You use positions 1500 and 2500 which are outside the default values.
To be able to work with angles you need to define the correct Pmin, Pmax and acf
for each servo. If you work with positions only, you can even leave the
control.initChannel() lines out. Also note that my class does not store 'home' values.
Any of your update(int value) must be replaced by control.setPosition(channel,0,value)
so one.update(510) is replaced by control.setPosition(0,0,510)
I have done so in the attachement (using values from version IV).
I like your idea of a home value.
I could add a home parameter to initChannel,
a positive value >= 0 would indicate an angle home parameter (default 900, center),
a negative value would indicate a home position (default -750, center).
I can then add a method home(int channel, int ramp) that moves a servo
to its home position.
How about that?
I have added a home position parameter to initChannel(), and this method
also moves the servo directly to this home position. setAngle() or setPosition() is not
required for initializion anymore, saves code in main().
Cool thanks! I have been working with IV actually and i was able to complete the project with that version. I am going to try and incorporate the psc class in V before i submit my work to the publisher.Thanks again!-Signol01
if home < 0 then it indicates a home position (default -250 to -1250)
if home >= 0 then home indicates a home angle (0-1800 representing 0.0-180.0 degrees)
so you should say
··· for(int i=0; i<5; i++){ ····· x = 750; ····· control.initChannel(i,250,1250,(short)52428,-x); ····· if ((i == 1) || (i == 2)){ ······· x = 1250; ····· } ··· }
Why are you not using the values 1500 and 2500 anymore?
Ok,
This version is the tested code. The reason why I am not using 2500, 1400 anymore is because I was using the PSC program to get the positions when the number scale is 500 to 2500 2000 units versus the 1000 units on the serial commands. Also, I didn't realize that the home parameter was degrees until recently. Here is the working prototype of Mark V.-Signol01
Looking at your commands,
I noticed command 'k' sets servo 3 to position 1300.
That is the only time that a position is outside the 250-1250 range,
yet you didn't define Pmax for servo 3 to be 1300.
Any reason why, or is this a typo?
regards peter ·
Ok, I just remembered i need to test that thing for you, I will do so tommorrow (finals are coming up and a lot has been going on I got accepted into Rensselaer Polytechnic on xmas eve!! ) at any rate I am working on the next phase of my project where I need a more dynamic robotic control system. I have made this prototype code to just see what needs to be included. Essentially the new protocol I want to follow is a series of numbers sent from the computer. Basically 3 numbers are sent, the servo number, followed by the angle followed by 0x0D. I am not sure if this would pick up the LF value sent as well and put it in the array so if you could look over this I would be much appreciative since the final computer program that links to it will not be ready for quite some time. Thanks!-Signol
Comments
parsing starts at the position in buf[noparse]/noparse where the previous command ended, while
the new command starts at position 0 in buf[noparse]/noparse.
Regards peter
Change the line
· if (a == '\r')
in main()
into
· if (a == 0)
I noticed that CR (0x0D) is NOT placed in buf[noparse]/noparse, but is replaced by a binary 0.
regards peter
·
Post Edited (Signol) : 12/12/2005 3:33:17 AM GMT
http://www.parallax.com/dl/docs/prod/motors/ServoController.pdf
servo position values 250 and 1250 correspond to 180 degrees rotation.
Lets call those positions Pmin and Pmax
then you can use
P = (A/180)*(Pmax-Pmin) + Pmin· to calculate Position value for given Angle
A = (P-Pmin)/(Pmax-Pmin)*180 to calculate Angle for given Position
regards peter
different servos have different position ranges is hidden from the main application.
Angle resolution is 0.1 degree but I must check the·formulaes used for overflow.
The class goes into folder lib/stamp/peripheral/servo/psc
regards peter
I·make use of the method umulf() (multiply unsigned int with unsigned fraction)
in class UnsignedIntMath.
http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/math/
regards peter
Post Edited (Peter Verkaik) : 12/12/2005 6:19:23 PM GMT
Also, with 6 channels, your servos must be connected to channels 0 to 5.
initChannel just fills some private arrays. No commands are sent to the psc.
setAngle() and setPosition() move the servos. Below I have used the values
you used in version IV of your program.
··· control.initChannel(0,250,1250,(short)52428);
··· control.initChannel(1,250,1250,(short)52428);
··· control.initChannel(2,250,1250,(short)52428);
··· control.initChannel(3,250,1250,(short)52428);
··· control.initChannel(4,250,1250,(short)52428);
··· control.initChannel(5,250,1250,(short)52428);
··· control.setPosition(0,0,1500); //move directly to home position
··· control.setPosition(1,0,2500);
··· control.setPosition(2,0,2500);
··· control.setPosition(3,0,1500);
··· control.setPosition(4,0,1500);
··· control.setPosition(5,0,1500);
You use positions 1500 and 2500 which are outside the default values.
To be able to work with angles you need to define the correct Pmin, Pmax and acf
for each servo. If you work with positions only, you can even leave the
control.initChannel() lines out. Also note that my class does not store 'home' values.
Any of your update(int value) must be replaced by control.setPosition(channel,0,value)
so one.update(510) is replaced by control.setPosition(0,0,510)
I have done so in the attachement (using values from version IV).
regards peter
I could add a home parameter to initChannel,
a positive value >= 0 would indicate an angle home parameter (default 900, center),
a negative value would indicate a home position (default -750, center).
I can then add a method home(int channel, int ramp) that moves a servo
to its home position.
How about that?
regards peter
also moves the servo directly to this home position. setAngle() or setPosition() is not
required for initializion anymore, saves code in main().
http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/peripheral/servo/psc/
regards peter
if home < 0 then it indicates a home position (default -250 to -1250)
if home >= 0 then home indicates a home angle (0-1800 representing 0.0-180.0 degrees)
so you should say
··· for(int i=0; i<5; i++){
····· x = 750;
····· control.initChannel(i,250,1250,(short)52428,-x);
····· if ((i == 1) || (i == 2)){
······· x = 1250;
····· }
··· }
Why are you not using the values 1500 and 2500 anymore?
regards peter
··· for(int i=0; i<5; i++){
····· x = 750;
····· if ((i == 1) || (i == 2)){
······· x = 1250;
····· }
····· control.initChannel(i,250,1250,(short)52428,-x);
··· }
otherwise home is 750 for all servos.
regards peter
··control.initChannel(1,250,1250,(short)52428,-1250);
··control.initChannel(2,250,1250,(short)52428,-1250);
··control.initChannel(3,250,1250,(short)52428,-750);
··control.initChannel(4,250,1250,(short)52428,-750);
··control.initChannel(5,250,1250,(short)52428,-750);
}
and call initServos in main().
This also allows you to reset your servos from anywhere else in your program.
regards peter
}
This version is the tested code. The reason why I am not using 2500, 1400 anymore is because I was using the PSC program to get the positions when the number scale is 500 to 2500 2000 units versus the 1000 units on the serial commands. Also, I didn't realize that the home parameter was degrees until recently. Here is the working prototype of Mark V.-Signol01
I noticed command 'k' sets servo 3 to position 1300.
That is the only time that a position is outside the 250-1250 range,
yet you didn't define Pmax for servo 3 to be 1300.
Any reason why, or is this a typo?
regards peter
·
In your latest program the 1300 is replaced by 650.
With all positions in range you can now use angles.
I have done that in the attachement. If version V runs,
so should version VI.
regards peter
Put the following
··········· int pos = control.getPosition(0);
··········· System.out.print("servo #0 position: ");
··········· System.out.println(pos);
as the first statements inside block if (cmd) {}
I like to know if the PSC reply works using a single I/O line.
Please report if you get any reading in the IDE message window or
if the javelin appears to be stopped.
regards peter
that specifies how fast the servo must move to its home position.
http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/peripheral/servo/psc/
I noticed you try to move the servos to their home positions at rate 5.
··· for (int z=0; z<=5; z++){
····· control.setHome(z,5);
··· }//end for loop
but initChannel() already moved the servos to their home position.
With the new psc class you can specify the rate directly in initChannel.
regards peter
regards peter
when two psc boards are networked.
http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/peripheral/servo/psc/
regards peter