bs2 data
oldhippy
Posts: 36
I have a BS2 getting several data streams in ASCII from a sensor it is sendt to a LCD if the data is ok i need to send it to a Bluetooth module how can i select the data i want to send?
Comments
However, each device can talk or listen to serial data. So, if the Stamp can successfully read the sensor data and parse out what to send to the LCD, it can also do the same for the Bluetooth device.
The limitation will be if the Stamp (due to RAM limitations) can grab a whole set of data from the sensor or if you'll have to do it in sections. Also, if you can slow the data delivery rate to say 2400 baud, the Stamp may be able to process the incoming data character by character. Alternatively, you can go to the BS2p series of Stamps which have a lot more RAM, higher speed and a couple of special commands which make grabbing long input strings easier.
Maybe post the incoming strings and a connection diagram of the components so we can better understand what the whole circuit looks like.
Cheers,
' {$STAMP BS2}
' {$PBASIC 2.5}
'2014 final inch.tenths, feet and inch to tenths WRITTEN TO DRAFTMATE1A SN 0115-1001A
'revised 1-16 20015 serout and serial in to match pcb
'sn 12-18-14-001
LCD PIN 15 '12-17-14 DISPLAYS ON NEWHAVEN LCD. GETS MAX MIN DIVIDES BY 2
idx VAR Byte ' SHOULD GET WAVE PEAK AND VALLEY AND GIVE ACCURATE READING
range VAR Word 'added pause # 19 on 12-18-15
accum0 VAR Word
accum1 VAR Word
mymax VAR Word
mymin VAR Word
draft VAR Word
inches VAR Word
feet VAR Word
leftoverq VAR Word
rem VAR Word
accum0 = 0
accum1 = 0
mymax = 0 'reversed 1-29-2015 didn't work changed back
mymin = 9999
PAUSE 150
SEROUT 15, 84, [254, 70] ' Initialize LCD
SEROUT LCD, 84, [" MEASURING DRAFT "]
SEROUT 15, 84, [254, 69, 64]
PAUSE 100
SEROUT LCD,84, [" WAIT FOR IT "]
SERIN 9,16468, [WAIT("R")] ' sync with the stream,
FOR idx = 1 TO 32
SERIN 9, 16468, [DEC range] ' capture 32 decimal values
accum0 = accum0 + range ' average
IF accum0 < accum1 THEN accum1 = accum1 + 1 ' double precision dda
mymax = mymax MIN range ' track min and max
mymin = mymin MAX range
NEXT
range = (accum0 >> 5) + (accum1 << 11) ' double precision divide by 32
draft = (mymax+mymin)/2
inches = DRAFT*10 /254
feet = inches / 12
rem = draft*10 // 254
leftoverQ = rem*100/254
SEROUT 15, 84, [254, 70] ' Initialize LCD
PAUSE 100
SEROUT 15, 84, [DEC4 draft,"mm ",DEC3 inches,".",DEC2 leftoverQ,"in " ]
SEROUT 15, 84, [254, 69, 66]
SEROUT 15, 84, [ DEC2 feet,"ft ", DEC2 inches-(feet*12),".",DEC2 leftoverQ,"in"]
If the LCD data is good, then all you have to do is get it to the Bluetooth module. But, you'll have to take into account the data format the Bluetooth is expecting and also what format the receiving equipment expects.
For instance, your lcd displays ( feet inches.tenths inches ) but the receiving device may need it in a different format; maybe BCD or Hex for example.
Cheers,