Pins, LCD and Manual 3

gerrymcc

New Member
Have I missed something?

I have been using an LCD panel with a 28X1, and controlling it using the PICAXE connections and steps broadly as described in Manual 3, at around page 39.

My understanding is that the "pins" command works on all 8 input or output bits simultaneously.

In the Manual 3, I read the following program steps

"rchr: let pins = b1 & 240" and "wrins: let pins = b1 & 240"

A note at the bottom of the page says

"The let pins = commands used by wrins/wrchr will not alter the state of unused pins
0 and 1."

I had been having difficulty with outputs on pins 0 and 1 changing, and it took me a long time to realise why this was happening. It was happening every time a character was written to the LCD.

Have I missed something, or is this yet something else I do not fully understand?

Thank you
 

Technical

Technical Support
Staff member
The sentence is indeed misleading and outdated, what it really means is "that the pins will stay at value 0 all the time" (as, as it states, it assumes they are unused!)

All 'let pins=' commands affect all pins that are configured as outputs.
 

gerrymcc

New Member
Thank you.

What is an easy way of accomplishing the same result, but making sure the unused outputs remain unmodified during LCD output operations?

I am not clever enough to come up with a neat solution.
 

jodicalhon

New Member
I'm a bit rusty at this so I may come a cropper, but:
- to keep the unused pins high you could try 'let pins = whatever | %00000011'
- or the keep the unused pins low you could try 'let pins = whatever & %11111100'
 

hippy

Ex-Staff (retired)
As with much example code ( for the PICAXE and other devices ) the primary intention is to show how things can be done and hardware controlled or used and such code often needs modifying for use in other circumstances and individual projects. Unfortunately it's not usually possible to provide example code for every circumstance in which the code may be used.

To preserve the pins you don't want to alter, the above techniques can be used; this involves recovering the pin levels previously set and ensuring when 'LET pins=" executes the pins are set as they were previously. The current state of output pins can be obtained by using the READOUTPUTS command. After that it is a case of masking, ANDing and ORing the data you need to manipulate to create a vlaue to write using "LET pins=".

You can find alternative code to control an LCD at the following link ( somewhat outadated now - change "byte" to "bite" and it uses PEEK rather than READOUTPUTS ) and this also details how to preserve pins 0 and 1 ...

http://www.hippy.freeserve.co.uk/picaxelc.htm

It's all a bit complicated which is why I would recommend using an AXE033 or FRM010 for LCD interfacing these days.
 
Top