MOI-AL-202 with XBoard I2C help request

Support for MOC/MOS/MOI/MOU/X-Board/MOP

Moderator: Mods

Post Reply
TimVukman
LCD Geek
Posts: 27
Joined: Sun Aug 10, 2008 7:20 pm

MOI-AL-202 with XBoard I2C help request

Post by TimVukman » Tue Apr 27, 2010 6:11 pm

Hi:

I am trying to get this combination to work with my Arduino Diecimila. I am not expecting you to help me on the Arduino side, but it has been some time since I have worked with this display and I suspect that I am doing something wrong.

I am looking in the MOX.pdf manual and on Page 14 it indicates that "Pins two and three are reserved here for I2C communcation on addresses 80 and 81."

On Page 18, in the Communication section, the forth last point indicates "The default slave address for the display module is 0x50."

On Page 19, Command 1. Communications lists the command to change the address as dec 254 51. I read the 51 as indicating a Write given that it is an odd number and on that basis, the address would be set to 50 for Read access.

In that command, it states the Hex version would be FE 33 to change the I2C write address.

I need to send to the display in Hex according to the Arduino library that I am using, but I do not get a response from the display using address 0x33.

Code: Select all

#include <LCDi2cW.h>                    
LCDi2cW lcd = LCDi2cW(2,16,0x33,0); 
The XBoard I have says it is version 2.1. I believe I have the jumpers set correctly in that none of the jumpers associated with serial communication are connecting any pins in the serial block.

The display powers up properly with the logo on the left side written across both rows and
Matrix Orbital
MOI-AL-202
written to the right of it.

Any suggestions would be most helpful.

Thanks

TimV

Clark
Matrix Orbital
Matrix Orbital
Posts: 859
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Post by Clark » Wed Apr 28, 2010 11:05 am

Hi Tim,

As mentioned, it does sound like you have your hardware set up correctly; there really isn't too much to do for an I2C display. One thing I don't see mentioned is pull up resistors, if you don't have them already, please include a resistance of 1 to 10 Kohms from each of the SCL and SDA lines to 5v.

Now, for software, I believe this is the source of your trouble. The default write address is 80 in decimal or 0x50 in hex. The command to change the I2C address takes 3 parameters, 254 and 51 are part of the command, the next byte will be the desired address. For example, to change the write address to 80 decimal, send 254 51 80.

I would recommend trying more basic commands or text using the default write address of 80 before trying some of the more advanced settings. If you feel the address may have been changed you can place the unit into manual override mode, check out the full description on page 18 and the pin location diagram on page 7.

~Troy
Troy Clark
Design & Development
Matrix Orbital

TimVukman
LCD Geek
Posts: 27
Joined: Sun Aug 10, 2008 7:20 pm

** Not a Matrix Issue - User Problem - Code **

Post by TimVukman » Wed Apr 28, 2010 11:33 am

Hi Troy:

Thanks for your reply. This morning I found my previous post on this forum from some time ago when I first got this display.

In reading that post, I was reminded about 7 bit vs 8 bit I2C addresses. On that basis, the actual address for this display is 0x28.

I hooked up a device I bought some time ago from Diolan.com. It allows me to see I2C / SPI networks.

I can confirm that the display is correctly registered on the I2C bus and that I can get it to respond to commands from the Diolan ControlPanel.

The work I had done before was two computer upgrades ago, so I no longer have the code I wrote for the Arduino. Time to re-invent the wheel :)

Thanks again for your help.

TimV

Clark
Matrix Orbital
Matrix Orbital
Posts: 859
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Post by Clark » Wed Apr 28, 2010 2:41 pm

No worries Tim,

I'm glad the display appears to be working correctly and that the code is all coming back to you. We do have a few app notes online, but you'll probably be left rounding off a square one way or another.

All the best,
~Troy
Troy Clark
Design & Development
Matrix Orbital

TimVukman
LCD Geek
Posts: 27
Joined: Sun Aug 10, 2008 7:20 pm

Post by TimVukman » Wed Apr 28, 2010 4:00 pm

Hi Troy:

Still no magic, but I am updating a library for the Arduino that will hopefully get me where I need to get.

I know I did all the code at the low level the last time, so I hope the library will be quicker in the end.

When done, would you like copies of the .h, .cpp and Arduino sketch? Your app notes are a little light.

Tim

TimVukman
LCD Geek
Posts: 27
Joined: Sun Aug 10, 2008 7:20 pm

Post by TimVukman » Thu Apr 29, 2010 2:04 pm

Hi:

Still no luck. I discovered this morning that I2C on the Arduino uses Analog Pin4 and Pin5. All day yesterday I was using Digital Pin4 and Pin5.

That was a pretty good waste of time.

Today I am on the right pins. I also connected my Diolan monitor to the SDA and SCL pins on the display itself. It should have been a pretty good clue yesterday that only one address was listed (0x28 for the display) which meant that the Arduino wasn't connected - see Analog vs Digital above.

I have scrapped the library approach for now and I am trying to connect much like I did in my previous posts here which indicated success. I have included my commented code in the hope that something obvious strikes someone.

I would appreciate some pointers.

Thanks

Tim
The page references and command numbers are taken from the MOX.PDF document.

Code: Select all

#include <Wire.h>
#include <inttypes.h>

#define i2c_address 0x28              //address of MOI-AL-202C
#define command 0xFE                  //value to define as command
#define Set_Data_Lock1 0xCA           //command 6.2 pg 28
#define Set_Data_Lock2 0xF5           //command 6.2 pg 28
#define Set_Data_Lock3 0xA0           //command 6.2 pg 28
#define Data_Lock_Value 0x00          //table 16 pg 28
#define Clear_LCD 0x58                //command 2.3 pg 19

void setup()
{
  Serial.begin(38400);                 //opens monitor on PC
  Wire.begin(i2c_address);             //sets the slave address
  Serial.print(i2c_address, HEX);      //displays value on monitor
  Serial.println();                    //line space
  Wire.beginTransmission(i2c_address); //starts the session
  delay(1000);                         //pause for 1 second
  Wire.send(command);                  //sends FE
  Serial.print(command, HEX);          //displays value on monitor
  Serial.println();                    //line space
  delay(1000);                         //pause for 1 second
  Wire.send(Set_Data_Lock1);           //sends CA
  Serial.print(Set_Data_Lock1, HEX);   //displays value on monitor
  Serial.println();                    //line space
  delay(1000);                         //pause for 1 second
  Wire.send(Set_Data_Lock2);           //sends F5
  Serial.print(Set_Data_Lock2, HEX);   //displays value on monitor
  Serial.println();                    //line space
  delay(1000);                         //pause for 1 second
  Wire.send(Set_Data_Lock3);           //sends 0xA0
  Serial.print(Set_Data_Lock3, HEX);   //displays value on monitor
  Serial.println();                    //line space
  delay(1000);                         //pause for 1 second
  Wire.send(Data_Lock_Value);          //sends 0x00
  Serial.print(Data_Lock_Value, HEX);  //displays value on monitor
  Serial.println();                    //line space
  Wire.endTransmission();              //closes session
  
  Wire.beginTransmission(i2c_address); //opens session
  delay(1000);                         //pause for 1 second
  Wire.send(command);                  //sends 0xFE
  Serial.print(command, HEX);          //displays value on monitor
  Serial.println();                    //line space
  delay(1000);                         //pause for 1 second
  Wire.send(Clear_LCD);                //sends 0x58
  Serial.print(Clear_LCD, HEX);        //displays value on monitor
  Serial.println();                    //line space
  
}

void loop()
{
}



Clark
Matrix Orbital
Matrix Orbital
Posts: 859
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Post by Clark » Fri Apr 30, 2010 9:33 am

Hi Tim,

Good to hear you have the ports figured out, unfortunately, I've gone through most of the basics above. I can add that the display will send back an ACK/NAK bit with each write, or read, which may be built into the function that you are using. I'd recommend checking that bit to ensure communication is successful.

Also, I had my firmware designer take a look at your code; she knows a little more I2C and programming than I. She mentioned that you may want to try the 8 bit address, just leave it at 0x50, and the display will sort things out. If 0x28 is not ACKing, that would be my next recommendation. She's also a little concerned about the begin and end transmission functions; you can send the address just like you would send data, so we're a little leery of anything that might be added by that built in command.

~Troy
Troy Clark
Design & Development
Matrix Orbital

TimVukman
LCD Geek
Posts: 27
Joined: Sun Aug 10, 2008 7:20 pm

Post by TimVukman » Fri Apr 30, 2010 9:57 am

Good Morning Troy:

Thanks for your suggestions. I will give those a go and report back.

The begin.Transmission function is supposed to do the actions to start I2C. I believe that is the transition of SDA from high to low. I don't think they do anything more than that.

I am concerned only in that I had this working before, using code that is in another thread on this forum and it was indeed talking on 0x28.

That was version 11 of the Arduino and it is now on version 18 so I have no idea if / what might have changed. That's why I dropped the library and went to the lower level code.

I'm pretty much at wit's end on this. I might see if I can make a serial cable and fire up the display that way. It makes no sense to me at the moment.

Later

Tim

Raquel
Matrix Orbital
Matrix Orbital
Posts: 689
Joined: Thu Aug 19, 2004 3:37 pm
Location: MO Office

Post by Raquel » Fri Apr 30, 2010 11:21 am

Hi,

With your existing code, can you please try to change the defined i2C_address from 0x28 to 0x50?

Just give it a quick try.

Thanks,
Raquel Malinis
Design and Development
Matrix Orbital

TimVukman
LCD Geek
Posts: 27
Joined: Sun Aug 10, 2008 7:20 pm

Post by TimVukman » Fri Apr 30, 2010 12:02 pm

Hi Raquel:

Changing the address to 50 made no difference.

Unfortunately it does make me question the value of the Diolan U2C-I2 I have been relying on.

I expected that the device reported the addresses it saw on the bus. Originally it indicated 7F which I took to be the Arduino and 0x28 which I believed was the MOI-AL-202C, in part because that was the address in my previous posts from 2008 and in my code which used to work (and I did find)

After trying to talk to the display on address 0x50, when I ask the Diolan what is on the bus, it reports address 0x50. It used to say 28, so I think it is whatever the query is for and not the physical address.

I did not send any code to set the address. Maybe I should try that?, or reset to factory?

Thanks

Tim

TimVukman
LCD Geek
Posts: 27
Joined: Sun Aug 10, 2008 7:20 pm

Post by TimVukman » Fri Apr 30, 2010 1:15 pm

Hi:

I have made progress. As stated in previous posts, when looking at the I2C bus with the Diolan U2C-12, I was seeing addresses of 0x7F and 0x28.

I have used address 0x7F in their software and selected "open device". At this point, with a memory address length of 1, and a memory address of 0x00, I can send different "data" bytes to the display.

I can send the hex codes from the character set table in MOI-AL202.PDF and they are being written on the display!!!!!

I think I must have somehow changed the address to 0x7F (perhaps hacking around with the Diolan device.

Address 0x28 no longer is showing on my bus. I may have the same address in the Arduino as in the display. (That's going to slow things down) I can't change the Arduino address but perhaps I can change the display address to something other than 7F.

Unfortunately, I am not sure exactly how I got any of this to do what it has done. (Big help eh?)

I know I can write to the display so ......

Tim

TimVukman
LCD Geek
Posts: 27
Joined: Sun Aug 10, 2008 7:20 pm

Got it!!!!!

Post by TimVukman » Fri Apr 30, 2010 2:05 pm

Hi:

I think I might have created an unwanted post on your forum. Please check and delete. It might just be blank. I'll have a look in a minute.

Ok. I have the display working from my Arduino.

The main issue was in my code in that I was always sending the 0xFE. That of course put the display in command mode which meant that I would not be displaying characters.

I dropped that out of the code and it nows takes a character as a character.

I did confirm that Wire.beginTransmission() must be there and it must contain the I2C address. It does actually intiate the physical bus requirements.

The following code works perfectly.

Please confirm if I need to put code in the initialization according to this note in section 4.1.1 of the I2C Communication Summary of the MOI-AL202.pdf document. I do not do any reads, but I might if I ever play with the IO pins.
* to be able to read the replies of query commands (eg. cmds 54, 55) the following command must be
sent (only needs to be sent once, so this can be done somewhere in init): 254 / 160 / 0 this command puts
the reply data in the I2C output buffer instead of the RS232 output buffer.
This code works if others follow behind me on this. I am going to go back and fix the library now for this display.

Code: Select all

#include <Wire.h>
#include <inttypes.h>

#define i2c_address 0x28              //address of MOI-AL-202C
#define command 0xFE                  //value to define as command
#define Set_I2C_Mode 0xA0             //command 4.1.1 pg 6
#define Set_I2C_Value 0x00            //command 4.1.1 pg 6
#define Clear_LCD 0x58                //command 2.3 pg 19
#define value 0x52                    // Number 3

void setup()
{
  Serial.begin(38400);                 //opens monitor on PC
  Wire.begin(i2c_address);             //sets the slave address
  Serial.print(i2c_address, HEX);      //displays value on monitor
  Serial.println();                    //line space
  Wire.beginTransmission(i2c_address); //starts the session
  Wire.send(value);                    //sends character "R"
  delay(1000);                         //pause for 1 second
  Serial.print(value, HEX);            //displays value on monitor
  Serial.println();                    //line space
  Wire.endTransmission();              //closes session 
}
void loop()
{
}
Thanks for your help and patience.

regards

Tim

Clark
Matrix Orbital
Matrix Orbital
Posts: 859
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Post by Clark » Mon May 03, 2010 9:31 am

Hi Tim,

No worries, it's great that you have I2C communication on an Arduino figured out, again, so that our other developers can follow. On their behalf, thank you!

As for turning off responses in RS232 mode on initialization, this is definitely recommended. While reading output states, unfortunately, is not supported, in any protocol, this will allow users to read the module type, firmware revision, and most importantly for those with keypad input, key presses. If this command is not issued, any responses from the device are sent out the RS232 port and in essence lost.

Anyway, all the best, and thanks again for your contribution to the community,
~Troy
Troy Clark
Design & Development
Matrix Orbital

Post Reply

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest