PSC help needed!
PitchingOne
Posts: 24
Hello everyone,
······ I am new to Parallax products. I am trying to operate three servos via the PSC useing the Javelin Stamp demo board. I got serial communication (green light flashes on the PSC) but the following does not work:
1- I can't get the PSC to tell me it's version number. The following code attempts to do that
public void getSvoCtrlResponse(){
··· buffer.clear();
··· uart.sendString("!SCVER?");····· //command servo to verify communication
··· uart.sendByte(0x0D);··········· //End Byte
····· uart.setDirection(1);····················· //read mode
········· for(int i =0;i ;i++){
··········· buffer.append((char)uart.receiveByte());
········· }
······· System.out.println(buffer.toString());
···· uart.setDirection(0);· //write mode
}//end getVersion
2- after this verification, I attempt to check the servo's current position with the following code:
public void checkServoPos(int pscChannel){
··· uart.sendString("!SCRSP");········ //servo position command
··· uart.sendByte(pscChannel);····· //Channel of Servo
··· uart.sendByte(0x0D);··········· //End Byte
···· buffer.clear();
···· uart.setDirection(1);·························· //read mode
········· for(int i =0;i ;i++){··················· //Three byte response expected for version command
········ buffer.append((char)uart.receiveByte());
········· }
······· System.out.println(buffer.toString());
··· uart.setDirection(0);·························· //write mode
}
3- then, I command the servos to move :
·· public void moveServo(int pscChannel, int ramp,int pulseWidth)
··· {
··· uart.sendString("!SC");········ //Servo Controller
··· uart.sendByte(pscChannel);····· //Channel of Servo
··· uart.sendByte(ramp);··········· //Ramp Rate
··· uart.sendByte(pulseWidth);····· //Pulse Width
··· uart.sendByte(pulseWidth>>>8);
··· uart.sendByte(0x0D);··········· //End Byte
··· }
·I have attached my whole code, in case you would like see it.
Your help will be truly appreciated. I am trying to finalize this code by this weekend.
Thanks
······ I am new to Parallax products. I am trying to operate three servos via the PSC useing the Javelin Stamp demo board. I got serial communication (green light flashes on the PSC) but the following does not work:
1- I can't get the PSC to tell me it's version number. The following code attempts to do that
public void getSvoCtrlResponse(){
··· buffer.clear();
··· uart.sendString("!SCVER?");····· //command servo to verify communication
··· uart.sendByte(0x0D);··········· //End Byte
····· uart.setDirection(1);····················· //read mode
········· for(int i =0;i ;i++){
··········· buffer.append((char)uart.receiveByte());
········· }
······· System.out.println(buffer.toString());
···· uart.setDirection(0);· //write mode
}//end getVersion
2- after this verification, I attempt to check the servo's current position with the following code:
public void checkServoPos(int pscChannel){
··· uart.sendString("!SCRSP");········ //servo position command
··· uart.sendByte(pscChannel);····· //Channel of Servo
··· uart.sendByte(0x0D);··········· //End Byte
···· buffer.clear();
···· uart.setDirection(1);·························· //read mode
········· for(int i =0;i ;i++){··················· //Three byte response expected for version command
········ buffer.append((char)uart.receiveByte());
········· }
······· System.out.println(buffer.toString());
··· uart.setDirection(0);·························· //write mode
}
3- then, I command the servos to move :
·· public void moveServo(int pscChannel, int ramp,int pulseWidth)
··· {
··· uart.sendString("!SC");········ //Servo Controller
··· uart.sendByte(pscChannel);····· //Channel of Servo
··· uart.sendByte(ramp);··········· //Ramp Rate
··· uart.sendByte(pulseWidth);····· //Pulse Width
··· uart.sendByte(pulseWidth>>>8);
··· uart.sendByte(0x0D);··········· //End Byte
··· }
·I have attached my whole code, in case you would like see it.
Your help will be truly appreciated. I am trying to finalize this code by this weekend.
Thanks
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/peripheral/servo/psc/
regards peter
One strange problem I could not over come was, I could not get my PSC to work unless I ran it off of a separate battery pack from my javelin. Now I just run 2 battery packs, 1 for each and it works. If you still can't get it to work, it might be worth your time to check if it works using separate power sources before trying other things.
Put the file(s) in lib>stamp>peripheral>servo>psc (you need to create those folders if you dont already have them)
One more thing, which you you will probably figure out-when the PSC starts up, the servos all go to center position and ramp towards their first initialized position. To prevent this, I power on my javelin first, then I turn on my PSC after a few seconds.
Do not use 38k4 as the javelin may have
trouble receiving at 38k4. Stick to 2400 baud.
regards peter
I went to the site you referred on yahoo groups but I get this message,
"You are not a member of the group JavelinCode. "·
I will now go to the lab and test the servos with your suggested comments. I will notify if it works or not.
Thanks
·
It is free.
regards peter
I have one power supply for the Javelin and another one for the servos. One of my servos moves continuously (continous motor) as soon as the PSC is turned on...I am not quite sure why it does that, since I do not tell it to move. I think it is trying to go to center position, but it never stops itself.
I disconnected this servo, and connected the other two servos to test them individually...but the code failed as well.
I tried my own code leaving the 2400 baud and nothing works still. I don't know what to do next.
one servo motor connected to channel 0 of the psc.
Your program used CPU.pin4 for the Uart, you might want to change
that in the psc_onepin_test.java program. Be sure to have only
one motor connected to channel 0.
regards peter
Post Edited (Peter Verkaik) : 4/29/2006 5:30:15 PM GMT
http://forums.parallax.com/showthread.php?p=577032
Bulkhead has it running with the psc class, so obviously there is something wrong
with your hardware setup. Please provide all servo motor types and how you
connect the motors, the psc,·the javelin and the power supplies.
For a start, stick to 1 motor connected to channel 0.
regards peter
This is exactly how it is wired:
The javelin powers the PSC (the cables were separated so that the white wire goes to pin0, red to vdd and black to vss )
The servos have their own power supply(5V). so when the PSC's swith is on, the servo's turn on.
One servo is connected to Channel 0 just so we can test one servo at a time.
When I test the standard servo, it moves to it's home position as soon as I power the PSC, even if there is no program running in the Javelin. (I guess this is normal, but it still does not respond to what I command it to do)
When I test the continous motors, they both rotate forever, as soon as the PSC swith is turned on...why don't they stop moving?
I read the thread that bulkhead started, and followed what he said seemed to strangly work, but my servos still do not respond.
Once again, thank for your help
System.out.println(myPsc.version());
The current version of psc is v1.3 so myPsc.version() should return 0x3133
(which is 12595 decimal)
If you don't get that number then somehow the cummunication
between javelin and psc board fails. If you do get that number
you know there is communication.
regards peter
(enter c in the one line text window of the Javelin message window)
It should display "Angle = 90.0"
regards peter
······· int pos = myPsc.getPosition(0);
······· System.out.println(pos);
to the end of·the while (true) loop
(after·the line
······· System.out.println(angle%10);
)
The center position equals 750
so it then should display 750
regards peter
(obviously, since the angle is calculated from the position)
I would disconnect those continues servos and only connect
the standard servo to channel 0.
Then what do you get?
regards peter
You should get 750 or 0x02EE
It appears the lowbyte and highbyte of position are swapped.
Add the following line after the line int pos =
pos = (pos>>>8)|(pos<<8); //swap low and high byte of pos
That should then display 750
Then try the other commands as well.
regards peter
Syntax: “!SCRSP” x $0D
Reply: x y z(where x is the channel number, and z:y is the value reported)
The psc class complies to this definition.
The basic stamp example in the manual says
SEROUT Sdat, Baud+$8000, [noparse][[/noparse]"!SCRSP", ch, CR]
SERIN Sdat, Baud, 1000, Init,[noparse][[/noparse]STR Buff\3]
DEBUG "Servo ", DEC buff(0), " ", HEX2 buff(1), " :", HEX2 buff(2), CR
which would indicate the position is y:z (and not z:y)
Perhaps bulkhead can confirm which is the correct definition.
regards peter
The math appears to be correct, but the psc class worked for bulkhead.
I posted a message in the basic forum regarding the byte order of
the position value. The manual is in error, either with the definition or with
the example. Hopefully I get an answer soon.
As I don't have a psc board, someone with servo experience should post
a reply, for I have no idea why your servo isn't moving. You haven't
by mistake set the psc board to channel 16 have you? (check jumper)
regards peter
Now, the terminal window does not show up! However, when I move the serial cable out of my javelin I/O header (I accidently did this) the terminal window showed up!!!! with diffent angle position for all the commands...I thought that was a great sign, but the servos won't respond. As far as the serial line is concerned, I am not sure why it all of a sudden responds that way.
WOW, this is really blowing my mind... : (
Did you make the changes to your program in the test program? That would explain why it is different. I am currently using the psc class, so that should be working, but I can't really say about that test program (although I recall it working).
If your servos go to center position when you turn on your PSC, it means that it is running the "frames" stored in its own memory. These are the commands that you load onto it through USB or serial port directly. You need to have your javelin send the first data bytes to "initialize" the servo positions BEFORE you turn on your PSC, otherwise it will begin executing the frames that are stored in your PSC. I avoid this by turning on my javelin, and then waiting for the green light on the PSC to flash (indicating data transfer). At that point I turn on the PSC's switch.
When you send a data byte or bytes to your PSC, you should see the PSC's green LED flash. If it is, then you know your javelin is sending the commands.
If you can, try running your single servo off of 4 AA batteries. Servos may not function properly at low voltages, although I believe they are designed for 4.8V operation. This probably won't help much, but it's something to try. If you have a multimeter, check the voltage that the servo is getting when the PSC is switched on.
Edit: one more thing I forgot to mention. I tried using the getPosition() method,but I get really large/small numbers and don't know how to convert them. I just keep track of position in my main class, and it works fine for my purposes.
Post Edited (bulkhead) : 4/30/2006 12:39:11 AM GMT
regards peter