Stamp serial questions
Tom P
Posts: 97
STAMPERS:
Here is my question?
I am collecting data from·a·few·TSL-230 light sensors on a BASIC STAMP 2, and relaying the data via a radio link to another STAMP 2 with the following program. Just looking at the·debug screen without·implementing the SEROUT command the data looks fine
But --·I'am trying to collect data on the second BASIC STAMP 2 and then trying to re-send out the data on the Internet via a serial device. but when I try to resend the data out via the SEROUT command, the·numbers shown on both the debug screen and the serial output on pin, do look correct.
Is it possible to receive data then re-transmit it again as I would like to do?
any suggestions to this problem??
'{$STAMP BS2}
'{$PBASIC 2.5}
'6-lightRx
cnt VAR Word
DO
· SERIN 7, 16780, [noparse][[/noparse]WAIT ("*"), cnt ]
· 'PAUSE 1
· DEBUG DEC5 cnt, (13)
· 'PAUSE 100
· 'SEROUT 1,16780, [noparse][[/noparse]DEC5 cnt,10,13]
LOOP
Here is my question?
I am collecting data from·a·few·TSL-230 light sensors on a BASIC STAMP 2, and relaying the data via a radio link to another STAMP 2 with the following program. Just looking at the·debug screen without·implementing the SEROUT command the data looks fine
But --·I'am trying to collect data on the second BASIC STAMP 2 and then trying to re-send out the data on the Internet via a serial device. but when I try to resend the data out via the SEROUT command, the·numbers shown on both the debug screen and the serial output on pin, do look correct.
Is it possible to receive data then re-transmit it again as I would like to do?
any suggestions to this problem??
'{$STAMP BS2}
'{$PBASIC 2.5}
'6-lightRx
cnt VAR Word
DO
· SERIN 7, 16780, [noparse][[/noparse]WAIT ("*"), cnt ]
· 'PAUSE 1
· DEBUG DEC5 cnt, (13)
· 'PAUSE 100
· 'SEROUT 1,16780, [noparse][[/noparse]DEC5 cnt,10,13]
LOOP
Comments
do you want to change the serial data so it will not look correct ??
if that look correct what's wrong ?
amaral
The program above shows the receiving program on the second STAMP 2.
When I read the debug statement on a PC - all looks fine, but when I add the SEROUT command to the program -- the readings from the debug output are no longer correct. although the debug reading and the serial output on pin 1 of the second STAMP 2 appear to be the same. So when the the SEROUT is added why do the reading become incorect.
Is it posible to have and incoming serial reading on the STAMP 2 and then have the same data resent out on another serial pin?
tom
Is there a leading character on your data stream so you can use the WAIT modifier? See the online help file for more info.
Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
The sensor/sending STAMP 2 uses a wait modifier when sending to the second RX STAMP 2 which also uses the wait modifier as shown. The wait modifier between the radio links sending serial data appear fine.
If I use: SEROUT 1,16780, [noparse][[/noparse] cnt ] in the program - the display is correct on the debug window but output on pin1 is gibberish
If I use SEROUT 1,16780, [noparse][[/noparse]DEC5 cnt5,10,13] in the program -- the readings on the debug screen are not correct any more, but the output from pin1 is formated correctly for five digits and displays wrong numbers but they are readible.
IS there a way to buffer the input from the output, there seems to be an strange interaction.
Any ideas out there?
Just a Question, your variables: (cnt) AND (cnt5) are the same ?? or is it a misstype ?
Amaral
This is the data collector: L[noparse][[/noparse]transceiver]<->bs2<->sensors I also have a serial lcd screen to verify that the data is going out correctly.
The receiver end is like so: L[noparse][[/noparse]transceiver]<->rs-1 serial interface adapter-->PC. I used minicom(linux) and hyperterm(windows) to test the data.
The transceivers I'm using are a pair of hac-um96 wireless links. I'm working on writing a perl script that collects the data and puts it to a db.
I've yet to run into any issues with receiving. Do you have the means to run a direct link to the PC and remove the second bs2? It's just a thought and worked well for me so far.
But I've been told by STAMPers that the receiver fed to the STAMP 2 cannot be used to mirror the serial input data, beacuse the STAMP has no buffer memory. I want to use the second STAMP to futher manipulate the incoming data.
tom
You could try doing a looped count to 5 and making sure that you get all of that data correctly?
count = 1
for count to 5
debug count
serout the count value
count = count + 1
loop
--[noparse][[/noparse]above is just an example]--
One other thing, you mention 5 digit groups which should be something that would fit in a word var, but do you know if it exceeds the words max value? One way to overcome this would be to use an array value for each character if this is the case.
Another thing to try is to send some dummy value, like 11111 to debug and to the serial device prior to the loop. Set the main loop to a for/next loop and set it to capture 5 times, then reset and send the dummy value(11111) again to see if the above values gets sent.
Last thing, you mentioned this in a previous post. "If I use SEROUT 1,16780, [noparse][[/noparse]DEC5 cnt5,10,13] in the program -- the readings on the debug screen are not correct any more, but the output from pin1 is formated correctly for five digits and displays wrong numbers but they are readible."
Where are the readings being displayed, are you sending this to a term program? I'm just curious how you have it all hooked up...
Debug goes to the stamp editor prog, were does the serout go to?
Since the stamp currently receiving is going to be processing the data, which can take a variable amount of time, you should make it the Master. The other stamp will be the Slave, only performing work when requested of the master. The typical flow would go like this:
1. The master is ready to process the next data value and sends the request to the slave.
2. The slave receives the request, reads the appropriate sensor, does any processing necessary on its end and replys to the master with the requested data.
3. The master processes the requested data and starts the loop again.
Sample code that I used on a similar two stamp system:
On the Master:
Get_Data:
· SEROUT bt_tx, BlueBaud,[noparse][[/noparse]"DR",Instrument]
· SERIN bt_rx,BlueBaud,5000, Oops,[noparse][[/noparse]WAIT (Instrument), DataIn1,DataIn2]
RETURN
The Oops·routine is used to handle the situation where the Slave if off-line
On the Slave:
DO
SERIN bt_rx,bluebaud,[noparse][[/noparse]WAIT ("DR"), Instrument]
SELECT Instrument
· {code here to process the selected value for instrument}
ENDSELECT
SEROUT bt_tx,bluebaud,[noparse][[/noparse]Instrument,DataOut1,DataOut2]
LOOP
Remember, the serial communication is just a stream of bits and if you don't jump in at exactly the right point the values you get out will be jibberish. In the above example, I was using a Bluetooth connection, but any device that is a serial link would work the same.
By the way, my second stamp is also sending the data to the internet using a PINK. You can see the output at http://weather.msd.k12.mo.us.
Post Edited (MSDTech) : 5/6/2008 11:26:41 PM GMT
Can I use a BS2e and try and utilize the buffer memory for the second STAMP in the project?
So here is the code so far:
1)code for the TX portion using RF transmitter
2)code for RX portion using RF recevier.
Code shown is what I have so far --- for the second STAMP 2e.
need some code help on the RX side with buffering ideas in order to send SEROUT from the BS2e to Internet serial device
thanks
Tom
' {$STAMP BS2}
' {$PBASIC 2.5}
' program to scan 6-TSL230 sensors & send data via RF Xmit
DIRL = %11111100 ' Set OE pins 2 through 7 to OUTPUT
IN PIN 0 ' Common TSL230R output to BASIC Stamp
OEPINS VAR OUTL ' Tie I/O pins 2 through 7 to the OE's of the six TSL230R's
cnt VAR Word(6)
i VAR Nib
mask VAR Byte
bdmd CON 16780 '2400 baud
tpin CON 8
Scan:
PULSOUT 8, 1200
mask = %11111011 ' These are the values for the OE pins.
FOR i = 0 TO 5
OEPINS = mask & %11111100 ' Keep input pin low
COUNT IN, 100, cnt(i)
mask = (mask << 1) | %0000001
NEXT
OEPINS = %11111100 ' Turn them all off
DEBUG HOME
FOR i = 0 TO 5
DEBUG DEC5 cnt(i)
SEROUT tpin,bdmd, [noparse][[/noparse] "*", cnt(i),10,13 ]
IF i < 5 THEN DEBUG " "
NEXT
GOTO scan
' STAMP 2e RX program
'{$STAMP BS2}
'{$PBASIC 2.5}
'{$PORT COM1}
'6-lightRx
cnt VAR Word
DO
SERIN 7, 16780, [noparse][[/noparse]WAIT ("*"), cnt ]
PAUSE 1
DEBUG DEC5 cnt, (13)
PAUSE 1
SEROUT 1, 16780,1, [noparse][[/noparse]cnt ]
LOOP