Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

LCD won't display?

Status
Not open for further replies.

MrDEB

Well-Known Member
Have checked and rechecked all my connections but still no "HELLO WORLD"
What am I missing? Sorry if I posted code wrong?
ANY SUGGESTIONS for this simple task?

Device = 18F1320
Clock = 8 // 8MHz clock
Config OSC = INTIO2

// some LCD options...
#option LCD_DATA = PORTB.0 // Assign the LCD connections
#option LCD_EN = PORTB.5 //
#option LCD_RS = PORTB.4 //

// import LCD library...
Include "IntOSC8.bas"
Include "LCD.bas"
Include "convert.bas"
Dim Variable As Word

// Start Of Program...
DelayMS(150) // Let the LCD warm up
LCD.Cls // Clear the LCD screen
LCD.WriteAt(1,1,"Hello World")
// Send some text to the LCD
Variable = 0 // Clear the "Variable" register
While True
Inc(Variable) // Increment the "Var1" register
// Convert to a string,
// and always display 5 characters
LCD.WriteAt(2,1,Convert.DecToStr(Variable,5))

DelayMS(1000) // Delay for 1 second
Wend
 

Attachments

  • PID sch.png
    PID sch.png
    36.8 KB · Views: 133
You can't put LCD.WriteAt(2,1,Convert.DecToStr(Variable,5)) It's LCD.WriteAt(2,1,DecToStr(Variable))

Code:
Device = 18F1320
Clock = 8 // 8MHz clock
Config OSC = INTIO2

// some LCD options...
#option LCD_DATA = PORTB.0 // Assign the LCD connections
#option LCD_EN = PORTB.5 //
#option LCD_RS = PORTB.4 //

// import LCD library...
Include "IntOSC8.bas"
Include "utils.bas"    // Your need this 
Include "LCD.bas"
Include "convert.bas"
Dim Variable As Word
SetAllDigital         //????? set's pins to output
// Start Of Program...
DelayMS(150) // Let the LCD warm up
LCD.Cls // Clear the LCD screen
LCD.WriteAt(1,1,"Hello World")
// Send some text to the LCD
Variable = 0 // Clear the "Variable" register
While True
Inc(Variable) // Increment the "Var1" register
// Convert to a string,
// and always display 5 characters
LCD.WriteAt(2,1,DecToStr(Variable))

DelayMS(1000) // Delay for 1 second
Wend

You forgot to Include "utils.bas" // Your need this to set Digital with SetAllDigital //????? set's pins to output
 
Last edited by a moderator:
I used a sample code that I think I had working before but different chip?
Why do some have no INCLUDES and other code doing the same thing have several INCLUDES.?
will try the new code out.
Need to figure out where to put (write) different headings for a PID controller. Going one step at a time. Have found several PID controllers that were bought but failed to work as planned.
 
NO WORKIE?
Going to recheck wiring, perhaps the 330 resistor needs to be smaller/ larger?
change out the PIC
Tried adjusting the pot but to no avail?
will get back to you.
perhaps a basic LCD program to just debug and be failsafe---lol
 
Well the reason is simple some code is not using all the library's and some is.

Include "utils.bas" is needed if you don't want to set pin as I/O if you set them your self it's not needed and some times with some chips it doesn't work

so most time I don't use it.

Make you template like this one
Code:
Device = 18F1320   //Change to match Chip your using 
Clock = 8 // 8MHz clock   set to what Mhz your using
Config OSC = INTIO2  //Set for OSC or FOSC 
 
//   #options here

 
// Include here
Include "IntOSC8.bas"   // Just comment out whats not needed 
Include "utils.bas"    // Your need this 
Include "LCD.bas"
Include "convert.bas"

////Dims here



/// Port setup here 



//// Main code here
 
do you have mclr pulled up to vdd with a resistor ? I no the code works I even posted a video showing you what it looked like
 
The grd and Vcc on pin 3 of the LCD was not connected (I started on this board about 8-10 months ago and just now getting back to it)
I connected missing connections, adjusted the contrast and BAM I have text!!
THANKS
Now to see what all the numbers in the LCD statement stand for. I know they move the text around to duifferent lines.
Using a 4 line LCD
 
Good to see it working we would never have done it with out tom and jerry LOL just a joke
 
You mean Frick and Frack?? LOL
Now on to inputting the temp program.
Going to continue with designing a PID.
Been contemplating the code as I posted eleswhere and was critized that it won't work. Wasn't actual code but an idea of how the code will flow.
Need to implement how to increment DESIRED TEMP. Using two pushbuttons (1's and 10's) plus up/down. Looking over the Geek Clock code as example.
will post a first version of schematic when done converting to DIPTRACE.
 
MrDeb if you keep it 140 to 141 I bet the steak will taste the same LOL. A dang On at 140 off at 141 would be close enough

And I would seared the meat at high temp before trying this.
 
Now to display temps

Using the DS18B20 .bas code and the LCD code from yesterday.
Almost got it but won't compile due to syntax error when using the LCD instead of the usart.
'
device and clock
Device = 18f1320




'*********************************************************************
'Compiler directives like oscillator settings
Clock = 8 // 8mhz clock
config OSC=INTIO2

'*********************************************************************
'#Options for include statements - must be before include statements

// some LCD options...
#option LCD_DATA = PORTb.0 // Assign the LCD connections
#option LCD_EN = PORTb.5 //
#option LCD_RS = PORTb.4 //



'*********************************************************************
'Includes

// import modules...
Include "DS18B20.bas" //temperature module
Include "convert.bas"
Include "usart.bas" //usart module
Include "LCD.bas" //LCD module if not using usart
include "intOSC8.bas" //osc module
include "utils.bas"







'*********************************************************************
'Dimension Statements (variable and constants

Dim
TempA As ShortInt, //temp a id farienheight
TempB As Word //temp b id metric
Dim Variable As Word
dim index as byte

'*********************************************************************
'Subroutines and functions


'Notice Function name, code steps, function end. Indenting shows what's contained 'inside the function or subroutine

'Note: If any subroutine calls another subroutine or function, the called sub or
' function must be placed first in the listing

'*********************************************************************
'Program initialization - only gets done once. Define initial variable conditions and etc.

'Note: The above happens only once when the program initializes.


'*********************************************************************
'Main program loop. This continues forever
//USART
//333333333333333333333333333333333333333333333333333
//SetBaudrate(br19200) // for usart
SetPin(PORTa.3) // set up port pin ra.3 as input of temp sensor

// Find() will search the bus for a single DS1820 device
// and load its ROM ID into the DS1820 public variable RomID - you
// could do this manually. For example, RomID = MyRomID...

If DS18B20.Find Then //locate a sensor
While true // convert date to readable format
Convert
GetTemp(TempA, TempB) // get readable data to display
LCD.WriteAt(2,1,convert.(DecToStr(TempA),".",DecToStr(TempB,4), " C", ) //display data SYNTAX eRROr
DelayMS(1000)
Wend
Else
USART.Write("No device found", 13, 10)
EndIf
//33333333333333333333333333333333333333333333333333333333333333
//LCD
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DelayMS(150) // Let the LCD warm up
LCD.Cls // Clear the LCD screen
LCD.WriteAt(1,1,"Hello World") // Send some text to the LCD
Variable = 0 // Clear the "Variable" register
While True
Inc(Variable) // Increment the "Var1" register
// Convert to a string,
// and always display 5 characters
LCD.WriteAt(2,1,Convert.DecToStr(TempA))

DelayMS(1000) // Delay for
wend
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx



'Note: the above goes on forever. This is the main program and all action
' is directed from within this loop
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 
Checking if probe is working

Using the following code, I got the usart to display in C only along w/ ROM ID #
BUT the temp is wrong?
probe in ice water bath and reads 10c not 0c
been fiddeling w/ conversion (*128, was 256)
This is using the Junebug only (have the LCD connected to another board instead for later but figure I would verify that the probe actually works.
Tried several code versions but this is the only one that works?
After getting this sorted out, on to getting it to display on LCD
This code was done by Pommie



Device = 18F1320
Clock = 8 // 8MHz clock
Config OSC = INTIO2, WDT = OFF, LVP = OFF

Include "OW.bas"
Include "USART.bas"
Include "DS18B20.bas"
Include "CONVERT.bas"

Dim Temperature As Word
Dim i As Byte

OSCCON = $72 // select 8MHz internal clock
ADCON1 = $7f //all digital
TRISA.3=0 //A3 output
PORTA.3=1 //and high
SetBaudrate(br9600)
OW.SetPin(PORTA.4)
While true
If OW.Reset Then
OW.WriteByte(owReadROM) //Skip ROM
USART.Write("Rom = ")
For i = 0 To 7
USART.Write(HexToStr(OW.ReadByte()))
Next
OW.Reset
OW.WriteByte(owSkipROM) //Skip ROM
OW.WriteByte($44) //Convert
OW.Reset
OW.WaitForHigh //wait for convert to finish
OW.Reset
OW.WriteByte(owSkipROM) //Skip Rom
OW.WriteByte($be) //Read Scratch Pad
Temperature=OW.ReadByte()
Temperature=(Temperature+OW.ReadByte()*128)changing this formula
USART.Write(" Temperature = ",DecToStr(Temperature/4))
If (Temperature And 1) = 1 Then
USART.Write(".5")
EndIf
USART.Write("C",13,10)
Else
USART.Write("No device found", 13, 10)
EndIf
DelayMS (100)
Wend
End
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top