PDA

View Full Version : lcdout versus serout2



Fred
- 26th September 2006, 20:57
In trying to plagiarize existing works I have found numerous instances of where there are lcdout commands. I use a LCD with a "backpack" affair such that it takes standard serout commands. In trying to convert the lcdout to a serout command I have found numerous allusions to using the serout2 command instead as it supposedly mimics the lcdout command. However, it does not work as advertised in the meager, limited little world I live in. The command I am trying to duplicate is
lcdout $fe,1,"TIME:",HEX2 hh,":",HEX2 mm,":",HEX2 ss
and I use the command
serout2 PORTB.6,84,[hex hh,":",hex mm,":",hex ss] I have also tried
serout2 PORTB.6,84,[hex2 hh,":",hex2 mm,":",hex2 ss]
serout2 PORTB.6,84,[ihex2 hh,":",ihex2 mm,":",ihex2 ss]
serout2 PORTB.6,84,[hex #hh,":",hex #mm,":",hex #ss]
In poring over the manual and looking futilely for some clues I confess to being stymied in my efforts. The display gives meaningless jumbles instead of pristine characters. Perhaps someone of greater programming prowess could enlighten me as to my deficiency.
Thanks

keithdoxey
- 26th September 2006, 21:45
Presumabley the LCD display works OK if driven from a PC ?

Normally a backpack LCD would expect to receive RS232 levels. Your seting of "84" is for 9600 baud TRUE. Unless you are using a MAX232 to perform the translation from TTL to RS232 I believe you will need to use INVERTED. Try changing the "84" to "16468" as shown in Appendix A of the PBP manual.

You also dont say what speed your PIC is running at and the manual includes the following warning "9600 baud may be unreliable with 4MHz clock"

Fred
- 27th September 2006, 00:19
The lcd works fine if I send text using the standard serout command so the lcd itself is fine. Also, I inserted some code into the program using serout and it appears fine so the connections have proven correct as well. I will try the new code instead of 84 tommorrow. By the way I'm using a 20 mhz clock.
Thank you for your help in this matter.

Fred
- 27th September 2006, 14:04
Changing the 84 to 16468 in the serout2 command does make the display at least readable. However, the display appears to be in hex format as the numbers count up through A1, A2 and so on. I haven't thoroughly re-examined the manual for the hundredth time but I thought including the HEX command would change the numbers back to the standard convention. I will re-read that section on serout2 as my manual now falls open to that part. Thanks so much for your input so far. The command I now use is
serout2 PORTB.6,16468,[hex2 hh,":",hex2 mm,":",hex2 ss]
If you have any further thoughts on how to make this work I would be most interested if you would share them.
Again, thanks for interest in helping me.

Fred
- 27th September 2006, 16:06
Just to complete this entry. I deciphered the issues and have satisfactorily resolved them.
Thanks.

keithdoxey
- 27th September 2006, 16:07
Glad to hear the display works... just need to fix the content now :)

All numbers are stored internally as HEX. Try using DEC instead.

BIN, DEC and HEX modifiers are used to output an ASCII representation of the number.

eg, myVar = 65

LCDout myVar displays "A"

LCDout DEC myVar displays "65"

LCDout HEX myVar displays "41"

LCDout BIN myVar displays "1000001" (leading zeros not displayed unless you specify how many bits to show)

Fred
- 28th September 2006, 13:14
I apologize for the ambiguity of my last message. What I intended was that all of my problems, jumbles on the display and also incorrect counting were all rectified. This appears to be a good example of needing to pull back from a project sometimes to get a fresh start. Indeed, I don't think I would have seen the problem with the display not displaying correct. It never occured to me that I had selected the wrong logic levels on the display. I was thoroughly convinced that the command using the 84 instead of 16468 was correct. But as for it counting wrong I overlooked that the numbers were in BCD. The initial problem had me so consumed I overlooked that one little fact. Thank you for taking your time to answer what to many is such a simple problem it's not worth their time. It was extremely frustrating.
Again thanks.