Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Writing variables to Newhaven display using I2C

Status
Not open for further replies.

foggysail

Newbie level 6
Joined
Mar 7, 2011
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,442
I have a small home project using C18 with a PIC18F4550 that needs to display some digitally adjusted 3 digit integers along with text strings on four lines of a 20X4 LCD display. Now those familiar with Newhaven ...and maybe for all I know, other similar displays, one can write a byte (WriteI2C(0x21) for example) at a time or a string with a putI2C(). For the byte which is actually 2 bytes with only one byte getting displayed, one needs to use Newhaven's ASCII table. It means only 1 digit at a time can be presented to the display.

Now of course, if you have an integer then it needs to be broken up to units, tens, hundreds and so forth so that individual digits can be ASCII coded then written. Example.... 123 needs to be 1, 2, 3 and then 1 could be written using ASCII which would be 0x31, 2 would be 0x32 and so forth. MESSY! Worse, I cannot see how to use a varible in a string for the putI2C().

Sure, I have a routine that will separate the integer digits and an array to call the digits for display. But that again is messy.

Is there any way to circumvent this stuff with pointers? I tried using them in the put command but it treated the pointer as a string as one would expect and not as a pointer to a variable.

If there are/is a way to do so, can you give an example?

Thanks--

Foggy
 

Is there any way to circumvent this stuff with pointers? I tried using them in the put command but it treated the pointer as a string as one would expect and not as a pointer to a variable.

Unfortunately not, all numerical values must be converted to character strings.

The Microchip Explorer PIC18 has LCD interface through an SPI port expander. You might take a look at the demo code and schematic to get some ideas.

**broken link removed**

The demo code and routines for the Explorer PIC18 could be easily modified for I2C instead of the SPI for output on the LCD.

The Microchip C18 Library routines cans an extensive list of I2C routines, including putsI2C() - Write a string to the I2C bus operating in either Master or Slave mode. The source for the library routines is available in the installation directory, you could use it to customize your own routine to fit your interface requirements.

MPLAB® C18 C COMPILER LIBRARIES

One way or the other, you'll most likely need to "Roll Your Own" routines to interface with the Newhaven Display.

There is also a example program for PIC and Newhaven Serial Interface Displays:

Program for writing to Newhaven Display Serial LCDs




BigDog
 

Unfortunately not, all numerical values must be converted to character strings.

The Microchip Explorer PIC18 has LCD interface through an SPI port expander. You might take a look at the demo code and schematic to get some ideas.

**broken link removed**

The demo code and routines for the Explorer PIC18 could be easily modified for I2C instead of the SPI for output on the LCD.

The Microchip C18 Library routines cans an extensive list of I2C routines, including putsI2C() - Write a string to the I2C bus operating in either Master or Slave mode. The source for the library routines is available in the installation directory, you could use it to customize your own routine to fit your interface requirements.
MPLAB® C18 C COMPILER LIBRARIES

One way or the other, you'll most likely need to "Roll Your Own" routines to interface with the Newhaven Display.

There is also a example program for PIC and Newhaven Serial Interface Displays:

Program for writing to Newhaven Display Serial LCDs




BigDog


Thanks BigDog.

I was afraid that might be the case. I am using a development board purchased from Future along with their programmer so board wise, I am OK. I have studied the stuff in the C18 user's guide along with their help forums and it just looks like I am stuck. Yes, one can write integers by using strings but the but of buts occurs. One cannot dynamically change them as the values change without rewriting the string for the new values.

It is not a huge big deal, I have the code already writen. I did that when I was going to use LEDs. With them, I had no choice but to break down the integers into digits and then break the digits down to segments. Just messy!

I just got over the learning phase for I2C stuff. Started when I was going to use SAA1064's to minimize the nightmare wiring needed for all the segments in all the LEDs. So hey, as bad as it is writing the messy display code, it sure beats the bull poop out of all teh wiring needed for for 3 or 4 LEDs.

If only I could use a string variable in the C18's putsI2c(). Heck, I'll just move on and do the code.


Foggy
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top