The button alternate the two temperatures (small and big). Full working code ! Thanks for support ! Regards !
The button alternate the two temperatures (small and big). Full working code ! Thanks for support ! Regards !
Last edited by fratello; - 24th May 2011 at 19:35. Reason: Add pictures...
Congratulations !
Looks Great !
Now tell us all about it, is that a PIC16F648A or PIC16F628A ?
What kind of display is that ? Where can get one and for about how much ?
I see the making of an article in this thread.
Oh to all who read this post, if you are willing, please rename your code from .bas to .txt becauseWindows XP and up requires you to download and rename and will not open it first. That is my experience on 3 different computers. Win 98 does not care unless you have loaded VB and then it too does not like it.
Ahhhgh: My dumb self, I see nokia 3310, first line of O. P.
Last edited by Archangel; - 25th May 2011 at 02:39. Reason: Ahhhgh
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Thanks !
It's PIC 16F628A ("downgrade" from 16F648A - the reason of this topic) ; display it's from Nokia 3310. Regards !
I re-wrote the code, in attempt to having BIGGER numbers on display !
This is the code :
Each number is made - in FastLCD- like in this example :Code:@ DEVICE pic16F648A, INTrc_osc, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_OFF, LVP_OFF, CPD_OFF, PROTECT_OFF Define NO_CLRWDT 1 DEFINE OSC 4 TRISB = %00011100 'portB configuration 0=out 1=in TRISA = %10100000 'portA configuration PortA = %11100000 CMCON = 7 VRCON = 0 INTCON = 0 OPTION_REG=%00000111 'weak pullups on, TMRO prescale = 256 DQ2 VAR PORTB.3 RST var PortA.4 'pin 3 Output reset display SDIN var PortA.3 'pin 2 Output master data out SCK var PortA.2 'pin 1 Output Spi clock DQ var PortB.2 'pin 18 I/O DQ DS18b20 D_C var PortB.0 'pin 6 Output command/data sel. register Temperature Var Word TempC Var Word Sign Var Word Float Var Word Dummy Var Byte LcdReg var byte x var byte y var byte z var byte Offset var byte Char var byte a var byte PosX VAR Byte PosY VAR Byte Chr VAR Byte LcdData VAR Byte Cursor Var Byte '------------------------------------------------------------------------------- Data @0,$FC, $FE, $FE, $06, $00,_ $00, $06, $FE, $FE, $FC,_ $7F, $FF, $FF, $C0, $00,_ $00, $C0, $FF, $FF, $7F,_ ; //0 $00, $00, $18, $1C, $FE,_ $FE, $FE, $00, $00, $00,_ $00, $00, $00, $C0, $FF,_ $FF, $FF, $C0, $00, $00,_ ; //1 $00, $3C, $3E, $3E, $06,_ $86, $FE, $FE, $7C, $00,_ $00, $E0, $F0, $FC, $FF,_ $CF, $C7, $C1, $C0, $00,_ ; //2 $00, $1C, $1E, $9E, $86,_ $86, $FE, $FE, $FC, $00,_ $00, $78, $F8, $F9, $C1,_ $C1, $FF, $FF, $7E, $00,_ ; //3 $00, $00, $F0, $FE, $7E,_ $FE, $FE, $FE, $00, $00,_ $00, $3F, $3F, $37, $30,_ $FF, $FF, $FF, $30, $00 ; //4 Data @101, $00, $FE, $FE, $FE, $C6,_ $00, $C6, $C6, $C6, $86,_ $71, $F1, $F1, $C0, $00,_ $00, $C0, $FF, $FF, $7F,_ ; //5 $00, $FC, $FE, $FE, $C6,_ $C6, $DE, $DE, $9C, $00,_ $00, $7F, $FF, $FF, $C0,_ $C0, $FF, $FF, $7F, $00,_ ; //6 $00, $06, $06, $06, $86,_ $E6, $FE, $7E, $1E, $00,_ $00, $80, $F0, $FE, $3F,_ $07, $01, $00, $00, $00,_ ; //7 $00, $7C, $FE, $FE, $86,_ $86, $FE, $FE, $7C, $00,_ $00, $7E, $FF, $FF, $C1,_ $C1, $FF, $FF, $7E, $00,_ ; //8 $00, $FC, $FE, $FE, $86,_ $86, $FE, $FE, $FC, $00,_ $00, $78, $F9, $F9, $C1,_ $C1, $FF, $FF, $7F, $00 ; //9 '------------------------------------------------------------------------------- pause 1000 RST = 1 PortB = 0 LcdReg = %00100001 'LCD Extended Commands. call PrintCtrlLcd LcdReg = $C5 'Set LCD Vop (Contrast). call PrintCtrlLcd LcdReg = %00000110 'Set Temp coefficent. call PrintCtrlLcd LcdReg = %00010011 'LCD bias mode 1:48. call PrintCtrlLcd LcdReg = %00100000 'LCD Standard Commands, Horizontal addressing mode. call PrintCtrlLcd LcdReg = %00001100 'LCD in normal mode call PrintCtrlLcd call CursorHome Gosub LCD_Clear Main: ' Sensor 1 OWOut DQ, 1, [$CC, $44] OWOut DQ, 1, [$CC, $BE] OWIn DQ, 2, [temperature.byte0, temperature.byte1] If Temperature.15 then Temperature= ~Temperature +1 sign="-" Endif Dummy = 625 * Temperature TempC = DIV32 10 TempC = (Temperature & $7FF) >> 4 Float = ((Temperature.Lowbyte & $0F ) * 25 )>>2 Temperature = TempC*100 + Float LcdReg = %10000000 ' cursor X call PrintCtrlLcd LcdReg = %01000000 ' cursor Y call PrintCtrlLcd Char = (temperature dig 1) Call PrintChar LcdReg = %10000000 + 5 ' cursor X call PrintCtrlLcd LcdReg = %01000000 ' cursor Y call PrintCtrlLcd Char = (temperature dig 1 )+ 1 Call PrintChar LcdReg = %10000000 ' cursor X call PrintCtrlLcd LcdReg = %01000001 ' cursor Y call PrintCtrlLcd Char = (temperature dig 1 )+ 2 Call PrintChar LcdReg = %10000000 + 5 ' cursor X call PrintCtrlLcd LcdReg = %01000001 ' cursor Y call PrintCtrlLcd Char = (temperature dig 1 )+ 3 Call PrintChar goto Main '============================================================ CursorHome: LcdReg = %10000000 ' cursor Home call PrintCtrlLcd LcdReg = %01000000 ' cursor Home call PrintCtrlLcd return PrintChar: offset = Char * 5 for a = 1 to 5 read offset, LcdReg call PrintDataLcd offset = offset + 1 next a LcdReg = 0 call PrintDataLcd return PrintCtrlLcd: D_C = 0 PrintDataLcd: for x = 1 to 8 SDIN = LcdReg.7 SCK = 1 LcdReg = LcdReg << 1 SCK = 0 next x D_C = 1 return Lcd_Clear: FOR Cursor = 0 TO 5 PosX=0:PosY=Cursor:GOSUB Lcd_GotoXY HIGH D_C LcdData = 0 FOR Chr = 1 TO 84 GOSUB LCD_ByteOut NEXT Chr NEXT Cursor RETURN LCD_GotoXY: LOW D_C LcdData=%01000000 | PosY :GOSUB LCD_ByteOut LcdData=%10000000 | PosX :GOSUB LCD_ByteOut RETURN LCD_ByteOut: SHIFTOUT SDIN,SCK,1,[LcdData] RETURN
But the results are...strange, like this :
Please, need advice...Thanks in advance !!!
LE : I use now 16F648A (more EEprom). Attaching ISIS simulating.
Based on this post : http://www.picbasic.co.uk/forum/show...7847#post87847 - Thank You, scalerebotics !!! I re-x-wrote the code. Now I have good results ! But.... HOW can I display all the three digits of var.temperature ?!? Give me a clue, please !!!
Now I have only dig 1 on displayCode:;********************************************************************************************** ; BIG FONTS - need improvements !!! @ DEVICE pic16F628A, INTRC_OSC, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_ON, LVP_OFF, CPD_OFF, PROTECT_OFF Define NO_CLRWDT 1 DEFINE OSC 4 TRISB = %00011100 'portB configuration 0=out 1=in TRISA = %10100000 'portA configuration PortA = %11100000 CMCON = 7 VRCON = 0 INTCON = 0 OPTION_REG=%00000111 'weak pullups on, TMRO prescale = 256 Lcd_DC var PortB.0 Lcd_SDA var PortA.3 Lcd_RST var PortA.4 Lcd_CLK var PortA.2 DQ var PortB.2 i var Byte j var Word k var Byte Nc var Byte PosX var Byte PosY var Byte LcdStr var Byte [28] Lcd_Data var Byte CharNum var Byte FA VAR BYTE[5] 'upper left of character FB VAR BYTE[5] 'upper right of character FC VAR BYTE[5] 'lower left of character FD VAR BYTE[5] 'lower right of character LcdReg var Byte x var Byte y var Byte cursor var Byte Temperature Var Word TempC Var Word Sign Var Word Float Var Word Dummy Var Byte DS18B20_12bit CON %01111111 ' 750ms, 0.0625°C 'initialize display----------------------------------------------- pause 250 '----------------------------------------------------------------- 'Initialize LCD, run 1st this! Low Lcd_RST 'Reset LCD (HW reset) pause 100 High Lcd_RST 'Release Reset Low Lcd_DC 'Command/Data Lcd_Data= $21: GOSUB Lcd_SentByte ' LCD EXTENDED COMMANDS Lcd_Data= $c2: GOSUB Lcd_SentByte ' SET LCD Vop (CONTRAST) era c8 Lcd_Data= $06: GOSUB Lcd_SentByte ' SET TEMP COEFFICENT Lcd_Data= $13: GOSUB Lcd_Sentbyte ' LCD BIAS MODE Lcd_Data= $20: GOSUB Lcd_Sentbyte ' LCD STANDARD COMMANDS Lcd_Data= $09: GOSUB Lcd_Sentbyte ; all on pause 1000 Lcd_data= $08: gosub lcd_sentbyte ' lcd blank Lcd_Data= $0c: GOSUB Lcd_sentbyte ' LCD IN NORMAL MODE gosub Lcd_Clear 'Clear contents of screen Low Lcd_DC Pause 100 '================================================== ' Init Sensor 1 OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_12bit] OWOut DQ, 1, [$CC, $48] ' Start temperature conversion OWOut DQ, 1, [$CC, $B8] OWOut DQ, 1, [$CC, $BE] Pause 50 OWIn DQ, 2, [temperature.byte0, temperature.byte1] '================================================== main: pause 100 sign = " " ' Start temp.conv.Sensor1 OWOut DQ, 1, [$CC, $44] OWOut DQ, 1, [$CC, $BE] OWIn DQ, 2, [temperature.byte0, temperature.byte1] If Temperature.15 then Temperature= ~Temperature +1 sign="-" Endif Dummy = 625 * Temperature TempC = DIV32 10 TempC = (Temperature & $7FF) >> 4 Float = ((Temperature.Lowbyte & $0F ) * 25 )>>2 Temperature = TempC*100 + Float LcdStr(2) = 48 + TEMPERATURE dig 1 LcdStr(1) = 48 + TEMPERATURE dig 2 LcdStr(0) = 48 + TEMPERATURE dig 3 Nc=2 Gosub Lcd_SentString gosub afisare goto main '================================================== afisare: High Lcd_DC LcdReg = %10000000 ' cursor X call PrintCtrlLcd LcdReg = %01000000 ' cursor Y call PrintCtrlLcd SHiftOUT Lcd_SDA , Lcd_CLK , 1, [ FA(0),FA(1),FA(2),FA(3),FA(4)] 'upper left LcdReg = %10000000 + 5 ' cursor X call PrintCtrlLcd LcdReg = %01000000 ' cursor Y call PrintCtrlLcd SHiftOUT Lcd_SDA , Lcd_CLK , 1, [ FB(0),FB(1),FB(2),FB(3),FB(4)] 'upper right LcdReg = %10000000 ' cursor X call PrintCtrlLcd LcdReg = %01000001 ' cursor Y call PrintCtrlLcd SHiftOUT Lcd_SDA , Lcd_CLK , 1, [ FC(0),FC(1),FC(2),FC(3),FC(4)] 'lower left LcdReg = %10000000 + 5 ' cursor X call PrintCtrlLcd LcdReg = %01000001 ' cursor Y call PrintCtrlLcd SHiftOUT Lcd_SDA , Lcd_CLK , 1, [ FD(0),FD(1),FD(2),FD(3),FD(4)] 'lower right Low Lcd_DC Return '================================================== Lcd_Clear: For cursor = 0 to 5 PosX=0:PosY=Cursor:Gosub Lcd_GotoXY High Lcd_DC For i= 1 to 84 Lcd_Data=0:Gosub Lcd_SentByte Lcd_Data=0:Gosub Lcd_SentByte Next i Next cursor Return '================================================== Lcd_GotoXY: Low Lcd_DC Lcd_Data=%01000000 | PosY :Gosub Lcd_SentByte 'Y Lcd_Data=%10000000 | PosX :Gosub Lcd_SentByte 'X Return '================================================== Lcd_SentByte: SHiftOUT Lcd_SDA , Lcd_CLK , 1, [ Lcd_Data ] Return '================================================== Lcd_SentString: ;For k=0 to Nc-1 FOR K=0 TO NC Lcd_Data=LcdStr(k) Gosub Lcd_SentChar next k Return '================================================== Lcd_SentChar: lookdown Lcd_data,[" !\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],CharNum Lcd_data = CharNum + 32 SELECT CASE lcd_data Case 48 ' a zero FA(0)=$00:FA(1)=$FC:FA(2)=$FE:FA(3)=$FE:FA(4)=$06 ' // 0 FB(0)=$06:FB(1)=$FE:FB(2)=$FE:FB(3)=$FC:FB(4)=$00 ' // 0 FC(0)=$00:FC(1)=$7F:FC(2)=$FF:FC(3)=$FF:FC(4)=$C0 ' // 0 FD(0)=$C0:FD(1)=$FF:FD(2)=$FF:FD(3)=$7F:FD(4)=$00 ' // 0 Case 49 ' a one FA(0)=$00:FA(1)=$00:FA(2)=$18:FA(3)=$1C:FA(4)=$FE ' // 1 FB(0)=$FE:FB(1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1 LcdReg = LcdReg << 1 LCD_CLK = 0 next x LCD_DC = 1 return END....
Hope not disturb !
This is my last variant of dual thermometer.
Last edited by fratello; - 1st June 2011 at 20:30. Reason: ...maybe someone want the code...
Bookmarks