/ EV

Solving OpenEVSE display bug

So.. after boot all seems fine with my openEVSE:


But when it starts charging this happens:


This comes from this this code:

if (curstate == EVSE_STATE_C) {
    time_t elapsedTime = g_EvseController.GetElapsedChargeTime();
    if (elapsedTime != g_EvseController.GetElapsedChargeTimePrev()) {   
      int h = hour(elapsedTime);
      int m = minute(elapsedTime);
      int s = second(elapsedTime);

So I was suspecting the printf line, maybe the implementation changed or something. So I added this:


And watched the serial monitor:


So, it's not that. I started putting Serial.println almost everywhere, and everywhere it echoed the expected results.

At this time I started to suspect a hardware problem, also because of the nature of the display output (jibberisch).. Do I have an overlap in assigned pins or something? Plowed through the code for that, but could not find any. The charging pin is using D3, the CP D10, analog in A1, and the display m_Lcd(13,12,11,7,9,8) should be fine..

The only state change that might be causing this is the charge state, right?

To be sure I commented out all the lines at the point where the charging is enabled:

    else if (m_EvseState == EVSE_STATE_C) {
      //chargingOn(); // turn on charging current

And sure enough, the expected display output:


So I jumped into the SetPWM method, and there it is.. in the comments:

// outputting a 1KHz square wave to digital pin 11 via Timer 1
// 16MHz / 64 / (OCR1A+1) / 2 on digital 9
// 16MHz / 64 / (OCR1A+1) on digital 10
// 1KHz variable duty cycle on digital 10, 500Hz fixed 50% on digital 9
// pin 10 duty cycle = (OCR1B+1)/(OCR1A+1)

The pins D11 & D9 are not used in the schema's at all, but obviously it is not a good idea to use pin D9 and D11 for the display (and D10, but I got that from the schema already)

Not sure why this is the case, and looking at the code I would not have found this, but I'm moving my LCD pins, and all will be fine..