[solved] Midas MC42005A6W-SPTLYI-V2 HUMS/LCD Project

Hi all,

My project uses a MKR Zero and an I2C 20x4 LCD Display (Midas MC42005A6W-SPTLYI-V2). I have had trouble writing to the LCD display and have tried a few different Libraries in doing so. At this point I just need functionality before I can move on with this project. Attached is a small circuit diagram and the latest code/library I have been using, created by 'Bill Perry'. I'm just trying the hello world sketch. Help would be greatly appreciated. I also used an I2C scanner and found the address 0x3f, that's why it's in written into the code.

// vi:ts=4
// ----------------------------------------------------------------------------
// HelloWorld - simple demonstration of lcd
// Created by Bill Perry 2016-07-02
// bperrybap@opensource.billsworld.billandterrie.com
//
// This example code is unlicensed and is released into the public domain
// ----------------------------------------------------------------------------
//
// This sketch is for LCD modules that have a native I2C interface such as
// PCF2119x, PCF2116, or certain RayStar LCDs rather than those LCD modules that
// use an i/o expander chip based based backpack.
// NOTE:
// These devices usually need external pullups as they typically are not on
// the module.
// WARNING:
// Use caution when using 3v only processors like arm and ESP8266 processors
// when interfacing with 5v modules as not doing proper level shifting or
// incorrectly hooking things up can damage the processor.
// 
// Sketch prints "Hello, World!" on the lcd
//
// If initialization of the LCD fails and the arduino supports a built in LED,
// the sketch will simply blink the built in LED.
//
// ----------------------------------------------------------------------------
// LiquidCrystal compability:
// Since hd44780 is LiquidCrystal API compatible, most existing LiquidCrystal
// sketches should work with hd44780 hd44780_I2Clcd i/o class once the
// includes are changed to use hd44780 and the lcd object constructor is
// changed to use the hd44780_I2Clcd i/o class.

#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Clcd.h> // i2c LCD i/o class header

// Note, i2c address can be specified or automatically located
// If you wish to use a specific address comment out this constructor
// and use the constructor below that specifies the address

// declare the lcd object for auto i2c address location
//hd44780_I2Clcd lcd;

//
// enter address of LCD.
// Addresses seen so far include:
// - 0x3a, 0x3b (PCF2119x)
// - 0x3c (unknwon chip)
// - 0x3d (unknwon chip)
// - 0x3e (unknwon chip)
// - 0x3f (unknwon chip)

// declare i2c address and constructor for specified i2c address
const int i2c_addr = 0x3f;
hd44780_I2Clcd lcd(i2c_addr); // use device at this address


// LCD geometry
const int LCD_COLS = 20;
const int LCD_ROWS = 4;
void setup()
{
int status;

 // initialize LCD with number of columns and rows: 
 // hd44780 returns a status from begin() that can be used
 // to determine if initalization failed.
 // the actual status codes are defined in <hd44780.h>
 // See the values RV_XXXX
 //
 // looking at the return status from begin() is optional
 // it is being done here to provide feedback should there be an issue
 //
 status = lcd.begin(LCD_COLS, LCD_ROWS);
 if(status) // non zero status means it was unsuccesful
 {
 // begin() failed so blink error code using the onboard LED if possible
 hd44780::fatalError(status); // does not return
 }

 // Print a message to the LCD
 lcd.print("Hello, World!");
}

void loop() {}

Any reason why you need to use another chip other than voltage translation?

The LCD looks like its based on the HD44780. If you can implement voltage translation, you can drive it directly from the MKR zero's I2C

It looks as if your LCD has a native I2C interface. i.e. it does not have a "backpack" stuck on the 16 pins.
It is not a HD44780

However your datasheet does not quote a specific controller chip.
You just connect SA0, SA1, CSB to GND as shown on Page#3.
I suggest that you put a 47R or 100R in series with A or K for the LED backlight.

Install hd44780.h library from the IDE Library Manager.

Run examples from hd44780ioClass/hd44780_I2C e.g. HelloWorld.ino

Your sketches will look like this:

#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Clcd.h> // i2c LCD i/o class header

Ask if you have a problem. Quote example by name.

David.

The hd44780_I2Clcd i/o class looks to be the correct i/o class for that LCD.

Why specify the address? Was the auto location not working?

What is happening when you run the HelloWorld?

Do you get anything on the display?
Is the begin() failing?
If so, do you get a blink code?
What is the blink code? or can you get it by printing out the status value on the serial port?

--- bill

Thanks for the advice guys. Hardware Issue

hzrnbgy:

  • The PCA9517AD chip is primarily used for voltage translation. Are you suggesting the MKR Zero can level shift without the use of this, that's not what I gathered from the datasheet?

david_prentice:
-I had SA1 connected to GND, as specified and followed your interpretation connecting SA0, SA1, CSB to GND. Once I ran Bills code the LCD displayed Hello World properly, so thankyou.

  • Also I'm using a constant current IC to maintain a current of 300mA @ 4.2V as apecified in the datasheet for reliability (didn't show that in my drawing).

bperrybap:
-You were correct Bill, no need to specify the address, as noted in your sketch.

No doubt I'll be back on the forum soon, cheers

Also I'm using a constant current IC to maintain a current of 300mA @ 4.2V as apecified in the datasheet for reliability (didn't show that in my drawing).

I am horrified. Please post a schematic of how you have connected components.
A pencil drawing is fine. Just so that we can see what you are doing.

I2C pullup resistors should be pulled to 3.3V.
You don't need any external level shifters.

But if you have, it should be fine. We need to see how you have connected.

Please don't run the electronics until we have seen your schematic.

David.

david_prentice:
I2C pullup resistors should be pulled to 3.3V.
You don't need any external level shifters.

Running a single 3v i2c bus when using a 3v master and 5v slaves can work as an alternative to using a proper level shifter with separate 3v and 5v buses.

But it depends a few things like none of the slaves having any of their own pullups on them.

I do it sometimes, but I've also had issues with things at higher clock rates depending on value of the pullups used and the condition/length of the wires.

Me, for anything but doing some quick testing, I use a level shifter.

--- bill

The schematic in #0 looks ok.

But there is no mention of the constant current IC to maintain a current of 300mA @ 4.2V in the schematic.

I can't think of anything in the Midas MC42005A6W-SPTLYI-V2 that would draw 300mA. A constant current source would attempt to raise the voltage until the current met the target.

David.