pins variable not accepted hen trying BASIC program to access a 1602 LCD

rieverjohn

New Member
Hi all, I am tying to access a 1602 LCD using a Basic program from a book PICAXE Microcontroller, by David Lincoln. I have attached the file. PICAXE 18M2 used.

The pins variable is flagged as an error during syntax check so I tried pinsb, which is accepted but no data appears when the LCD is connected ( one row of full blocks appear so the LCD works) trying pinsb was a wild but I thought reasonable guess when I couldn't find an alternative, but no change in the display. What is the correct variable name in this instance.

I also found that in another program variables get and byte were not accepted, my documentation seems out of date.
 

Attachments

rieverjohn

New Member
this is the file in question


'LCD 4-bitdirect
'OPTIONS PICAXE-18M2

symbol latchout=1
symbol lcddata=1
symbol lcdinst=0

symbol outbyte=b0
symbol rs=b1
symbol counter=b2
symbol nblcount=b3

rs=lcdinst
for counter=0 to 5
lookup counter, ($33, $32, $28,$0C, $01, $06), outbyte
gosub lcdout
next counter

doloop:
rs=lcdinst
outbyte=$80
gosub lcdout

rs=lcddata
for counter=0 to 15
lookup counter, ("PICAXE-18M2 ABC"), outbyte
gosub lcdout
next counter

rs=lcdinst
outbyte=$C0
gosub lcdout

rs=lcddata
for counter=0 to 9
lookup counter, ("1234567890"), outbyte
gosub lcdout
next counter

goto doloop

lcdout:
for nblcount=1 to 2
pins=outbyte & $F0 | 2 | rs 'latch high
low latchout
pause 4
outbyte=outbyte*16
next nblcount
return
 

hippy

Technical Support
Staff member
The 'lcdout' routine which outputs two nibbles, msb then lsb, is not ideal because it sets the E as the data is written and that can cause some issues with some displays. It also doesn't seem to be setting Port B as outputs. I am guessing it was originally coded for an 18X or 18M.

I would try -
Code:
lcdout:
  pinsB = $00
  dirsB = $FF
  pause 1
  pinsB = outbyte & $F0 | rs
  high B.1
  low B.1
  pause 4
  pinsB = outbyte * 16 | rs
  high B.1
  low B.1
  pause 4
  return
 

rieverjohn

New Member
Hello Hippy, thanks for you reply, It seems I was right to use pinsb. I also wasn't aware of differences in the programming of the M2 chips, the four PICAXE instruction series don't mention that. I take on board that setting E can be a problem and I will try your solution.
 
Top