Sending sensor Data over 433Mhz (P/N 27982)
rushrv
Posts: 8
Good Morning all;
I am having some trouble with a project i am working on. This is my fist post so please bare that in mind.
Here is what i have and trying to pull off. I have a LV-MaxSonar-EZ1 (www.maxbotix.com/documents/MB1010_Datasheet.pdf) a basic stamp 2 and a parallax transceiver (P/N 27982). I also have a serial LCD (parallax Item code 27977) on the unit transmitting. I aslo have a second basic stamp 2 for a receiver with the same transceiver unit (P/N 27982).
I have the program for setting up and reading the range with the sonar head (complete and works), but i want to be able to transmit the readings via wireless. The transmit/receiver code is what hanging me up. The range data is not critical but does need to be accurate, I have tried modify the codes for the transceiver with the check sum off the parallax website but when i try to add the sonar range code I run out of variable room. there for i at a loss on what to try next.
here is a sample of the codes i am using, any help or suggestions would be greatly appreciated.
Transmit code:
'{$STAMP BS2} com port 4
'{$PBASIC 2.5}
'---Set up Variables---
Value VAR Byte 'Holds data value being transmitted
realDistance VAR Word
echoTime VAR Word
value = realdistance
'---Set up Constants---
Tx CON 14 'Transmit I/O pin number
TxFlow CON 15 'Transmit flow control I/O pin number
N9600 CON $4054 'Baud mode value for 9600 baud, 8,N,1
value = realdistance
' Constants
DelayTime CON 500
Initialize:
HIGH Tx
'
Main Routine
'Transmit data
DO
sendermain:
PULSIN 12, 1, echoTime
realDistance = 2*echoTime/147 + 7
DEBUG DEC realDistance
DEBUG CR
SEROUT 11,84, [148, DEC3 realdistance, "in"]
PAUSE DelayTime
SEROUT TxFlow,N9600,[Value]
PAUSE 1000
GOTO SenderMain
SEROUT 11,84, [22,12,17]
PAUSE 5
LOOP
Receiver Code:
'{$STAMP BS2} com port 3
'{$PBASIC 2.5}
'
'---Set up Variables---
Value VAR Byte 'Holds data value being transmitted
'---Set up Constants---
Rx CON 15 'Receive I/O pin number
N9600 CON $4054 'Baud mode value for 9600 baud, 8,N,1
'
Main Routine
LOW rx
'Receive data
ReceiverMain:
SERIN Rx,N9600,[Value] 'Receive one byte
DEBUG "Receiving: ",DEC3 Value,CR
GOTO ReceiverMain 'Then start over again
I am having some trouble with a project i am working on. This is my fist post so please bare that in mind.
Here is what i have and trying to pull off. I have a LV-MaxSonar-EZ1 (www.maxbotix.com/documents/MB1010_Datasheet.pdf) a basic stamp 2 and a parallax transceiver (P/N 27982). I also have a serial LCD (parallax Item code 27977) on the unit transmitting. I aslo have a second basic stamp 2 for a receiver with the same transceiver unit (P/N 27982).
I have the program for setting up and reading the range with the sonar head (complete and works), but i want to be able to transmit the readings via wireless. The transmit/receiver code is what hanging me up. The range data is not critical but does need to be accurate, I have tried modify the codes for the transceiver with the check sum off the parallax website but when i try to add the sonar range code I run out of variable room. there for i at a loss on what to try next.
here is a sample of the codes i am using, any help or suggestions would be greatly appreciated.
Transmit code:
'{$STAMP BS2} com port 4
'{$PBASIC 2.5}
'---Set up Variables---
Value VAR Byte 'Holds data value being transmitted
realDistance VAR Word
echoTime VAR Word
value = realdistance
'---Set up Constants---
Tx CON 14 'Transmit I/O pin number
TxFlow CON 15 'Transmit flow control I/O pin number
N9600 CON $4054 'Baud mode value for 9600 baud, 8,N,1
value = realdistance
' Constants
DelayTime CON 500
Initialize:
HIGH Tx
'
Main Routine
'Transmit data
DO
sendermain:
PULSIN 12, 1, echoTime
realDistance = 2*echoTime/147 + 7
DEBUG DEC realDistance
DEBUG CR
SEROUT 11,84, [148, DEC3 realdistance, "in"]
PAUSE DelayTime
SEROUT TxFlow,N9600,[Value]
PAUSE 1000
GOTO SenderMain
SEROUT 11,84, [22,12,17]
PAUSE 5
LOOP
Receiver Code:
'{$STAMP BS2} com port 3
'{$PBASIC 2.5}
'
'---Set up Variables---
Value VAR Byte 'Holds data value being transmitted
'---Set up Constants---
Rx CON 15 'Receive I/O pin number
N9600 CON $4054 'Baud mode value for 9600 baud, 8,N,1
'
Main Routine
LOW rx
'Receive data
ReceiverMain:
SERIN Rx,N9600,[Value] 'Receive one byte
DEBUG "Receiving: ",DEC3 Value,CR
GOTO ReceiverMain 'Then start over again
Comments
i have changed the transmit program. once i get it back home i am going to attatch it to the response, if you don't mind looking at it.
Serout 11 outputs on pin 11
Serout TxFlow outputs on pin 15
you still have the goto in your code.
you also may need a wait in your serin if you are having flow problems.
I figured it out and got the programing doing what i needed it to. but now i am on to overhauling the program again to attempt to add more than one data source (multiple transmitters to one receiver unit.) Getting it to work was simple once i read up a little more about data transmission i just need to put a sync line in the code.
Serout 11,84, [148, DEC realdistance, "in"] ***that is to send the sensor data to the LCD display on pin 11.**
Thank you for your insights and help.
If you have any thoughts on where to find research on receiving data from multiple sources into one receiver i would be great-full.
You could add a one-byte header to your message with the address of each transmitter, followed by the data. At the receiver, your SERIN command would now read in two bytes and then based on the value of the first one (the ID), you'll know which transmitter sent the message.