Program behavior changes with power source

First off, I am unsure whether this is the right topic.
I am experiencing an extremely strange behavior with my program. My setup is: Arduino Nano Every connected to 8bit TFT screen, relays and other sensors. It is placed on a custom PCB and is powered via a DC-DC buck converter connected to a 12V input. Power is supplied directly to 5V pin and ground is in common with 12V power source.

I want to change the screen state if the touchscreen hasn't been pressed for a while. This is my code (stripped down). I skipped some variable definitions and function, but it should not be a problem.

bool down = false;
uint8_t screenState = 0;
bool screenUpdate = false;
bool stealthMode = true;
unsigned long lastPress = 0;
unsigned long timeSinceLastPress = 0;
#define LCD_TIMEOUT 300 // lcd dark mode in seconds
#define HOME_TIMEOUT 60 // time to homescreen in seconds
#define INPUT_TIMEOUT 200 // input min cooldown in millis

void setup()
{
	Serial.begin(115200);

	// screen management
	tft.begin(0x9486); // il9486 controller
	tft.invertDisplay(0);
	tft.setRotation(1); // landscape
	tft.fillScreen(TFT_BLACK);
}

void loop()
{
	//check touchscreen and change screen
    timeSinceLastPress = millis() - lastPress;
	if (timeSinceLastPress > INPUT_TIMEOUT)
	{
		down = Touch_getXY();
		if(down)
                 {
			lastPress = millis();
                        timeSinceLastPress = 0;
                  }
	}
	else
		down = false;

	if (stealthMode)
	{
		if (screenState != 6 && timeSinceLastPress/1000 > LCD_TIMEOUT)
		{
			tft.fillScreen(TFT_BLACK);
			screenState = 6 ;
			timeWrite(tm, 280, 18);
		}
		else if (screenState == 6 && timeSinceLastPress/1000 < LCD_TIMEOUT)
		{
			screenState = 0;
			drawGUI();
            drawState(lightMode, lightState[tmH], 406, 0, lightSprite);
            drawState(fanextMode, fanextState, 406, 82, fanSprite);
            drawState(fanintMode, fanintState[tmH], 406, 164, fanSprite);
            drawState(waterMode, waterState, 406, 246, waterSprite);
		}
	}
       // timeout to home screen
	if(screenState != 0 && screenState != 6 && timeSinceLastPress/1000 > HOME_TIMEOUT)
	{
		dataSave(screenState);
		screenUpdate = true;
		screenState = 0;
	}

My issue is as follows: if I am running the Arduino while connected to the computer (USB power source) after the set amount of time the condition
(screenState != 6 && timeSinceLastPress/1000 > LCD_TIMEOUT)
turns true and the screen enters state 6. However, if I place the Arduino on the PCB and power it via the DC-DC converter it never happens. Program is running just fine and there aren't any other issues, however it simply fails to enter the condition. What I tried:

  • powering Arduino from 5V USB cable from the computer, connected to just the screen: program runs fine, screen enters state 6;
  • connecting Arduino the the whole PCB, but leaving the 12V power supply off, so power is still provided via 5V USB cable from the computer: program runs fine, screen enters state 6;
  • connecting Arduino the the whole PCB and powering it via the 12V (which gets converted to 5V via a buck converter): program runs fine, but the condition
    (screenState != 6 && timeSinceLastPress/1000 > LCD_TIMEOUT)
    never turns true and the screen never gets to state 6.
    I am not making any other change to the code or the connections.

I am baffled and do not understand at all this behavior. It seems to only be caused by the different power source, as there are no issues when the circuit on the PCB is used but power is provided via the 5V USB connection.
I tested for any possible problem: 5V power with the DC-DC converter is at 5.0V, so there are no power delivering issues.
What is even more strange is that the second condition
(screenState != 0 && screenState != 6 && timeSinceLastPress/1000 > HOME_TIMEOUT)
always works fine. After HOME_TIMEOUT seconds the screen gets to state 0.

Does anybody have any clue on why this is happening? Thank you!

is DC-DC buck converter is grounded too?

I have 220V AC power coming into 12V transformer, then there is the buck converter.

DC-DC converter inputs are wired with +12V and GND coming from the 12V transformer and on the outputs I have +5V and GND. GND have both the same potential, as they have 0 Ohm resistance between them.

ok. how big is capacitor at 5V output of DC-DC?
or set additional capas 100+ µF

This is the DC-DC converter I am using.
I have not set up any additional capacitors.

But even then, why would the lack of a capacitor compromise only a single part of the program?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.