Page 1 of 4

Customizing display output

Posted: 17 Dec 2020 19:13
by AliTaih
I changed the Code so i can see the OnBoard Voltage instead of AFR (lambda is better).

so i changed the code to look like this:

Code: Select all

//Calculate supply voltage.
float SupplyVoltage = (((float)adcValue_UB / 1023 * 5) /10000) * 110000;

//Output display data.
u8g2.firstPage();
do {
      u8g2.drawXBMP(112, 4, 16, 16, LambdaSensorSymbol);
      u8g2.drawXBMP(112, 24, 16, 16, BatterySymbol);
      u8g2.drawXBMP(112, 44, 16, 16, HeaterSymbol);
      u8g2.setFont(u8g2_font_helvB24_tf);
      u8g2.setCursor(0,29);
      u8g2.print(SupplyVoltage);                 //ändern mit Volt Spannung
      u8g2.setCursor(0,59);
      u8g2.print(Lookup_Lambda(adcValue_UA), 2);
} while ( u8g2.nextPage() );
I took the (//Calculate SupplyVoltage) from Code Line 472
can i do it better or different so i will not use it twice ?
Also the Voltage says ( 11.08V-11,45V) but my Multimeter measures ( 12,12-12,45), so its a huge difference and my multimeter is Correct.
Am i doing something wrong ?

Re: SupplyVoltage instead AFR

Posted: 17 Dec 2020 19:49
by Christian_Bylund
Welcome to the forum Ali.
AliTaih wrote:
17 Dec 2020 19:13
I took the (//Calculate SupplyVoltage) from Code Line 472
can i do it better or different so i will not use it twice ?
This line is only executed once during heating so if you want to value to update you need to perform the calculation like you are doing now for every update.
AliTaih wrote:
17 Dec 2020 19:13
Also the Voltage says ( 11.08V-11,45V) but my Multimeter measures ( 12,12-12,45), so its a huge difference and my multimeter is Correct.
Am i doing something wrong ?
That looks correct, what you are not considering is the voltage drop of the protection diode. We are actually measuring the input voltage, not the battery voltage. But the forward voltage drop at 1A consumed by the heater gives a voltage drop of 1V that you can easily compensate for.

Code: Select all

//Calculate battery voltage. Compensated for voltage drop over diode.
float SupplyVoltage = 1 + (((float)adcValue_UB / 1023 * 5) / 10000) * 110000;
You can off course fine tune this to be very precise by calibrating for different voltages.

With my power supply set to 12.40V, I see the same on the display.
Image
Image

Another issue that you might run into is that these are raw values, typically even on a multimeter values are filtered to show a moving mean average over a couple of seconds.

Good luck, and please share your progress.

Re: SupplyVoltage instead AFR

Posted: 18 Dec 2020 18:48
by AliTaih
Ok it worked fine. i am struggling adding a V for volt behind number and maybe the greek lambda sign behind ads value.

u8g2.print((SupplyVoltage),"V"); this does not work.

u8g2.print(Lookup_Lambda(adcValue_UA), 2); what does the 2 stand for ?

Re: SupplyVoltage instead AFR

Posted: 18 Dec 2020 22:33
by Christian_Bylund
AliTaih wrote:
18 Dec 2020 18:48
Ok it worked fine. i am struggling adding a V for volt behind number and maybe the greek lambda sign behind ads value.

u8g2.print((SupplyVoltage),"V"); this does not work.

u8g2.print(Lookup_Lambda(adcValue_UA), 2); what does the 2 stand for ?
The "2" sets how many decimals you want to display of the SupplyVoltage variable.

To display a "V" after the voltage you need to perform a second print function, same with the lambda symbol that is a bit more complicated to do.

Code: Select all

//Calculate supply voltage. Compensated for voltage drop over diode.
float SupplyVoltage = 1 + (((float)adcValue_UB / 1023 * 5) /10000) * 110000;

//Output display data.
u8g2.firstPage();
do {
	u8g2.drawXBMP(112, 4, 16, 16, LambdaSensorSymbol);
      	u8g2.drawXBMP(112, 24, 16, 16, BatterySymbol);
      	u8g2.drawXBMP(112, 44, 16, 16, HeaterSymbol);
      	u8g2.setFont(u8g2_font_helvB24_tf);
      	u8g2.setCursor(10,29);
      	if (SupplyVoltage >= 10) u8g2.print(SupplyVoltage, 1);
     	if (SupplyVoltage < 10) u8g2.print(SupplyVoltage, 2);
      	u8g2.setFont(u8g2_font_unifont_t_greek);
      	u8g2.print("V");
      	u8g2.setCursor(10,59);
      	u8g2.setFont(u8g2_font_helvB24_tf);
      	if (LambdaValue >= 10) u8g2.print(Lookup_Lambda(adcValue_UA), 1);
      	if (LambdaValue < 10) u8g2.print(Lookup_Lambda(adcValue_UA), 2);
      	u8g2.setFont(u8g2_font_unifont_t_greek);
      	u8g2.drawGlyph(75,59, 0x03bb);
    } while ( u8g2.nextPage() );
Here is an example code that looks quite nice and adjusts the resolution automatically from 1 digit to 2.

Image

Hope it helps!

Re: Customizing display output

Posted: 19 Dec 2020 22:05
by AliTaih
Thank you very much worked very well i just changed a bit because "lambdavalue" was not declared but i wanted the 2 decimals als the time. now i am struggling using a bigger display from u8g2 lib. its working with olikraus and i changed in your program but didn't work maybe because its spirit and not IIC?

Re: Customizing display output

Posted: 19 Dec 2020 23:37
by AliTaih
NOO it is working. i am using the WaveShare 128x128 1,5inch display with this :

U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);

But my problem is the code does not start. it is just showing me the logo but nothing else. the less are not flashing.
if i change to :U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);
everything works.
am i missing something ?

Re: Customizing display output

Posted: 20 Dec 2020 00:18
by Christian_Bylund
AliTaih wrote:
19 Dec 2020 23:37
But my problem is the code does not start. it is just showing me the logo but nothing else. the less are not flashing.
if i change to :U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);
everything works.
am i missing something ?
Glad to see you are making progress! I think I see the problem with the larger display.

U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);

Your new screen is using the same chip select pin (CS) as the Lambda Shield 2. Try using another pin for the CS of the display, for example Pin 11.

Re: Customizing display output

Posted: 20 Dec 2020 11:17
by AliTaih
OK didnt thought about that. I'm now using 13,12,11,9,8. But still just loading screen. Am i using more used pins ?

Re: Customizing display output

Posted: 20 Dec 2020 11:40
by Christian_Bylund
AliTaih wrote:
20 Dec 2020 11:17
OK didnt thought about that. I'm now using 13,12,11,9,8. But still just loading screen. Am i using more used pins ?
Those pins are OK to use, it is only pin 10 that is used by the Lambda Shield.

Could you please share the serial output, then I am sure we can figure out what is going on. I suspect there is an SPI issue. Probably the display sets a different SPI setting than the lambda controller like to use. Is it possible to use I2C for the display you are using and could you please share the information of the screen?

There seems to be a I2C option for the SSD1327 display controller:
U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, / reset=*/ U8X8_PIN_NONE);

Re: Customizing display output

Posted: 20 Dec 2020 13:41
by AliTaih
Is this my serial output ?

0,1,-1,307,447,79,833
0,1,-1,306,447,78,831
0,1,-1,306,447,79,832
0,1,-1,307,448,79,834
0,1,-1,307,448,80,835
0,1,-1,308,448,80,836
0,1,-1,309,448,81,838
0,1,-1,308,448,79,835

yes there is an i2c for the display but there is no lib. the olikraus does not work...