Serial PSC Commands
WaldoDTD
Posts: 142
Hey, does this command work for the PSC? I am using a Javelin Stamp and I am sending this string using a char array and sending letter by letter to the PSC using a Uart class on the string. I know that someone has interfaced the PSC with a Javelin before so how would you handle the transmission from the stamp to the PSC.
Command array =·!SC1085.LOWBYTE2304.HIGHBYTE
-Hacker
Command array =·!SC1085.LOWBYTE2304.HIGHBYTE
-Hacker
Comments
Here is a code snipit of what I used to communicate with the psc on my javelin based robot...Perhaps this will help.
here is the setup for the txUart
more examples can be found here
www.kettering.edu/~kein0105/robotics.html
-Jon
is missing, it tells the psc which servo to move.
It should go after the !SC like this:
-Jon
I think your SERIAL_CTS_PIN is actually your SERIAL_RTS_PIN.
In hardware flowcontrol , tx is paired with cts, and rx is paired with rts.
tx and rts are outputs, rx and cts are inputs.
tx connects to rx, rts connects to cts (eg. output connects to input)
Do you really want the PSC to wait transmitting until javelin is ready to receive (current rxUart),
or do you want the javelin to wait transmitting until the PSC is ready to receive?
Current txUart lets the javelin transmit to PSC at will.
regards peter
Current setup:
· static Uart comUart = new Uart( Uart.dirTransmit,SERIAL_TX_PIN2,Uart.dontInvert,
························· SERIAL_RTS_PIN, Uart.dontInvert, Uart.speed9600,
························· Uart.stop1 );
You define a transmit uart for the pc, SERIAL_TX_PIN2 is the pin that the
javelin uses to transmit data to the pc, and at the pc side it connects to RX.
For hardware handshake, tx is paired with cts. So it should be
· static Uart comUart = new Uart( Uart.dirTransmit,SERIAL_TX_PIN2,Uart.dontInvert,
························· SERIAL_CTS_PIN, Uart.dontInvert, Uart.speed9600,
························· Uart.stop1 );
SERIAL_CTS_PIN is the pin that the javelin uses to check if it may transmit,
and at the pc side it connects to RTS.
Javelin will transmit if pc is ready to receive.
· static Uart txUart = new Uart( Uart.dirTransmit,SERIAL_TX_PIN,Uart.dontInvert,
························· Uart.speed2400, Uart.stop1 );
You define a transmit uart for the PSC, SERIAL_TX_PIN is the pin that the
javelin uses to transmit data to the PSC, and at the PSC side it connects to RX.
Javelin will immediate transmit data if available (does not wait for PSC to be ready)
· static Uart rxUart = new Uart( Uart.dirReceive, SERIAL_RX_PIN, Uart.dontInvert,
························· SERIAL_CTS_PIN, Uart.dontInvert, Uart.speed9600,
························· Uart.stop1 );
You define a receive uart for the PSC, SERIAL_RX_PIN is the pin that the
javelin uses to receice data from the PSC, and at the PSC side it connects to TX.
For hardware handshake, rx is paired with rts. So it should be
· static Uart rxUart = new Uart( Uart.dirReceive, SERIAL_RX_PIN, Uart.dontInvert,
························· SERIAL_RTS_PIN, Uart.dontInvert, Uart.speed9600,
························· Uart.stop1 );
SERIAL_RTS_PIN is the pin that the javelin uses to inform PSC that·it may transmit,
and at the PSC side it connects to CTS.
PSC will transmit if javelin is ready to receive.
regards peter
·http://www.geocities.com/navacrony/toddler.html
You should be able to get the Javelin communicate in the same way using I/O pins and Uarts.
regards peter
·
for the udp programs for the PINK (it was a VB source) it first didn't work because
it was UNICODE encoded. After I changed it to ASCII encoding it worked.
I don't know if encoding is used in your program but do check.
regards peter
It displays whatever is received by the Uart. Let your pc program send its data
and see in the javelin ide message window what is received.
Set pin and baudrate for your setup.
You require 2 com ports on your pc.
regards peter
Be sure your pc program sends a '\r' (13 decimal) otherwise
bufferMessage() never returns.
regards peter
Format.printf("%02x ",0xFF & c); //display hex value
where 0xFF & c turns the byte into a hex value? I tried to run my original wintermute program again but it didn't work. I just need to know if you changed the bytes to hex values in some way similar to the way you find the highbyte of a number by adding >>>8 to the int number. Would it be more relevant if I create a buffer and store the bytes in there and then terminate the handling when it comes accross the the value 0D? Thanks!-Signol
Format.printf("%02x ",0xFF & c);
displays the parameter as a hexvalue. Because the parameter is an integer (not a char)
I use c&0xFF to make sure the integervalue equals the·value of c.·If c >= 0x80 and you don't
use &0xFF than the resultvalue would be 0xFF80-0xFFFF (the parameter gets sign extended).
%02x instructs printf to display the integervalue as 2 hexbytes, preceeded by 0's if
the value < 16 (so 11 is printed as 0B, not just .
Suggested handling:
wait for cmd false; then you know previous command was sent
place command in cmdbuf,·for example "asd",0 (closing 0 !!) in·the cmdbuf, then set cmd true.
Notice that the state machine adds CR,LF to the bytes in cmdbuf (so 'a','s','d',CR,LF gets sent)
On the javelin you assemble the received bytes until CR,LF is received. On the fly you
change the received CR,LF to·just a newline ('\n') or discard it altogether.
So a complete message received would be "asd\n" or "asd". Then you can let the javelin
execute the·command.
Notice that I use CR,LF as end of message marker so do not use those as regular data.
If you do need to send binary values, either send them as hextext (11 would be send as 0x0B)
or figure out another way to let the javelin know the message has ended.
regards peter
·
what command was received. If your command is "asd"
it will display CMD: asd
regards peter
Post Edited (Signol) : 12/2/2005 5:07:44 PM GMT
Post Edited (Signol) : 12/1/2005 2:06:49 AM GMT
I was thinking you tried to send commands via the JIDE port, but that was another thread,
so I used Terminal for input. You send commands via a Uart so your change is correct.
Can you rename the attachement JideTerm_protocol_test in your previous post to
Uart_command_receive_test or something like that.·To avoid confusion.
regards peter
··········· index = 0;
in main()
into
··········· cmdlen = 0;
otherwise you don't parse a received command from the start.
regards peter
Add the line
··· cmdlen = 0;
after the line
··· index = 0;
regards peter
·