PDA

View Full Version : Serial in out question with Reynolds Xmit and Rec



tigershark35
09-07-2008, 08:32 AM
Hi
I have a problem I need some help on. I am sending 2 changing values from one Basic Stamp 2 to another via xmitter and receiver.ˇI used the TWS-434 and RWS-434 from Trynolds Electronics.ˇAttached are the two programs.
The range for the two values is from 500 to 1000.ˇ The initial values are received by the receiving Stamp and are displayed. These values are 750. Then the values after that do not make sense.

For example with no input from the Joy Stick that will change the values sent, the next received values after the initial 750, 750 are diffent.ˇ Like 1148, 218.

Any ideas. If there is more I can provide to help on this, let me know. Is it baud rates or something like that.

Any help will be appreciated, I want to expand the programs to control a number of servos, motors and lights.

Thanks.

tigershark35
09-07-2008, 08:34 AM
I don't see the files attached, so I am trying them again
JG

Franklin
09-07-2008, 10:06 AM
Not sure why you are sending junk(synch) and looking for synch

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen

Jack Jordan
09-08-2008, 12:47 AM
You might try something like this:

SoftwareFlowControlExample.bs2

' {$STAMP BS2}
' {$PBASIC 2.5}
'
' Software Flow Control Example Snippit
'
' This example lays out the basic framework for implementing software
' flow control on the basic stamp.
'
' Author: Christopher Chess Ellsworth
'
SerialInPin CON 16
SerialOutPin CON 16

T2400 CON 396
T19K2 CON 32
T38K4 CON 6
Inverted CON $4000
Baud CON T2400 + Inverted

'Timeout for reading from the serial port
SerialInTimeout VAR Word
SerialInTimeout = 1000

command VAR Byte

Init:
'Tell the host that we are not ready to recieve data
GOSUB X_OFF

Main:
GOSUB Read_Message
'Do something if command is not 0
'SELECT command
'ENDSELECT
GOTO Main

'Read a message from the server machine.
Read_Message:
GOSUB X_ON
SERIN SerialInPin, Baud, SerialInTimeout, Read_Message_Time_Out, [command]
GOSUB X_OFF
RETURN
'END Read_Message

'If no message can be read from the serial port.
Read_Message_Time_Out:
GOSUB X_OFF
command = 0
RETURN
'END Read_Message_Time_Out

'Send software flow control bytes
X_ON:
SEROUT SerialOutPin, Baud, [17]
RETURN

X_OFF:
SEROUT SerialOutPin, Baud, [19]
RETURN