Serial Communications
Hi!! We are stuck on our senior design project and would
appreciate a little help.
We are trying to connect our sensor to BASIC Stamp using RS 232
serail port. When we hook up the Sensor to the PC and use hyper
terminal (9600 Baud No Parity 1 stop bit ) we output RR and we get 1
byte back that tells us the range 8 feet.
The stamps serial port is working too. We then hook up the
SENSOR to BS2P and try to make it do something (using an if loop and
it does not do anything). We think our sensor is not interfacing
with the BS2P using RS 232.
This is our piece of code.
'{$STAMP BS2p}
SerData VAR BYTE
SerData1 VAR BYTE
Bmode CON 16624
Rpin CON 16
Tpin CON 1
Pace CON 500
number6 CON 56
letteri CON 105
OUTPUT 2
Loop:
PAUSE 2000
SEROUT Rpin, Bmode, [noparse][[/noparse]"R"]
SEROUT Rpin, Bmode, [noparse][[/noparse]"R"] 'Sends "RR" to HOB
SERIN Rpin, Bmode, [noparse][[/noparse]SerData]'Reads incoming data Stores "R" result
to "SerData"
IF SerData=1 THEN Steer 'goes to steer to light LED'
GOTO Loop
I haven't included the "steer" part of code but it works perfect.
We then used the PC hyperterminal to talk with the microcontroller
and it can read data from the BS2P to the computer but when we type
in characters in hyperterminal(for SERIN) it doesnt let us. Here's
the code for that.
'{$STAMP BS2p}
SerData VAR BYTE
SerData1 VAR BYTE
Bmode CON 16624
Rpin CON 16
Tpin CON 1
Pace CON 500
number6 CON 56
letteri CON 105
OUTPUT 2
Loop:
PAUSE 2000
SEROUT Rpin, Bmode, [noparse][[/noparse]"R"]
SEROUT Rpin, Bmode, [noparse][[/noparse]"R"] 'Sends "R" to HOB after 0.5 sec. pause
SERIN Rpin, Bmode, [noparse][[/noparse]SerData] 'Stores "R" result to "SerData"
'SEROUT Tpin, Bmode, [noparse][[/noparse]SerData]
SerData1=9
'Sends "SerData" out from P1
DEBUG ? SerData, CR 'display data back'
GOTO Loop
appreciate a little help.
We are trying to connect our sensor to BASIC Stamp using RS 232
serail port. When we hook up the Sensor to the PC and use hyper
terminal (9600 Baud No Parity 1 stop bit ) we output RR and we get 1
byte back that tells us the range 8 feet.
The stamps serial port is working too. We then hook up the
SENSOR to BS2P and try to make it do something (using an if loop and
it does not do anything). We think our sensor is not interfacing
with the BS2P using RS 232.
This is our piece of code.
'{$STAMP BS2p}
SerData VAR BYTE
SerData1 VAR BYTE
Bmode CON 16624
Rpin CON 16
Tpin CON 1
Pace CON 500
number6 CON 56
letteri CON 105
OUTPUT 2
Loop:
PAUSE 2000
SEROUT Rpin, Bmode, [noparse][[/noparse]"R"]
SEROUT Rpin, Bmode, [noparse][[/noparse]"R"] 'Sends "RR" to HOB
SERIN Rpin, Bmode, [noparse][[/noparse]SerData]'Reads incoming data Stores "R" result
to "SerData"
IF SerData=1 THEN Steer 'goes to steer to light LED'
GOTO Loop
I haven't included the "steer" part of code but it works perfect.
We then used the PC hyperterminal to talk with the microcontroller
and it can read data from the BS2P to the computer but when we type
in characters in hyperterminal(for SERIN) it doesnt let us. Here's
the code for that.
'{$STAMP BS2p}
SerData VAR BYTE
SerData1 VAR BYTE
Bmode CON 16624
Rpin CON 16
Tpin CON 1
Pace CON 500
number6 CON 56
letteri CON 105
OUTPUT 2
Loop:
PAUSE 2000
SEROUT Rpin, Bmode, [noparse][[/noparse]"R"]
SEROUT Rpin, Bmode, [noparse][[/noparse]"R"] 'Sends "R" to HOB after 0.5 sec. pause
SERIN Rpin, Bmode, [noparse][[/noparse]SerData] 'Stores "R" result to "SerData"
'SEROUT Tpin, Bmode, [noparse][[/noparse]SerData]
SerData1=9
'Sends "SerData" out from P1
DEBUG ? SerData, CR 'display data back'
GOTO Loop