Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MX220 and LCD
14-05-2012, 08:40 PM,
#1
MX220 and LCD
Hello,

I just installed Pinguino X.3 and tried the examples.
There is a "HelloWorld.pde" for LCDs in ...\10.Libraries\LiquidCrystal.

Compiling for an OTG board does not work: error: too few arguments to function '_lcd_begin'.
Current code is: lcd.begin(16, 2).
What is the correct syntax for lcd.begin now?

That example worked in X.2 without problems.

Compiling for MX220 does not work at all (same as X.2): error while linking...
Stdout last line says: region `kseg0_program_mem' overflowed by 764 bytes.
Is the MX220 too small ever for that little example?

Thank you
Hannes
Reply
14-05-2012, 09:12 PM, (This post was last modified: 27-05-2012, 07:28 PM by mf01.)
#2
RE: MX220 and LCD
Hi,

it was changed in a recent update of X.3 (r363 01 May 2012) to correct some previous errors and be more compatible with the Arduino library on which it was based. The corresponding library file entry is now :-
Code:
void _lcd_begin(u8 cols, u8 lines, u8 dotsize)
i.e. it requires three parameters, the number of display columns (cols), the number of display lines (lines) and the "dot size". Dot size should always be 0 unless lines = 1 when it can be one.

I have updated the function page in the Pinguino wiki to include this information.

If you have similar problems you can look at the corresponding pdl32 file (in this case lcdlib.pdl32) and find the corresponding entry for the function you are having difficulty with :-
Code:
lcd.begin _lcd_begin#include <lcdlib.c>

This says that the corresponding function in the lcdlib.c file is _lcd_begin, as I have included above.

Hope this helps.

Update 27 May 2012:

Since this was originally posted the syntax of lcd.begin/_lcd_begin for P32 has been changed back (r462, 26 May 2012) to the previous version with only two parameters so the corresponding library file entry is now :-
Code:
void _lcd_begin(u8 lines, u8 dotsize)
i.e. it only requires two parameters, the number of display lines (lines) and the "dot size". Dot size should always be 0 unless lines = 1 when it can be one. The wiki page has been updated accordingly.
Board = PIC32-Pinguino-OTG Rev C
OS = Linux Unbuntu 11.10 till 26 Apr 2012
OS = Linux Unbuntu 12:04 from 27 Apr 2012
Reply
15-05-2012, 10:58 AM,
#3
RE: MX220 and LCD
Thank you. It helps a lot to know which library is used.

And for the MX220?
Any chance to get the LCD run for this device?
Btw. I need "analogRead" and if possible "lcd.printFloat" too.

Or do I need the extra hardware for LCDI2C and am limited to integers?
Reply
15-05-2012, 05:05 PM, (This post was last modified: 15-05-2012, 06:36 PM by mf01.)
#4
RE: MX220 and LCD
Hi Hannes,

unfortunately I have no direct experience of using the MX220 but what I can say is that it should just be a case of connecting the LCD appropriate lines to the Pinguino board, ensuring that the Pin numbers in the example correspond to the connections you are using and then running the example. I have a PIC32 Pinguino OTG which I have run with several LCD displays, and once I set up the Pinguino Pin numbers correctly with lcd.pins ( ) I was able to swap displays quite easily (I put pin headers in each of the displays so that they could be plugged into a prototyping board). I also used different Pinguino Pin numbers to those used in the examples in the Pinguino IDE, although I did take care to ensure that the pins did not conflict with other functions that might make use of the same IC or IDE pins.

The same code ran on a 16 x 2 and two different 20 x 4 displays.

The library for the using i2c to talk to a display in lcdi2c.c/lcdi2c.h but from a quick look there is not a float function built into that library. I do not believe that lcdi2c will give you any additional functionality so I would not recommend using lcdi2c unless you need to talk to the LCDdisplay using i2c.

*** Update: I have tried lcd.printFloat and got a reasonable output for some numbers. The two parameters you need are the number to be printed and the number of decimal places to be printed. The syntax is :-
Quote:void lcd.printFloat(float number, u8 digits)
What you may have to be careful of is the limited number of significant digits. If you try for more than 7 significant digits you may run into rounding problems.

There may be something using lcd.printf() but I have not tried that or confirmed its operation with floating point numbers. I would suggest getting the display working with the simpler examples, e.g. HelloWorld etc and also trying positioning the cursor and scrolling before trying the float variants of lcd.printFloat() or or lcd.printf(). Details of how to do the formatting in lcd.printf() can be found on the wiki (.printf() formats). This page is still work in progress and based on an older page. As yet I have not tried the "float" option so I have not yet updated the line detailing floating numbers hence it still says Not yet implemented which may not be accurate.

If you do not have any success with lcd.printFloat() or lcd.printf() you could always try using the c sprintf() function to generate a formatted string from your floating point variable and then using lcd.print() or lcd.printf() to print out the formatted string. You should be aware that the c sprintf() function is quite resource hungry which may be an issue with the MX220. The lcd.printf() function uses a simplified Pinguino specific version which is faster and less resource hungry all be it with more limited functionality and is accessible directly in the Pinguino IDE as Sprintf() (Note the difference in capitalization).

Finally, what is the range (maximum - minimum) of values that you are trying to output and what sort of output format are you looking for. I will not promise but if you post it here and I get the chance I will try it with my board and one of my displays

Regards
Board = PIC32-Pinguino-OTG Rev C
OS = Linux Unbuntu 11.10 till 26 Apr 2012
OS = Linux Unbuntu 12:04 from 27 Apr 2012
Reply
15-05-2012, 06:13 PM,
#5
RE: MX220 and LCD
Hi mf01,

sorry, I have expressed myself poorly.
There are absolutely no problems using an OTG board.
After adding the 3rd argument to "lcd.begin", even with X.3.
The "HelloWorld" example is that what I used (pls. see first post).

It's a matter of _size_.
I compiled the "HelloWorld" a few times and noticed the sizes in the output window.
Device is the OTG.

Here's what's in the main loop:
Code:
void loop() {
  lcd.setCursor(0, 1);

  lcd.print("Pinguino");
  //lcd.printf("Pinguino: %d", millis()/1000);
  //lcd.printFloat(3.14, 2);  
    
  delay(100);
}

This results a code size of 18.704 bytes.
Uncommenting the printf line: 23.104 bytes.
Uncommenting the printFloat line: 25.916 bytes.
Uncommenting both lines: 31.820 bytes.

That is too heavy for a device with only 32KB flash like the MX220!


Hannes
Reply
15-05-2012, 07:46 PM, (This post was last modified: 15-05-2012, 10:03 PM by mf01.)
#6
RE: MX220 and LCD
Hi Hannes,

no problem.

I am not sure that size is the only issue. I successfully compiled an example similar to your minimum for both the 220 and the OTG boards. For the OTG I got a size of 16,112, but with the 220 selected I got a size of 12,256. Also, although the lcd.printf() and lcd.printFloat seem to cause problems I did manage to get an output from a variable (all be it an integer) using itoa to do the integer to string function, and this did compile for the 220 with a size of 12,444. It ran an expected on an OTG and it might be worth trying something similar with your 220.

Code:
u16 i = 0;

void setup() {
// initialize the library with the numbers of the interface pins
// lcd.pins(RS, E, D4, D5, D6, D7,  0,  0,  0,  0); //4bits
// lcd.pins(RS, E, D0, D1, D2, D3, D4, D5, D6, D7); //8bits
   lcd.pins(18, 19, 3, 4, 5, 7, 0, 0, 0, 0);     // Use last 4 pins as zero for 4bits mode
   lcd.begin(20, 4, 1);
   lcd.print("Hello, World!");
}

void loop() {
  u8 buffer[20];
  itoa (i,buffer,10);
  lcd.setCursor(0, 1);
  lcd.print(buffer);
  i++;
  delay(1000);
}

Now all you have to do is squeeze in the extra code for the analogueRead() and you may be able to display the count corresponding to the analogue reading Wink.

Regards
Board = PIC32-Pinguino-OTG Rev C
OS = Linux Unbuntu 11.10 till 26 Apr 2012
OS = Linux Unbuntu 12:04 from 27 Apr 2012
Reply
15-05-2012, 08:53 PM,
#7
RE: MX220 and LCD
Hi mf01,

the line
itoa (i, buffer, 10);
causes these errors:
c:\pinguinox.3\win32\p32\bin\../lib/gcc/mips-elf/4.5.2/../../../../mips-elf/include/stdlib.h:62:5: error: expected identifier or '(' before 'int'
c:\pinguinox.3\win32\p32\bin\../lib/gcc/mips-elf/4.5.2/../../../../mips-elf/include/stdlib.h:62:5: error: expected ')' before '>' token

I tried to figure out what's wrong, but that's too complicate for me.

Hannes
Reply
15-05-2012, 10:02 PM, (This post was last modified: 15-05-2012, 11:30 PM by mf01.)
#8
RE: MX220 and LCD
Hi Hannes,

Firstly, I did unfortunately manage to accidentally delete the } at the end of the setup loop in my earlier post above although I don't think that this was the cause of your error messages. I have now corrected my earlier post above.

I thinking that unfortunately your latest error messages may be down to a difference between the GCC compilers on Windows and Linux. When I tried it I used a version of the Pinguino IDE running on Unbuntu (as per my signature), but since noticing your latest error messages I have also tried it on Windows (Vista) and got very similar error messages to the ones you did. Unfortunately itoa is not a standard c function so is not guaranteed to be present on all implementations Huh but there is a Pinguino specific implementation included in the IDE. What is not clear is why it does not appear to be working in Wndows.

If you are really interested in getting an output on an LCD with the 220, then you could try writing your own itoa function (although you will have to call it something else). I did find this link giving some alternative implementations (http://www.jb.man.ac.uk/~slowe/cpp/itoa.html) which might be a starting point and you may be able to simplify the code if say, you only want to work in base 10. There are probably many other possible implementations available on the web.

Regards
Board = PIC32-Pinguino-OTG Rev C
OS = Linux Unbuntu 11.10 till 26 Apr 2012
OS = Linux Unbuntu 12:04 from 27 Apr 2012
Reply
15-05-2012, 11:04 PM,
#9
RE: MX220 and LCD
Hi mf01,

a lot of work, you did for me. Thank you very much.

Converting the integer is really no problem.
When I convert the ADC input to volts, I always know, where the decimal point is ;-)

Again, you helped me very much.

Hannes
Reply
15-05-2012, 11:37 PM,
#10
RE: MX220 and LCD
Hi Hannes,

no problem, but I did find out that there is a Pinguino specific implementation of itoa (see itoa.c in the \p32\include\pinguino\core folder). What is not clear is why it is not being correctly recognised in Windows. I have updated my earlier post but until someone works out why it is not working it may be simplest to do your own conversion.

Regards
Board = PIC32-Pinguino-OTG Rev C
OS = Linux Unbuntu 11.10 till 26 Apr 2012
OS = Linux Unbuntu 12:04 from 27 Apr 2012
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)