Thanks for that Steve.
I'll start with 200ohms. Just to double check that goes to the anode pin 15 right?
Dave (Mr Windy).
Printable View
Thanks for that Steve.
I'll start with 200ohms. Just to double check that goes to the anode pin 15 right?
Dave (Mr Windy).
It does not matter, 15 or 16.
Finaly managed to find five minutes to connect the back-light up using a 150ohm
resistor, however:
Before connection I had 4 lines of text. Then I connected the back-light which came on a nice blue colour but the text vanished. I then disconnected the back-light,the text didn't reappear, reloaded the program still no text (with or without the back-light on). I then loaded the program into my other 16F684 with the same outcome:(
Could it be the DATAUS number again?
Or something more worrying.
Dave
Hmmm, from where do you pull the current for the backlight and is that supply rated/capable of supplying the current? Measure the voltage as you turn on the backlight and see if it sags.
Do you have a PAUSE at the beginning of the program to allow the LCD to boot up properly before writing to it? Something like PAUSE 1000 or whatever....
/Henrik.
Hi Henrik
I've measured the voltage, it doesn't blip from 4.6v, even when the back-light is switched off - on.
I added the pause.Still no text showing.
Here's the program:
DaveCode:ANSEL = %00000000 'Disable analog select so ports work as digital i/o.
CMCON0 = %00000111 'Disable analog comparators.
TRISA = %00000000 'Set PORTA as OUTPUT.
PORTA = %00000000 'Set PORTA pins all low.
TRISC = %00000000 'Set PORTC as OUTPUT.
PORTC = %00000000 'Set PORTC pins all low.
DEFINE LCD_DREG PORTC 'PORTC.0 WILL CONNECT TO DB4, PORTC3 TO DB7
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTC
DEFINE LCD_RSBIT 4 'PORTC.4 CONNECT TO LCD PIN4
DEFINE LCD_EREG PORTC
DEFINE LCD_EBIT 5 'PORTC.5 CONNECT TO LCD PIN6
DEFINE LCD_BITS 4
DEFINE LCD_LINES 4
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 75
DEFINE OSC 4
MAIN:
PAUSE 1500
LCDOUT $FE,1,"*Hello WORLD*!"
LCDOUT $FE,$C0,"I't WORKS!"
LCDOUT $FE,$94,"I't WORKS!"
LCDOUT $FE,$d4,"Oh dear it stopped!"
GOTO MAIN
Hi Dave,
Try adding a LED to an unused pin and blink it a few times at start-up. Just to verify that the PIC is still actually executing code. Are you using an extarnal crystal or are you running on the internal oscillator?
If it appears to not executing code and you're using an external source for the osciallator then check and double check that.
/Henrik.
Hi Henrik,
Will do.Quote:
Try adding a LED to an unused pin and blink it a few times at start-up. Just to verify that the PIC is still actually executing code.
Internal oscillator.Quote:
Are you using an extarnal crystal or are you running on the internal oscillator?
It does seem strange that the PIC wrote the test lines to the LCD then stopped when the back-light was fired up. It would be nice if it were something not too serious.
Dave
Hi Henrik,
I've added the LED and pause to the program and no (unless I've made another mistake) the LED doesn't blink,so program not / stopped running? Program doesn't 'run' with the back-light turned off either.
Here's the code:
DaveQuote:
ANSEL = %00000000 'Disable analog select so ports work as digital i/o.
CMCON0 = %00000111 'Disable analog comparators.
TRISA = %00000000 'Set PORTA as OUTPUT.
PORTA = %00000000 'Set PORTA pins all low.
TRISC = %00000000 'Set PORTC as OUTPUT.
PORTC = %00000000 'Set PORTC pins all low.
DEFINE LCD_DREG PORTC 'PORTC.0 WILL CONNECT TO DB4, PORTC3 TO DB7
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTC
DEFINE LCD_RSBIT 4 'PORTC.4 CONNECT TO LCD PIN4
DEFINE LCD_EREG PORTC
DEFINE LCD_EBIT 5 'PORTC.5 CONNECT TO LCD PIN6
DEFINE LCD_BITS 4
DEFINE LCD_LINES 4
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 75
DEFINE OSC 4
MAIN:
PAUSE 500
HIGH PORTA.5
PAUSE 500
LOW PORTA.5
PAUSE 500
HIGH PORTA.5
PAUSE 500
LOW PORTA.5
PAUSE 1500
LCDOUT $FE,1,"*Hello WORLD*!"
LCDOUT $FE,$C0,"I't WORKS!"
LCDOUT $FE,$94,"I't WORKS!"
LCDOUT $FE,$d4,"Oh dear it stopped!"
PAUSE 500
HIGH PORTA.5
PAUSE 500
LOW PORTA.5
PAUSE 500
HIGH PORTA.5
PAUSE 500
LOW PORTA.5
PAUSE 50
GOTO MAIN
Well I changed the LCD_DATAUS n from 75 to 150 and the led fired up on PORTA.5, still no text on the LCD though.
Dave
I would not think DATUS would cause the LED not to work...
Have you adjusted the contrast POT after connecting the back light? Maybe it is just washed out ?
Hi mackrackit,
Yes, I've even disconnected the back light but can't see any text now, it hasn't reappeared.Quote:
Have you adjusted the contrast POT after connecting the back light? Maybe it is just washed out ?
Dave
I've cracked it...........!!!.....Yippeee.
PIN 5 onto LCD from PIC loose R/W.
Henrik, mackrackit, really sorry to have caused a problem.
The display looks great, bright but not too bright and the text is as clear as clear.
:):):)Dave
If I only had a dime for everytime something like that has happened to me :)
:)Quote:
If I only had a dime for everytime something like that has happened to me
I don't think it'll be my last either...;)
Really pleased it's going though.
So a good place to start and get a grip / understanding of LCD display characters would be that link you posted earlier:
Interfacing an LCD with a project opens up so many possibilities, be it just instructions right through to displaying live information. I suspect it's not going to be easy but I'd like to get a grip on LCD's: They're seriously...:cool:
Dave
Yes, that link will show you how to do custom characters.
You will also want to look in the manual about how to place a normal character anyplace on the display along with different things that can be done with the cursor.
I'm on it....
See you tomorrow.
Dave
I had a go at loading a couple of custom characters with no success, so I thought I'd make my name move across the screen. Here's a part of the program.
The trouble is, on the third line down of the LCD (first square) my name also appears there. Could I when trying to load a custom character have inadvertently done something to the CGRAM setting? I then thought maybe it's the cursor so I turned that off with no joy, name moves across the screen still and also 1'st square third line.
Nice work on the website by the way.Code:MAIN:
pause 1000
LCDOUT $FE,$0C 'Cursor off
PAUSE 50
LCDOUT $FE,1," *"
pause 500
LCDOUT $FE,1," *D"
pause 500
LCDOUT $FE,1," *DA"
PAUSE 500
LCDOUT $FE,1," *DAV"
PAUSE 500
LCDOUT $FE,1," *DAVE"
Dave
Part of the problem might be the 21 spaces on a 20 character screen??
Post you custom character code and we will see whats up.
Hi mackrackit,
Oh dear, I can't even count up to 20 now:(
I've been working on my HEX today, maybe that explains it:eek:
Working a treat now thanks, 'again'.
It's not mine it's Darrel Taylor's, from that link you posted. It's the battery symbol.Quote:
Post you custom character code and we will see whats up.
DaveCode:MAIN:
PAUSE 500
LCDOUT $FE,$78,$06,$0f,$0f,$0f,$0f,$0f,$0f,$00
GOTO MAIN
The LCDOUT character stuff place at the beginning of your code, in the variable area.
Then in your loopCode:LCDOUT $FE,$40,$06,$0f,$0f,$0f,$0f,$0f,$0f,$00 'This is the first character #0
'The first place in the RAM is $40
'The next character would start with $48
VARS
DEFINES
...
Code:MAIN:
PAUSE 500
LCDOUT $FE,1,0 'First character
LCDOUT $FE,1,1 'Second character if you have one
GOTO MAIN
Cheers mackrackit,
Things slowly starting to filter through. I'll have a look tomorrow.
I love the old LCD though, cracking.
Dvae
Hi mackrackit,
Well I managed to get the program to do what I wanted it to do, namely run through four custom characters then place the four custom characters one in each corner of the display ( program code below).
All the info to do this was found within the LCD link you posted:) However, I can't really see how the CONSTANT:works, what does the 128 part of it mean? I guess it must relate to LCD position HEX 0000 DDRAM Address for a 4 Line LCD but can't relate that to a CGRAM character position.Code:Row1 CON 128
Dave (lovin his LCD).Code:ANSEL = %00000000 'Disable analog select so ports work as digital i/o.
CMCON0 = %00000111 'Disable analog comparators.
TRISA = %00000000 'Set PORTA as OUTPUT.
PORTA = %00000000 'Set PORTA pins all low.
TRISC = %00000000 'Set PORTC as OUTPUT.
PORTC = %00000000 'Set PORTC pins all low.
DEFINE LCD_DREG PORTC 'PORTC.0 WILL CONNECT TO DB4, PORTC3 TO DB7
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTC
DEFINE LCD_RSBIT 4 'PORTC.4 CONNECT TO LCD PIN4
DEFINE LCD_EREG PORTC
DEFINE LCD_EBIT 5 'PORTC.5 CONNECT TO LCD PIN6
DEFINE LCD_BITS 4
DEFINE LCD_LINES 4
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 150
Row1 CON 128
Row2 CON 192
Row3 CON 148
Row4 CON 212
DEFINE OSC 4
LCDOUT $FE,$40,$02,$06,$1a,$1a,$1a,$06,$02,$00 'FIRST CHAR 0 (Battery)
LCDOUT $FE,$48,$06,$0f,$0f,$0f,$0f,$0f,$0f,$00 'Second CHAR 1 (Speaker)
lcdout $FE,$50,$1F,$11,$15,$17,$17,$15,$11,$1F 'Third CHAR 2 (Copywrite)
lcdout $FE,$58,$00,$0a,$0a,$00,$00,$11,$0e,$00 'Fourth CHAR 3 (Smiley)
MAIN:
PAUSE 500
LCDOUT $FE,1,0 'First character
pause 1000
LCDOUT $FE,1,1 'Second character
pause 1000
lcdout $FE,1,2 'Third character
PAUSE 1000
lcdout $fe,1,3 'Fourth Character
pause 1000
LCDOUT $FE,Row1+0,0 'Places CHAR 0 Top LHS of display.
PAUSE 250
lcdout $FE,ROW1+19,1 'Places CHAR 1 Top RHS of display.
PAUSE 250
LCDOUT $FE,Row4+0,2 'Places CHAR 2 Bottom LHS of display.
PAUSE 250
LCDOUT $FE,Row4+19,3 'Places CHAR 3 Bottom RHS of display.
PAUSE 4000
GOTO MAIN
Each position on the display has a number for an "address".
By adding to the constant you can place the character anyplace you want on the display.Code:Row1 CON 128 = $80
Row2 CON 192 = $C0
Row3 CON 148 = $90
Row4 CON 212 = $D0
'All first position on each of the lines
First line third position from the left would be
$83 or 131
Setup a loop adding to the constant and see if you can make something scroll.
Ah right (penny drops):) cheers mackrackit.
Mmm, I'll see what I can do.Quote:
Setup a loop adding to the constant and see if you can make something scroll.
Dave
I'm still working hard on this........!
I know what I need to do to get this to work (on paper as it were, I think I do anyway:eek:). I'm reading and GQQGLing like made to find and learn the programming skill I need to make it work.
If I can't crack it tonight I'll have to ask, tick, tick, tick....must dash.
Dave
Well I did try.......:(
It was getting the LCD to output B0 as a DEC number (LCD location for the smiley) rather than just B0 that foxed me. I tried DEC B0 and a few other things ("."B0..."B0") but still no good. I think (and hope) I was on the right lines though.
Here's my attempt:
DaveCode:BO VAR BYTE 'BYTE 0 Sets position for CHAR 128...+19
LC var byte 'Loop_Count Counts 0 to 19 'positions' across display
LCDOut $FE,$60,$00,$0a,$0a,$00,$00,$11,$0e,$00 'Smiley Face
Pause 500
MAIN
For LC = 0 TO 19
PAUSE 500
LET BO = 128 + LC 'Start at LCD Top LHS then add 1 to move across display
LCDOUT $FE,1,B0,0 'Output the 'Smiley Face' at location B0
PAUSE 500
Next LC
GOTO MAIN
Reallllllly close :)
Made a couple smal changes
But there is still one small problem...Code:LCDOut $FE,$40,$00,$0a,$0a,$00,$00,$11,$0e,$00 'Smiley Face
For LC = 0 TO 19
PAUSE 500
LET BO = 128 + LC 'Start at LCD Top LHS then add 1 to move across display
LCDOUT $FE,1
LCDOUT $FE,BO,0 'Output the 'Smiley Face' at location B0
PAUSE 500
Next LC
GOTO MAIN
I will leave that for you :D
Well I compiled it and it ran........:) Like you say I wasn't a million miles off on this one which is pleasing.
Mmm, I've looked and looked and I can't see one. Was it from the original brief where you said use a CONSTANT and I've used a VARIABLE?Quote:
But there is still one small problem...
Quick question. In the program you made the change of address from $60 to $40, that's because the Custom characters are given memory addresses $40.....$78 (Char 0 - 7) and they must be sequential right? In other words I had Character '0' at address $60 which was a mistake.
Also having the:
Simply clears the display on every loop so the next increment of LC moves the character along one and clears the previous character.Quote:
LCDOUT $FE,1
Dave (Oop's what's next?)
OOPPSS! Now I am the one that can not count. I have a 16x4 I use for testing. It would work for you 20x4 display.
Yes, your were calling the wrong address.Quote:
Quick question. In the program you made the change of address from $60 to $40, that's because the Custom characters are given memory addresses $40.....$78 (Char 0 - 7) and they must be sequential right? In other words I had Character '0' at address $60 which was a mistake.
Quote:
Simply clears the display on every loop so the next increment of LC moves the character along one and clears the previous character.
Can not have a character location after it, only display commands. But for spped you can do this, (a snippet from,,)Code:LCDOUT $FE,1
Code:LCDOUT $FE,1,"THE TEMPERATURE",$FE,$C0,"IS: ",DEC TRESULT,$FE,$90,"BAD READS ",DEC BCS
I will get back to you with something :DQuote:
Dave (Oop's what's next?)
Thanks for that mackrackit, a great help.
As and when mackrackit, we're all busy.:)Quote:
I will get back to you with something
Dave
Had to look over what we have done so far.
Serial
LCD
Some program flow.
Input from a switch
How about remembering something?
Let's say you have some parts moving along a conveyor and you want to count how many parts have passed by a certain point. But the problem is when the machine is turned off and then turned back on the counting starts back at zero and you want total parts counted for a week.
You can use the push button to simulate when a part passes by and have a WORD size variable increment each time the switch is activated and that value displayed someplace (serial or LCD).
To save the value for when the machine is turned off and on you will need to save the value to EEPROM and read from the EEPROM when the machine is started again. Place that value into the counting variable to continue counting from where it left off.
Another problem that can be addressed later is the EEPROM only has 1,000,000 write cycles so if the EEPROM is written to each time a part passes depending on how fast things are moving you could wear out the EEPROM in a matter of weeks.
So a shut down sequence is needed to only write to the EEPROM at shut down. This is not hard for scheduled shut downs but can be a "trick" for power failures.
For now you can have the value written to The EEPROM each time the variable is incremented.
Are you still using a 16F684 ?
I'm a carer, I know a thing or two about remembering.....:)Quote:
How about remembering something?
Yes still with the 16F684, do I need a more suitable chip?Quote:
Are you still using a 16F684 ?
Just an aside here, I was looking at in the RS catalogue the other day, they have a PICKit2 for a good price. Is this the next one up for me? Or should I stick with the PICkit1 for now?
http://uk.rs-online.com/web/search/s...duct&R=0149613
The 16F684 is fine for now. It all depends on what you need to do. More I/Os, memory, built in hardware? But for learning the small ones are good.
I am a big fan of the PicKit2 so if you can get one at a good price do so. But for now the PicKit1 is fine for the parts you are using. It is just very limited parts wise.
What do you have in mind to do with all of this? Home automation/monitoring?
There is so much that can be done with the "small" parts and they can be made to share information they may be all you need.
You know I really don't have a direct answer to that one. I've got a couple of small projects in the offing (I'll tell you about them later) and some ideas.The thing is, it's almost unlimited in what you can do! For me right now, it's about building a sound knowledge base, plus it's really absorbing, fascinating, I love it.Quote:
What do you have in mind to do with all of this? Home automation/monitoring?
Dave
Hi mackrackit,
I've been busy working on the last assignment....:)
Quick question. Would the code (below) output the value of B_P onto my LCD? B_P is a VAR WORD. I've used DEC1 as I only want to test the output with a couple of button presses (if that makes sense).
DaveCode:LCDOUT $FE,1
LCDOUT $FE,DEC1 B_P
Well... what did you get on your display?
Code:B_P = 12345
LCDOUT $FE,$C0,DEC1 B_P 'Displays 5
LCDOUT $FE,$C0,DEC2 B_P 'Displays 45
LCDOUT $FE,$C0,DEC3 B_P 'Displays 345
LCDOUT $FE,$C0,DEC4 B_P 'Displays 2345
LCDOUT $FE,$C0,DEC5 B_P 'Displays 12345
LCDOUT $FE,$C0,DEC B_P 'Displays 12345
Hi mackrackit,
Really sorry for the late reply, has been one of those days today.
I've got a couple of small problems with LCD / Counting at the moment, nothing I shouldn't be able to fix by now so please bear with me. If I can't get it going soon I'll have to ask.
Dave
Days???Quote:
Really sorry for the late reply, has been one of those days today.
I have been having one of those weeks :p
Hi mackrackit,
Lol..... Nice to know I'm not alone, you do have my sympathy though.Quote:
I have been having one of those weeks:p
Here's what I thought was a silly question, now I'm not so sure it is:
When you declare a VAR WORD, I thought that the value would automatically be set at zero, now I'm not so sure it is. Do you have to have to re-set it to zero before you start a count program or is it zero already?
I know it's Friday tomorrow but I hope your week gets better.
Dave
Sometimes it will be zero at power up but you never know.
You can use CLEAR, in the manual
or
VAR_IN_QUESTION = 0
Not a stupid question at all :)