Dual Temp Control using BS2,LCD and DS18S20 Code help
Radridz3
Posts: 49
Hey there everyone this is· only the second time I've used this forum. And everyone was very helpful on my 1st project ....Spotted my typo imdtlyyy.. The project I'm working on know is a dual Temp controller using a common 2x16 hd44780 LCD and 2 DS18S20 Digi temp sensors. 1 sensors for water temp and others for Engine Temp...The Display is from seetron and will be on the dash in my boat. I have looked at some old code for this app in DIY Elect...Using a PIC16F627/628 and 628A...Actually I had to buy the hole kit for 40 bucks just to get the pre prog chip ... So I tried to us the editor to use my BS2 with that code and had no luck. Now since that point I burned up a hard drive and lost all my elect folders/datasheets/research and so on. Because I was to Stupid· not to back it up. Amazing isn't it 4 terra bytes and only had all my info on 1 Drive. Dont rub it in OK++ Im still ticked...Anyways I know your sayin why not just read the PIC again well I returned the Kit after I got what I wanted and Now I'm starting all over...I guess it could be KArma.. If anyone has any info or good links to knowledge let me Now I'm not lookin for some one to give me the code because I really Do want to get better at writting it... Thanks ahead of time.........························ J.Hess
Comments
I think you are you asking if you can implement the 1-wire protocol with a BS2 and the answer is no - but you can use the any of the BS2p microcontrollers to communicate with a DS1820. See the attached link for a discussion of the DS1820 on a previous posting - http://forums.parallax.com/showthread.php?p=651724
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
························ Craig Eid
··········· Triad Research and Development
Electical Engineering Design and Consulting Services
··················· www.TriadRD.com
If You dont need an over priced BS---stamp,
Why Are You in this Froum???
____$WMc%___________
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············································ BoogerWoods, FL. USA
Keep looking at the Daily Deals and get yourself a BS2P, BS2PE·or better yet a PS2PX.
The Special deals are the only way to go these days.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave W.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There's nothing like a new idea and a warm soldering iron.
http://moderndevice.com/LCD117CommandSummary.htm
so what are you sending to the lcd now ?
' LCD117_1.BS2 (Parallax Basic Stamp 2)
'
' Configured for 9600 baud, 8 bits, no parity.
'
' Basic Stamp 2 LCD #117
'
' P0 (term 5)
> RX (term 7)
'
'
' Sets geometry of LCD as 4X20 and clears the LCD and writes a byte in decimal and in hex
' an integer, a word, a character to the LCD display.
'
' Defines, special characters 0 - 5 as no vertical lines, 1 vertical line, 2 vertical lines etc. Displays an
' increasing bar and then a decreasing bar on line 3.
'
' Enters an infinite loop winking outputs 7 and 6.
'
' copyright, Peter H. Anderson, Baltimore, MD, Oct, '06
BaudMode Con 84 ' 9600 baud, non-inverted
N Var Byte
I Var Byte
WordVar Var Word
ByteVar Var Byte
NN Var Byte
Remainder Var Byte
Num_5 Var Byte
Dir0 = 1 ' make P0 an output
High 0 ' this is the steady state for non-inverted
Pause 1000 ' allow to stabilize
SerOut 0, Baudmode, [noparse][[/noparse]"?G420"] ' configure LCD geometry
Pause 200 ' pause to allow LCD EEPROM to program
SerOut 0, Baudmode, [noparse][[/noparse]"?B40"] ' set backlight to 40 hex
Pause 200 ' pause to allow LCD EEPROM to program
SerOut 0, Baudmode, [noparse][[/noparse]"?f"] ' clear the LCD
SerOut 0, Baudmode, [noparse][[/noparse]" LCD #117?n"] 'note new line
SerOut 0, Baudmode, [noparse][[/noparse]"www.phanderson.com?n"]
SerOut 0, Baudmode, [noparse][[/noparse]"?0?1?2?3?4?5?6?7?n"] ' display special characters
Pause 5000 ' pause five secs to admire
SerOut 0, Baudmode, [noparse][[/noparse]"?y1?x00"] ' cursor at line 1, col 0
SerOut 0, Baudmode, [noparse][[/noparse]"?l?j?l?j?l?y1"]' clear lines 1, 2 and 3 and start at line 1
' note use of down cursor
WordVar = 12345
ByteVar = 123
For N = 0 to 25
SerOut 0, Baudmode, [noparse][[/noparse]"?x00?y1"] ' locate cursor to beginning of line 1
SerOut 0, Baudmode, [noparse][[/noparse]Dec N, "?t", Hex N, "?t"] ' display N in Dec and Hex
SerOut 0, Baudmode, [noparse][[/noparse]Dec ByteVar, "?n"]
SerOut 0, Baudmode, [noparse][[/noparse]Dec WordVar, "?n"] ' display a word
ByteVar = ByteVar + 1
WordVar = WordVar + 1
For I = 1 to 4
SerOut 0, Baudmode, [noparse][[/noparse]"?g"] ' beep four times
Pause 50
Next
Pause 500
Next
SerOut 0, Baudmode, [noparse][[/noparse]"?D00000000000000000"] ' define special characters
Pause 200 ' delay to allow write to EEPROM
SerOut 0, Baudmode, [noparse][[/noparse]"?D11010101010101010"]
Pause 200
SerOut 0, Baudmode, [noparse][[/noparse]"?D21818181818181818"]
Pause 200
SerOut 0, Baudmode, [noparse][[/noparse]"?D31c1c1c1c1c1c1c1c"]
Pause 200
SerOut 0, Baudmode, [noparse][[/noparse]"?D41e1e1e1e1e1e1e1e"]
Pause 200
SerOut 0, Baudmode, [noparse][[/noparse]"?D51f1f1f1f1f1f1f1f"]
Pause 200
SerOut 0, Baudmode, [noparse][[/noparse]"?c0"] ' no cursor
Pause 200
SerOut 0, Baudmode, [noparse][[/noparse]"?y3?x00?l"] ' cursor to beginning of line 3 and clear line
For N = 0 to 25 ' increasing bar
SerOut 0, Baudmode, [noparse][[/noparse]"?y3?x00"]
NN = 4 * N
Num_5 = NN / 5
Remainder = NN // 5
For I = 1 to Num_5
SerOut 0, Baudmode, 10,[noparse][[/noparse]"?5"]
Next
SerOut 0, Baudmode, 10, [noparse][[/noparse]"?", Dec1 Remainder]
Next
Pause 1000
For N = 0 to 25 ' decreasing bar
SerOut 0, Baudmode, [noparse][[/noparse]"?y3?x00?l"]
NN = 4 * N
NN = 100 - NN
Num_5 = NN / 5
Remainder = NN // 5
For I = 1 to Num_5
SerOut 0, Baudmode, 10, [noparse][[/noparse]"?5"]
Next
SerOut 0, Baudmode, 10, [noparse][[/noparse]"?", Dec1 Remainder]
Next
Do ' continually bring outputs 7 annd 6 high and low
SerOut 0, Baudmode, [noparse][[/noparse]"?H7?L6"]
Pause 500
SerOut 0, Baudmode, [noparse][[/noparse]"?L7?H6"]
Pause 500
Loop
Basic Stamp 2 - Big Number Example
' {$STAMP BS2}
' {$PBASIC 2.5}
' LCD117_2.BS2 (Parallax Basic Stamp 2)
'
' Illustrates displaying quantities using the Big Number (3-wide) format.
'
' Continually calls a stub program which returns temperatures in the range
' of -99.9 to 999.9 and display on the LCD in the 3-wide big number format.
'
' Configured for 9600 baud, 8 bits, no parity.
'
' Basic Stamp 2 LCD #117
'
' P0 (term 5)
> RX (term 7)
'
' Sets geometry of LCD as 4X20, sets backlight intensity to 40 hex and configures
' for no cursor.
'
' Note that PBASIC 2.5 is used.
'
' copyright, Peter H. Anderson, Baltimore, MD, Oct, '06
BaudMode CON 84 ' 9600 baud, non-inverted
N VAR Byte
T_10 VAR Word
TWhole VAR Byte
TFract VAR Byte
Digit VAR Byte
DIR0 = 1 ' make P0 an output
HIGH 0 ' this is the steady state for non-inverted
PAUSE 1000 ' allow to stabilize
SEROUT 0, Baudmode, [noparse][[/noparse]"?G420"] ' configure LCD geometry
PAUSE 200 ' pause to allow LCD EEPROM to program
SEROUT 0, Baudmode, [noparse][[/noparse]"?B40"] ' set backlight to 40 hex
PAUSE 200 ' pause to allow LCD EEPROM to program
SEROUT 0, Baudmode, [noparse][[/noparse]"?c0"] ' clear the cursor
PAUSE 200
SEROUT 0, Baudmode, [noparse][[/noparse]"?f"] ' clear the LCD
' SEROUT 0, Baudmode, [noparse][[/noparse]"?>3"] 'note new line
' PAUSE 200 ' allow time for the new special characters to be downloaded.
AGN:
FOR N = 0 TO 7 ' for seven different temperatures
SEROUT 0, Baudmode, [noparse][[/noparse]"?f"] ' clear the LCD
SEROUT 0, Baudmode, [noparse][[/noparse]"?>3"]' big num 3 format
PAUSE 200 ' allow time for the new special characters to be downloaded.
GOSUB MeasTemp
IF T_10 >= $8000 THEN ' if sign bit is one, its negative
T_10 = -T_10
TWhole = T_10 / 10 ' separate off whole and fractional parts
TFract = T_10 // 10
IF TWhole > 9 THEN ' -10 to -99
SEROUT 0, Baudmode, [noparse][[/noparse]"-"]
Digit = TWhole / 10
SEROUT 0, Baudmode, [noparse][[/noparse]DEC1 Digit]
Digit = TWhole // 10
SEROUT 0, Baudmode, [noparse][[/noparse]DEC1 Digit]
ELSE ' -0.0 to - 9.9
SEROUT 0, Baudmode, [noparse][[/noparse]"?y0?x04"]
SEROUT 0, Baudmode, [noparse][[/noparse]"-"]
Digit = TWhole
SEROUT 0, Baudmode, [noparse][[/noparse]DEC1 Digit]
ENDIF
ELSE ' its positive
TWhole = T_10 / 10
TFract = T_10 // 10
IF TWhole > 99 THEN ' 100.0 - 999.0
Digit = TWhole / 100
SEROUT 0, Baudmode, [noparse][[/noparse]DEC1 Digit]
TWhole = TWhole // 100
Digit = TWhole / 10
SEROUT 0, Baudmode, [noparse][[/noparse]DEC1 Digit]
Digit = TWhole // 10
SEROUT 0, Baudmode, [noparse][[/noparse]DEC1 Digit]
ELSEIF TWhole > 9 THEN ' 10.0 to 99.0
SEROUT 0, Baudmode, [noparse][[/noparse]"?y0?x02"]
Digit = TWhole / 10
SEROUT 0, Baudmode, [noparse][[/noparse]DEC1 Digit]
Digit = TWhole // 10
SEROUT 0, Baudmode, [noparse][[/noparse]DEC1 Digit]
ELSE
SEROUT 0, Baudmode, [noparse][[/noparse]"?y0?x06"]
Digit = TWhole
SEROUT 0, Baudmode, [noparse][[/noparse]DEC1 Digit]
ENDIF
ENDIF
' now the fractional part
SEROUT 0, Baudmode, [noparse][[/noparse]"."]
SEROUT 0, Baudmode, [noparse][[/noparse]DEC1 TFract]
SEROUT 0, Baudmode, [noparse][[/noparse]"?<"] ' Display "Deg F" in normal text
SEROUT 0, Baudmode, [noparse][[/noparse]"?y1?x17"]
SEROUT 0, Baudmode, [noparse][[/noparse]"Deg"]
SEROUT 0, Baudmode, [noparse][[/noparse]"?y2?x17"]
SEROUT 0, Baudmode, [noparse][[/noparse]" F "]
PAUSE 2500
NEXT
GOTO AGN
MeasTemp:
' This is a stub which returns various values of a temerature T_10
' It is intended to illustrate examples from -99.9 to 999.0
LOOKUP N, [noparse][[/noparse]-123, -42, -8, 1234, 723, 72, 2], T_10
'-12.3, -4.2, -0.8, 123.4, 72.3, 7.2, 0.2
RETURN
IF SignBit = 1 THEN
DEBUG "-", DEC Whole, ".", DEC2 Fract, CR
ELSE
DEBUG DEC Whole, ".", DEC2 Fract, CR
ENDIF
I know this is where the code needs to be changed but what 117 commands do I use???????
Here's the hole code \/ and this is the code to rrun the ph anderson 1 wire controller with a bs2
' {$STAMP BS2}
' {$PBASIC 2.5}
BaudMode CON 84 '9600 True
X VAR Word
Y VAR Word
SignBit VAR Byte
Whole VAR Byte
Fract VAR Byte
DIR7 = 0 ' serial input
DIR8 = 1 ' serial output
OUT8 = 0 ' be sure SerOut pin is stable at zero
PAUSE 1000
DO
AGN:
SEROUT 8, BaudMode, 10, [noparse][[/noparse]"P0", "W0cc", "S044"] 'perform temp meas
' note strong pullup
PAUSE 1100 ' wait for conversion to complete
SEROUT 8, BaudMode, 10, [noparse][[/noparse]"P0", "W0cc", "W0be"] ' send temperature data
SEROUT 8, BaudMode, 10, [noparse][[/noparse]"R0"] ' fetch data
SERIN 7, Baudmode, 1500, TimeOut, [noparse][[/noparse]DEC X.LOWBYTE]
PAUSE 100
SEROUT 8, BaudMode, 10, [noparse][[/noparse]"R0"] ' fetch data
SERIN 7, Baudmode, 1500, TimeOut, [noparse][[/noparse]DEC X.HIGHBYTE]
PAUSE 100
' now do the calculations
SignBit = X / 256 / 128
IF SignBit = 1 THEN ' its negative
X = X ^ $ffff + 1 ' take the two's comp
ENDIF
' multiply by 6.25 - This is 100 * Tc
Y = X / 4 ' 0.25
X = X * 6 + Y
Whole = X / 100
Fract = X // 100
IF SignBit = 1 THEN
DEBUG "-", DEC Whole, ".", DEC2 Fract, CR
ELSE
DEBUG DEC Whole, ".", DEC2 Fract, CR
ENDIF
PAUSE 1000 ' wait 1 secs
LOOP
TimeOut:
DEBUG "Timeout Error", CR
GOTO AGN
AND IT WORKS GREAT ON THE COMPUTER!!!!!
For N = 0 to 25
SerOut 0, Baudmode, [noparse][[/noparse]"?x00?y1"] ' locate cursor to beginning of line 1
SerOut 0, Baudmode, [noparse][[/noparse]Dec N, "?t", Hex N, "?t"] ' display N in Dec and Hex
SerOut 0, Baudmode, [noparse][[/noparse]Dec ByteVar, "?n"]
SerOut 0, Baudmode, [noparse][[/noparse]Dec WordVar, "?n"] ' display a word
ByteVar = ByteVar + 1
WordVar = WordVar + 1
For I = 1 to 4
make sure the pin numbers and baudmodes are for the lcd.
SerOut 0, Baudmode, [noparse][[/noparse]"?f,?a"]···· OR···· SerOut 0, Baudmode, [noparse][[/noparse]"?f", "?a"]
SerOut 0, Baudmode, [noparse][[/noparse]Dec Whole, ]
Post Edited (L_Gaminde) : 5/2/2009 5:44:49 PM GMT
> ENGINE TEMP 114.8
> AIR TEMP 79.2
> WATER TEMP 76.6
When the program runs it will post 1 at a time on its correct row and then gets to clear screen and home cursor and starts over. My question now is how to make the Sensor names stay on all the time and just the temps update. Do I need to like store them in data and pull it up before every reading or like store it as a custom scrren to the lcd eeprom or something like that. I am a big rookie when it comes to something like this. I thouhgt I could only store 7 custom characters to the lcd eeprom so don't think thats right. Or should I just write what I want like [noparse][[/noparse]" Water Temp"] and then make it to where it will skip spaces before it posts the temp. Like this > [noparse][[/noparse]"?x09",
SEROUT 0, 84, [noparse][[/noparse]" WATER TEMP "]
SEROUT 0, Baudmode, [noparse][[/noparse]"?x09", REP "-"\x.BIT15, DEC ABS x/5, ".", DEC1 ABS x]
PAUSE 400
SEROUT 0, Baudmode, [noparse][[/noparse]"?x09", REP "-"\x.BIT15, DEC ABS x/5, ".", DEC1 ABS x]
PAUSE 400
Scratch this 1 that didn't work..
?x## Position cursor on x column, (two characters are required), first column is column 0
?y# Position cursor at y row, first row is row 0, one digit only (no leading zero)
if temp>99 then displaytemp=" "+temp
else displaytemp=temp
serout blah,blah, "water: ",temp
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Callsign: NQ5I
Interests: Robotics, Embedded Systems, Computers, Machining
Here's your demo slighly modified.
' {$STAMP BS2}
' {$PBASIC 2.5}
BaudMode CON 84 '9600 True
X VAR Word
DIR7 = 0 ' serial input
DIR8 = 1 ' serial output
OUT8 = 0 ' be sure SerOut pin is stable at zero
PAUSE 1000 ' allow to stabilize
SEROUT 0, BaudMode, [noparse][[/noparse]"?G420"] ' Sets geometry of LCD as 4X20
PAUSE 200 ' pause to allow LCD EEPROM to program
'SEROUT 0, 84, [noparse][[/noparse]"?BFF"] '100% backlight
SEROUT 0, 84, [noparse][[/noparse]"?B0F"] '15% backlight
'SEROUT 0, 84, [noparse][[/noparse]"?B7E"] '50% baclight
PAUSE 200 ' pause to allow LCD EEPROM to program
SEROUT 0, Baudmode, [noparse][[/noparse]"?f"] ' clear the LCD
DO
BOAT:
SEROUT 8, BaudMode, 10, [noparse][[/noparse]"P0", "W0cc", "S044"] 'perform temp meas
PAUSE 1100 ' wait for conversion to complete
SEROUT 8, BaudMode, 10, [noparse][[/noparse]"P0", "W0cc", "W0be"] ' send temperature data
SEROUT 8, BaudMode, 10, [noparse][[/noparse]"R0"] ' fetch data
SERIN 7, Baudmode, 1500, TimeOut, [noparse][[/noparse]DEC X.LOWBYTE]
PAUSE 100
SEROUT 8, BaudMode, 10, [noparse][[/noparse]"R0"] ' fetch data
SERIN 7, Baudmode, 1500, TimeOut, [noparse][[/noparse]DEC X.HIGHBYTE]
PAUSE 100
x = x + 160 * 9 / 5 ' covert to F
SEROUT 0, BaudMode, [noparse][[/noparse]"?y1?x00"] ' cursor at line 1, col 0
PAUSE 500
SEROUT 0, 84, [noparse][[/noparse]" Engine Temp "]
SEROUT 0, Baudmode, [noparse][[/noparse]"?x14", REP "-"\x.BIT15, DEC ABS x/5, ".", DEC1 ABS x]
PAUSE 400
LOOP
TimeOut:
DEBUG "Fail", CR
GOTO BOAT:
Post Edited (plankton) : 6/14/2009 8:20:27 PM GMT