Shop OBEX P1 Docs P2 Docs Learn Events
BPI-216 fun — Parallax Forums

BPI-216 fun

Al AdrianAl Adrian Posts: 4
edited 2006-04-30 16:12 in General Discussion
I'm working towards using a BS2P to monitor GPS NMEA strings to feed route turn warning sounds into my motorcycle intercom, flash lights and stuff...

I also will monitor a temperature and battery voltage ADC while I'm there...

I have a Scott Edwards BPI-216 serial LCD display and I'm trying to get to grips with using it...

My goal is to scroll (sometimes quite long) routing information strings from the NMEA string along the top line of the LCD, while updating the temp and volts on the bottom line... (the frequency of the sensor data update is not all that important, but I'd like it to appear to be there all the time)

Problem is that when I issue a scroll command , the position of the bottom line information seems to scroll too... Even though I give a new cursor position each time I write the bottom line data. In my mind, I should get a top line scroll, then the cursor gets set on the bottom line, and sensor data written, LCD scrolls, sensor data is positioned, and written... etc...

Thanks for any help on this...

Al...

below is my code:
' {$STAMP BS2p}

' This program is for messing around with my prototype system which
' when finished, will take in GPS NMEA data, as well as the temperature
' from a DS1820 and display as much as possible on my serial 2x16 display
' as of April 26 2006 it reads a Dallas one wire temp sensor and an
' ADC0831 A-to-D converter and prints temp and volts to an LCD display

N9600 CON $40f0 ' Baudmode-9600 bps inverted. Use $40F0 for BS2p.
I CON 254 ' Instruction prefix value.
CLR CON 1 ' LCD clear-screen instruction.
LINE2 CON 192 ' Address of 1st char of 2nd line.
L1_C7 CON 135 ' Address of line 1, character 7.

Temp VAR Word 'Holds the temperature value
CRem VAR Byte 'Holds the counts remaining value
CPerC VAR Byte 'Holds the Counts per degree C value
d VAR Byte 'counter for scroling display

ADres VAR Byte 'A-to-D result: one byte.
CS CON 12 'Chip select is pin 12
AData CON 14 'ADC data output is pin 14
CLK CON 13 'clock is pin 13
v VAR Byte 'variables for building voltage from 8 bits
R VAR Byte '
v2 VAR Byte '
v3 VAR Byte '

' Now clear the screen in case there's text left from a previous
' run of the program. Note that there's a 1-second PAUSE prior to
' sending any data to the Backpack.

initialize:
PAUSE 1000
SEROUT 1,N9600,[noparse][[/noparse]I,CLR] ' Clear the LCD screen.
PAUSE 1
SEROUT 1,N9600,[noparse][[/noparse]I,144] 'put coursor just off screen upper row
PAUSE 1
SEROUT 1,N9600,[noparse][[/noparse]"System start...."] ' write some text
GOSUB scrolltext 'scroll it to the middle
PAUSE 1000 ' pause it for a second
GOSUB scrolltext 'scroll it off
SEROUT 1,N9600,[noparse][[/noparse]I,CLR] ' Clear the LCD screen.
HIGH CS 'Deselect ACD to start
'
'Load a scrolling text
SEROUT 1,N9600,[noparse][[/noparse]I,128] 'put the cursor at home
SEROUT 1,N9600,[noparse][[/noparse]"Text to scroll and all that jazz"] ' write some text
PAUSE 1000

'MAIN PROGRAM LOOP
Start:
GOSUB gettemp
GOSUB getvolts
GOSUB calctemp
GOSUB calcvolts
GOSUB display
'
GOTO start
'
scrolltext:
FOR d=1 TO 16 ' then scroll it one screen width
SEROUT 1,N9600,[noparse][[/noparse]I,24] '
PAUSE 100 '
NEXT '
RETURN

gettemp:
OWOUT 0,1,[noparse][[/noparse]$CC,$44] 'Send Calculate Temperature command

CheckForDone: 'Wait until conversion is done
PAUSE 25
OWIN 0,4,[noparse][[/noparse]Temp] 'Here we just keep reading low pulses until
IF Temp = 0 THEN CheckForDone 'the DS1820 is done, then it returns high.

OWOUT 0,1,[noparse][[/noparse]$CC,$BE] 'Send Read ScratchPad command
OWIN 0,2,[noparse][[/noparse]Temp.LOWBYTE,Temp.HIGHBYTE,CRem,CRem,CRem,CRem,CRem,CPerC]
RETURN

GETvolts: 'Check the A-to-D converter for a voltage reading

LOW CS 'Activate the ADC0831
SHIFTIN AData, CLK, MSBPOST, [noparse][[/noparse]ADres\9] 'shift in the data
HIGH CS 'Deactivate the 0831
RETURN

calctemp: 'Calculate temperature in degrees C

Temp = Temp>>1*100-25+((CPerC*100-(CRem*100))/CPerC)

RETURN

calcvolts: 'take an 8 bit number and make it into a voltage
v=5*ADres/255 'number that can be displayed
R=5*ADres//255
v2=100*R/255
v3=100*R//255 '
v3=10*v3/255 '
IF v3<5 THEN skip_a_line '
v2=v2+1 '
skip_a_line: '
IF v2<100 THEN skip_out '
v=v+1 '
v2=0 '
skip_out: '
RETURN

display: 'display on the LCD Voltage and Temperature
SEROUT 1,N9600,[noparse][[/noparse]I,24] ' scroll text one space
PAUSE 10
SEROUT 1,N9600,[noparse][[/noparse]I,192] ' Move to line 2, character 0.
PAUSE 100
SEROUT 1,N9600, [noparse][[/noparse]DEC1 v, ".", DEC2 v2, " V ",DEC2 Temp/100,".",DEC2 Temp-(Temp/100*100),223,"C"] 'Print the voltage
PAUSE 100
RETURN
Sign In or Register to comment.