Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 14:21 29 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Smaller/Lesser Displays.

Author Message
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 10:49am 31 May 2017
Copy link to clipboard 
Print this post

Wondering if it's worth while adding support to MMbasic for some lesser capable displays like 16x2 Serial displays.

Not all projects need advanced displays, the likes of a 16x2 or 20x4 will suffice.

Currently using a 20x4 on my ceiling heater control;
Only issue is it costs 6 pins; too many on a 28 pinner.

If we could use the serial versions we've be back at 2 & displays could be remote to a small extent.

I don't know if the existing LCD command could be revised to support them, or whether it would be best left as an External Function.

One's like these is what I had in mind, presuming there's a very standard controller being used.

Cheers.

PS, Could see one hanging off MikeO's battery monitor.
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 11:07am 31 May 2017
Copy link to clipboard 
Print this post

how about a single pin? About half way down the page

http://www.romanblack.com/shift1.htm

you have to do all the register handling (piece of cake on HD44780) and it won't be terribly fast to update but if your displays are fairly static, you can replace 6 pins with 1 and a bit of code. The timings are reasonably important (not critical) but you can open them out or whatever with trial and error...

Just a thoughtEdited by CaptainBoing 2017-06-01
 
GoodToGo!

Senior Member

Joined: 23/04/2017
Location: Australia
Posts: 188
Posted: 12:49pm 31 May 2017
Copy link to clipboard 
Print this post

Those little I2C modules with the PCF8574 are great. I, like Phil23, use them on a 20x4 module. The code is a bit unwieldy, I admit. It would be great in a Cfunction. However when it comes to C, it's all uint_string {Greek} to me. Anyone want a go at it? I can supply the Basic routines I use....

I've also bolted a modified one on to a 4xRelay I have here to turn it into an I2c Controlled Relay Module:-

The four extra pins are the remaining 4 I/O's from the PCF8574 to use for whatever I desire.

The code is based on Phil23's Spa paging code and I squeezed the GUI layout onto a 2.8" MM+ LCD Backpack:-

I find the buttons are workable for my fingers.

I've also adapted an 8x Relay unit I have as well, but utilising a slightly different I2c module. (Hence why the GUI above is for controlling 8 relays )

Controlling a bunch of stuff using only 2 pins comes in handy.

Cheers,

GTG!


...... Don't worry mate, it'll be GoodToGo!
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9063
Posted: 05:06pm 31 May 2017
Copy link to clipboard 
Print this post

Yes, I2C two or four line LCD's are the way to go, if you want to use them, but still save pins at the same time.

There are a plethora of 2-line and 4-line I2C LCD's on eBay, also a heap of OLED modules and even 1.8"-2.2" graphical LCD's running on I2C.

Search for "I2C LCD for Arduino" and take your pick!
Smoke makes things work. When the smoke gets out, it stops!
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 11:36am 02 Jun 2017
Copy link to clipboard 
Print this post

  Grogster said  Search for "I2C LCD for Arduino" and take your pick!


Ahhh,

There in lies the next question; which one, in terms of a "Standardised controller" that might best be supported, or already have something written for it in MMbasic.

There seem to be a lot of module like these.
But do they only work with 16x2?

Having a variety here, 16x2, 20x4, 16x4 & 8x4 even (maybe),
would it support all those configurations, or is it specifically 16x2 only?





Even though many MM projects may not need a display, they could still be useful as a diagnosis tool, that could just be plugged into a heater to check stuff if the device was so coded.

Cheers

Phil.
 
retepsnikrep

Senior Member

Joined: 31/12/2007
Location: United Kingdom
Posts: 131
Posted: 09:06pm 02 Jun 2017
Copy link to clipboard 
Print this post

I must admit i'm torn on this.

I've used the simple 16x2 and 20x4 serial lcds quite a lot and they have usually been more expensive and very unreliable. I think the code in the serial/converter pic (often a 16F88) is pretty flaky. I've had to reflash them on occasion.

The options of LCD output DEFINE commands that are actually PARALLEL, I2C or SERIAL would be useful though.. Parallel does cost a lot of pins but is more reliable in my experience. Not tried I2C..


Gen1 Honda Insights.
 
GoodToGo!

Senior Member

Joined: 23/04/2017
Location: Australia
Posts: 188
Posted: 09:41pm 02 Jun 2017
Copy link to clipboard 
Print this post



Here's the code I use to drive a 20x4 LCD module with a PCF8574T I2c module attached. The modules are cheap as chips and pretty hardy. I don't think it's worthwhile putting routines into MMbasic to control something like this, but a Cfunction would be the way to go.... or maybe even bung the code into the library?
' -----------------------------------------------------------
' Routines for Micromite to drive serial I2C LCD
' by Andy H. 17/05/2017
' Adapted from a program by Jim Rowe.
' 3 calls in total
' initLCD - Initialises the LCD Controller
' ClearScreen - Clears the display and sets cursor to line 1 position 1
' DisplayText row, offset, text$ - which row to output on, repositions cursor to offset, txt to be displayed


' LCD functions of PCF8571 output bits P0 - P7:
' Name 8574 bit LCD function
' DB4 = P4 Data Line 4 (pin 11)
' DB5 = P5 Data Line 5 (pin 12)
' DB6 = P6 Data Line 6 (pin 13)
' DB7 = P7 Data Line 7 (pin 14)
' RS = P0 Reg select (pin 4) 0 = Cmd 1 = Data
' EN = P2 EN (pin 6) 0 = Idle, 1 = Active
' R/Wbar = P1 R/W-bar (pin 5, should be 0 for writing)
' BL = P3 Backlight control (Q1 & LCD pin 16)
' ----------------------------------------------------------

OPTION AUTORUN ON
OPTION EXPLICIT
option default integer

' declare the PCF8574 I2C address (all links out)
DIM AS LCDI2CAddr = &H27 ' (A2=A1=A0=1)

' masks for preparing I2C bytes for writing to 8574 & LCD
DIM RSCmask = &B00000000 ' select cmd register (RS = 0)
DIM RSDmask = &B00000001 ' or data register (RS = 1)
DIM ENmask = &B00000100 ' Enable (active = P2 high)
DIM BLmask = &B00001000 ' Turn on backlighting (P3 = 1)
Dim CNT(7) ' array to store LCD config command bytes
CNT(0) = &B00110011 ' &H33 --> 8-bit / 8-bit mode init
CNT(1) = &B00110010 ' &H32 --> 8-bit / 4-bit mode
CNT(2) = &B00101000 ' &H28 --> 4-bit mode, 2 lines, 5x7 pixels
CNT(3) = &B00001000 ' &H08 --> disp off, cursor off, no blink
CNT(4) = &B00000001 ' &H01 --> clear screen, return home cmd
CNT(5) = &B00000110 ' &H06 --> increment cursor, cursor move
CNT(6) = &B00001100 ' &H0C --> disp on, cursor off, no blink
dim line1home = &B10000000 ' &H80 --> Place cursor at start of line 1
Dim line2home = &B11000000 ' &HC0 Place cursor at start of line 2

PAUSE 200 ' wait 200ms for LCD to stabilise after powerup
I2C OPEN 100,100 ' enable I2C (bus speed 100kHz, 100ms timeout)
InitLCD ' then go initialise the LCD + controller

' main program loop starts here
DO
ClearScreen
DisplayText 1, 0, "1234567890"
DisplayText 2, 10, "GoodToGo!!"
DisplayText 3, 0, "abcdefghij"
DisplayText 4, 10, "zyxwvutsrq"
PAUSE 1000
DisplayText 1, 10, "1234567890"
DisplayText 2, 0, "GoodToGo!!"
DisplayText 3, 10, "abcdefghij"
DisplayText 4, 0, "zyxwvutsrq"
pause 1000
LOOP

END ' end of main part of program, subs follow

' -----------------------------------------------------------------

' subroutine to Display text on LCD.
sub DisplayText row, offset, text$
local i
select case row
case 1
sendcmdbyte (line1home + offset)
case 2
sendcmdbyte line2home + offset)
case 3
sendcmdbyte (line1home + 20 + offset)
case 4
sendcmdbyte (line2home + 20 + offset)
end select
For i = 1 To Len(text$)
SendDataByte ASC(Mid$(text$, i, 1))
Next i
end sub

' -----------------------------------------------------------------

' subroutine to clear LCD screen
sub ClearScreen
SendCmdByte cnt(4)
PAUSE 400 ' pause for 400ms to give it time...
end sub

' -----------------------------------------------------------------

' subroutine to initialise the LCD
SUB InitLCD
local i
For i = 0 To 6
SendCmdByte cnt(i)
IF i = 4 THEN
PAUSE 20 ' pause for 20ms to allow full clear
END IF
PAUSE 50 ' pause to let LCD controller settle down
Next
END SUB

' -----------------------------------------------------------------

' subroutine to send a command byte (aByte) to the LCD controller
SUB SendCmdByte aByte
local temp, RSbit
RSbit = RSCmask ' make sure we're sending to cmd reg (RS=0)
' then prepare the more significant nibble
temp = (aByte AND &HF0) Or RSbit OR BLmask
DirectSend temp ' and send it
' then prepare the less significant nibble
temp = ((aByte AND &H0F) << 4) Or RSbit OR BLmask
DirectSend temp ' and send it also
END SUB

' -----------------------------------------------------------------

' subroutine to send a data byte (aByte) to the LCD controller
SUB SendDataByte aByte
local temp, RSbit
RSbit = RSDmask ' make sure we're sending to data reg (RS=1)
' then prepare the more significant nibble (from aByte)
temp = (aByte AND &B01110000) Or RSbit OR BLmask
DirectSend temp ' and send it
' then prepare the less significant nibble (from aByte)
temp = ((aByte AND &H0F) << 4) OR RSbit OR BLmask
DirectSend temp ' and send it also
END SUB

' -----------------------------------------------------------------

' subroutine to send a nibble (in temp) to the LCD
SUB DirectSend temp
temp = temp Xor ENmask ' make EN=1
I2C WRITE LCDI2CAddr, 0, 1, temp ' send it with EN=1
Pause 10 ' pause for 10ms
temp = temp Xor ENmask ' now make EN=0 again
I2C WRITE LCDI2CAddr, 0, 1, temp ' before sending again
END SUB
' ----------------------------------------------------------------


Feel Free to use.

Cheers!

GTG!
...... Don't worry mate, it'll be GoodToGo!
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 12:49am 03 Jun 2017
Copy link to clipboard 
Print this post

  GoodToGo! said  
Feel Free to use.

Think I'll grab a couple of modules & give it a try.

Can't see any reason for serial displays to not fit in with the MM's.

Bare basic output is all that is needed in some instances & costing just 2 pins adds a big windfall on a 28 pin chip.

Phil.
 
gumath
Newbie

Joined: 25/04/2017
Location: Austria
Posts: 10
Posted: 03:14am 03 Jun 2017
Copy link to clipboard 
Print this post

@ Phil23

Hello Phil,

Since I still have many MX-150 left, I block these to VT-100 ads
(See Geoffs website), and use cheap displays for the ad.





This is a complete monitoring, our heating system and hot water system, with solar support.
The small display is only switched on when I am present in the boiler room.
Directed over com2 the MX-170, 28Pin.
9 x DS18B20
1 x DHT22
1 x relay input solar pump
1 x relay output, for controlling the circulating pump for hot water (bath, etc.)
1 x MAX 232, connected to the CONSOLEN interface for data transfer to my shack

The evaluation, and display of the temperature data, etc. is done with a
TFT-Maximite, (converted by me to a color maximite), to a large one
Display.

Best regards,
Vy 73 de Guenter, OE7GMT
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 03:38am 03 Jun 2017
Copy link to clipboard 
Print this post

Thanks Guenter, seeing such a brilliant implementation of the technology makes all the work on MMBasic worthwhile. Just what I was hoping for when I set off on this path.

Geoff
Geoff Graham - http://geoffg.net
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1328
Posted: 01:21am 04 Jun 2017
Copy link to clipboard 
Print this post

Hello Guenter - as Geoff said, this is an impressive project. Can you tell me what type of display you are using there - and a link if possible?

Greg
 
gumath
Newbie

Joined: 25/04/2017
Location: Austria
Posts: 10
Posted: 09:43am 04 Jun 2017
Copy link to clipboard 
Print this post

@paceman, Hello Greg

I always refer to these displays from Amazon.de.
Look for "Mini Display" or "Mini Monitor".
Costs just under 20 euros.
Best regards, Guenter



@ Geoffg, Hello Geoff

Thanks for the commendation, I give back.
The system runs continuously, without interruption, and fault over a year.
The hot water circulating pump ran before, almost all day from 6am to 22h.
Through the monitoring I have seen how often the heating the boiler needs to heat up.
The circulation pump now switches on via a relay at 30 degrees Celsius
And over 39 degrees off again.
Through this procedure, I have been able to reduce the number of heaters by a third.
This alone saves in the winter, when with us the solar system nothing supplies a large quantity natural gas. And of course a lot of money.

Thanks Geoff,

Vy 73 de Guenter, OE7GMT
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024