Customizing display output

Support forum for the Lambda Shield designed to connect Bosch LSU 4.9 wideband oxygen sensors to Arduino projects.
User avatar
Christian_Bylund
Posts: 255
Joined: 07 Mar 2015 18:09

Re: Customizing display output

Post by Christian_Bylund » 20 Dec 2020 17:08

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

0,1,-1,307,447,79,833

yes there is an i2c for the display but there is no lib. the olikraus does not work...
Yes, so this confirms that the SPI is not working when the display libraries are loaded. According to U8g2 they support your SSD1327 128x128 display by I2C. Your best - is to use the display with I2C which should work fine, but I read that the display need to be set in to I2C mode (default is SPI).

I found this User Manual:
https://www.waveshare.com/w/upload/8/80 ... ual_EN.pdf
So the DC pin need to be grounded for the I2C addressing to work.
Best Regards,
Christian Bylund
Bylund Automotive AB

AliTaih
Posts: 22
Joined: 17 Dec 2020 16:48

Re: Customizing display output

Post by AliTaih » 21 Dec 2020 19:48

Ok it worked with I2C. I forgot to connect DC to ground. But the FPS were so terribly slow, because its a 16 bit grey display.
So back to the 1.3inch display. maybe i will find a bigger one and try again. so far thank you christian.

User avatar
Christian_Bylund
Posts: 255
Joined: 07 Mar 2015 18:09

Re: Customizing display output

Post by Christian_Bylund » 21 Dec 2020 22:13

I believe it is probably possible to improve the speed of the display. Now it is made for the minimum ram usage to work on all types of Arduino boards. There is a full frame buffer mode that is much faster according to the U8g2-library. Let me see if I can get it to work on my display first, then you can see if it works better with your display.

https://github.com/olikraus/u8g2/wiki/u8g2setupcpp
Best Regards,
Christian Bylund
Bylund Automotive AB

User avatar
Christian_Bylund
Posts: 255
Joined: 07 Mar 2015 18:09

Re: Customizing display output

Post by Christian_Bylund » 22 Dec 2020 12:36

After some testing I managed to improve the performance slightly by increasing the clock speed of the I2C interface using the u8g2.setBusClock() function. But nothing that will improve the overall experience.

Instead I have ordered the same kind of display you are hopefully using:
https://www.ebay.com/itm/1-5-128x128-OL ... 3075694095

Hopefully with the display I can find a way to make it work on SPI without interfering with the lambda controller.

What you can do right now is to hardcode the CJ125_Status to CJ125_DIAG_REG_STATUS_OK as well as the calibration values.

Code: Select all

CJ125_Status = CJ125_DIAG_REG_STATUS_OK;
adcValue_UA_Optimal = 307;
adcValue_UR_Optimal = 175;

And remove the use of the COM_SPI() function. The Lambda Shield works without SPI but you will not be able to see any errors or faults so it is not recommend but it will let you continue with your project and get your display up and running.

This topic is also addressed in this thread.
Best Regards,
Christian Bylund
Bylund Automotive AB

AliTaih
Posts: 22
Joined: 17 Dec 2020 16:48

Re: Customizing display output

Post by AliTaih » 22 Dec 2020 23:37

i think this is going to be to complicated for me. i am happy that this is working on the small display. you can try writing a programm for the big 1.5 inch display. and try if you can speed it up using I2C. if not then spi is ok

User avatar
Christian_Bylund
Posts: 255
Joined: 07 Mar 2015 18:09

Re: Customizing display output

Post by Christian_Bylund » 10 Jan 2021 01:41

AliTaih wrote:
22 Dec 2020 23:37
i think this is going to be to complicated for me. i am happy that this is working on the small display. you can try writing a programm for the big 1.5 inch display. and try if you can speed it up using I2C. if not then spi is ok
Ali, good news! The 1.5 inch display finally arrived from ebay. I managed to get it up and running using SPI with the following changes of the original code.

Code: Select all

//Define display.
U8G2_SSD1327_EA_W128128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 30, /* dc=*/ 32, /* reset=*/ 34);
I defined the display with this configuration, using pins 30, 32 and 34 for CS, DC and RST.

Code: Select all

//Function for transfering SPI data to the CJ125.
uint16_t COM_SPI(uint16_t TX_data) {
  
  //Reconfigure SPI (Reset by display).
  SPI.setClockDivider(SPI_CLOCK_DIV128);
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SPI_MODE1);
  
  //Set chip select pin low, chip in use.
  digitalWrite(CJ125_NSS_PIN, LOW);

  //Transmit and receive.
  byte highByte = SPI.transfer(TX_data >> 8);
  byte lowByte = SPI.transfer(TX_data & 0xff);

  //Set chip select pin high, chip not in use.
  digitalWrite(CJ125_NSS_PIN, HIGH);

  //Assemble response in to a 16bit integer and return the value.
  uint16_t Response = (highByte << 8) + lowByte;
  return Response;
  
}
The real problem was that the display changes the SPI settings so by resetting them each time we communicate with the lambda controller it works again.

Let me know if this solves your problem.
Best Regards,
Christian Bylund
Bylund Automotive AB

AliTaih
Posts: 22
Joined: 17 Dec 2020 16:48

Problems

Post by AliTaih » 09 Apr 2021 20:51

Hello Christian,

i have built in the lambda controller but i have now 2 problems.
After a few minutes the controller stops working. It just freeze. this problem was from the beginning.
The second problem is awkward, it just shows me 10.12 Lambda ( i think its the maximum value). perhaps i wired the bosch wrong because it was working fine.

AliTaih
Posts: 22
Joined: 17 Dec 2020 16:48

Re: Customizing display output

Post by AliTaih » 11 Apr 2021 15:51

i am happy with the small display but got new problems while finally running it in the car

AliTaih
Posts: 22
Joined: 17 Dec 2020 16:48

Re: Problems

Post by AliTaih » 11 Apr 2021 22:32

everythin is wired correctly so i orderes a new sensor hope it works

AliTaih
Posts: 22
Joined: 17 Dec 2020 16:48

Re: Problems

Post by AliTaih » 12 Apr 2021 23:19

ok i now connected the new sensor and it worked for a few minutes than it was showing a completly wrong lamda value ( 0,88 was normal, now 1,88). and it freezes again. after multiple restarts it starts working but with wrong value again. its freezin while heating and sometimes while showing the logo.

Post Reply