Programming Question

Can you program a LCD display connected to a PIC with easy c v2 to display a variable, like a timer?

Dont quote me on this but LCD displays will not work on a PIC brain.

Actually it does work on PIC, in Microcontroller on the LCD page it says PIC works. If you use a while loop then you can update the LCD display with your variable, so yes you can display a variable.

What block do you use? I couldn’t find one for the LCD display.

Really? I use RobotC right now, but I used to use EasyC, and I had the LCD category. However, I was using Cortex. If you don’t have this LCD category, you may need EasyC Pro. Sorry I couldn’t be of more help.

where do you expect to plug in a LCD on a PIC? there are none of the 4 prong plugs.

On the LCD info page, it says you need 2 3-wire extensions to plug the LCD into a PIC.

Line from VEX LCD page: “PIC Microcontroller V0.5: Requires (2) 3-Wire Extension Cables”.

Presumably it connects here to the TX and RX ports.

It’s probably why the LCD display has two connectors and why the Y cable for the cortex is sold separately.

The simple answer is yes… To make it work, that is a little harder…

The LCD is like a Two Line Terminal(See Specs)… The problem is that the Output from the Vex Controller is set for 115,200 Bits Per Second (bps), where as the Vex LCD is set for 19,200bps(See Specs).

Luckily, easyC is just a Front End for the Microchip C18 Compiler, so with a little “Special Code”, the proper bps can be set… Quazar might have already done some examples like this, or created a Library. If not, this is something I can take on, since I have EasyC 1.1, 2.x, 3.x and 4.x, and the LCD Display… ( and lots of Microchip C18 programming experience )…

How soon did you want to implement this???

I did, and it does work. I’ll post it when I get home tonight (assuming I can find it).

You have to implement it as user code, since the serial functions are part of UserAPI.h and not available directly via any programming blocks.


  • Dean

Did you create a Library, or just have some Modular Code to include??

It has been a while since I looked at that. IIRC, it is just a source file with entry points for init, clear, position, print, backlight, and buttons.


  • Dean

OK, I found it. It was pretty crusty because I set it up using an old hack I used with EasyC (V1) which was to modify API.h to #include my extra stuff.

I’ve got it mostly ported to a real EasyC V2 library and will post it this evening after a get the last few wrinkles sorted.


  • Dean

Make sure that BlakeSchmidt, gets a Heads Up when you get it posted… He seems anxious to get it implemented…

Also, were you able to “Check my Work” on the EasyC 4.x version of your Line Follower code??

I have it all working - it is a thing of beauty! (well, relatively)

I exported it to a library called VexLCD, ready to zip up and post. Then I tried importing the library into a new blank project and got an error. Arrays in globals seem it work fine when compiling, running and saving a library. But you can’t import a library with an array for a global, and I need a char[32] array for the LCD contents. Sigh.

I’ll be working around that tonight and posting it for real.

[EDIT]A search yielded this thread. It appears this defect is still present in current EasyC V4. If I can’t devise an acceptable solution within the library itself, I suppose I could require the author of the importing project to declare a global “char LCD_Content[32]”. [/EDIT]

Not yet - I’ve been busy rediscovering the limitations of EasyC V2 :smiley:

  • Dean

The Satisfaction, of a Job Well Done… :wink:

So, if you create a Library from a User Function, that references Global Variables located in the Main Function, the Global Variables are not copied out to the Library, or they are, but not Integrated Back In when Importing a Library??

Looking forward to that… Actually, I should be pounding out some Vex Code, myself… ( Slacker… Slacker… Slacker… )

I would do just that, AND, Provide a Template Project, with the Proper Global-s in place, and the Typical “Hello, World\n” output, that they can Start a New Project from… That way they can look at how a Working Example is done…

Also, get that deficiency in the EasyC Bug Fix Que…

Not a Problem… I am Glad to see all the Activity happening here… Vex is getting more exciting, every year…

[EDIT] WOW!!! Sometimes, I excellent!!! I just read the above Thread on EasyC v4.x, and “I should be in Tech Support!!” Oh, wait… I AM in Tech Support, for my Family, for my Work, for Vex, for other Robotics, for Underwater Robotics…[/EDIT]

The referenced globals (actually all globals) seem to get merged into the importing project’s namespace. I think all it does is merge the library into the main project wholesale, simply discarding or ignoring the library’s main().

I figure there is a 50/50 chance I’ll do that. Either way, it gets posted tonight.

Oh, certainly! It is a shame there isn’t a reasonable way to throw in doxygen comments.

The number printing function “LCD_PrintNum(num,len,base)” is pretty cool. You can specify any base from 2 to 36 for unsigned numbers (e.g., base=2 for binary; base=16 for hexadecimal). Signed values are printed by specifying negative base numbers (e.g., base=-10 for a signed decimal format). If you specify base=0, you get special signed decimal format where positive numbers get a ‘+’ sign out front; handy for displaying deltas and offsets. You can specify a minimum length and it will pad out to that length (decimal formats pad with spaces, and non-decimal formats pad with leading zeros).

I tried to bump that thread, but no reply privs in that forum. I doubt they will fix it for V2 anyway, though it is worth getting them to fix it for V4.


  • Dean

The project is now posted over here.

It is fully documented on the download page, and here is the main() function from the demo code so you can get a sense of the flavor of the library:

#include "Main.h"

unsigned char LCD_Cursor = 0;       // Location for next PutChar (0..31)
unsigned char LCD_Backlight = 1;    // Set to 1 for backlight on, or 0 for off
unsigned char LCD_LeftButton = 0;   // Reads 1 if left button is pressed
unsigned char LCD_CenterButton = 0; // Reads 1 if center button is pressed
unsigned char LCD_RightButton = 0;  // Reads 1 if right button is pressed
unsigned char LCD_Contents[32];     // ASCII contents of LCD screen

void main ( void )
    int pot;
    while (1)      {
        pot = GetAnalogInput(1);
        LCD_Backlight = (pot>0);
        LCD_MoveTo(0, 0);
        LCD_PrintNum(pot-512, 4, 0); // base=0 prints signed decimal with a '+' sign
        LCD_PrintNum(pot, 3, 16);    // Hexadecimal (base 16)
        LCD_PrintNum(pot, 0, 36);    // Print in base 36 (really!)
        LCD_Newline() ;
        LCD_PrintNum(pot, 10, 2);    // Print in 10-bit binary
        LCD_MoveTo(1, 29);
        LCD_PrintChar(0xfc + LCD_LeftButton);
        LCD_PrintChar(0xfc + LCD_CenterButton);
        LCD_PrintChar(0xfc + LCD_RightButton);


  • Dean

Sorry for the Delay in Posting… The Forum seems to be having Issues…

It would be more difficult to Cleanly Integrate them… So I would guess Dropping the Library’s Main and Global Space.

Make it So, Number One… :wink:

What is so Special about, doxygen?? It appears to me to be a Hyper-Text Documenting System…

That is very Cool… What is Base 36 Called??? AlphaOmegadecmal…

It would be nice if they would fix all the EasyC versions for this Issue… It would allow Easy Extensibility in the Future…