hmzi1234
Posts: 9
Joined: Fri Oct 28, 2022 10:25 am

Screen going black

Mon May 29, 2023 5:10 pm

Hello, I've made a program and I've got into an issue and i was wandering if i can somehow fix it.
I've made a program that recognizes people and based on them it open a solenoid lock. The problem is that when the lock is gets opened and/or closed monitor goes black for half of a second or so.
I was wandering what might be the problem and if i can fix this from happening! Thank you!

User avatar
thagrol
Posts: 9843
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Screen going black

Mon May 29, 2023 5:46 pm

Power?

Is your PSU able to supply enough current to ruyn the Pi, the screen, and the solenoid at the same time?
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

hmzi1234
Posts: 9
Joined: Fri Oct 28, 2022 10:25 am

Re: Screen going black

Mon May 29, 2023 6:01 pm

I've got a PSU of 5.1V and 3A and the thing connected to the rpi are this: A 16x2 lcd screen, a fan, a USB camera, a dongle for the keyboard, the hdmi cable to the monitor, and the relay that is used for the solenoid lock to be connected. I think they should draw that much.

User avatar
kerry_s
Posts: 6001
Joined: Thu Jan 30, 2020 7:14 pm

Re: Screen going black

Mon May 29, 2023 8:37 pm

hmzi1234 wrote:
Mon May 29, 2023 5:10 pm
Hello, I've made a program and I've got into an issue and i was wandering if i can somehow fix it.
I've made a program that recognizes people and based on them it open a solenoid lock. The problem is that when the lock is gets opened and/or closed monitor goes black for half of a second or so.
I was wandering what might be the problem and if i can fix this from happening! Thank you!
how are you running the program ? loop ?

hmzi1234
Posts: 9
Joined: Fri Oct 28, 2022 10:25 am

Re: Screen going black

Mon May 29, 2023 9:16 pm

kerry_s wrote:
Mon May 29, 2023 8:37 pm
hmzi1234 wrote:
Mon May 29, 2023 5:10 pm
Hello, I've made a program and I've got into an issue and i was wandering if i can somehow fix it.
I've made a program that recognizes people and based on them it open a solenoid lock. The problem is that when the lock is gets opened and/or closed monitor goes black for half of a second or so.
I was wandering what might be the problem and if i can fix this from happening! Thank you!
how are you running the program ? loop ?
its a python gui made with tkinter that has a function that runs as a loop

User avatar
thagrol
Posts: 9843
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Screen going black

Mon May 29, 2023 11:35 pm

hmzi1234 wrote:
Mon May 29, 2023 6:01 pm
I've got a PSU of 5.1V and 3A and the thing connected to the rpi are this: A 16x2 lcd screen, a fan, a USB camera, a dongle for the keyboard, the hdmi cable to the monitor, and the relay that is used for the solenoid lock to be connected. I think they should draw that much.
That implies that the HDMI screen and the solenoid are not drawing their power from the pi. Correct?

Some further questions:
  1. Which model Pi are you using?
  2. Which OS is it running on? Desktop or command line?
  3. Which screen is blanking out? The HDMI one or the character LCD?
  4. What sort of relay?
  5. How much current does its coil require?
  6. Do you have an anti back emf diode across the relay's coil?
  7. Are you driving the relay directly from one of the Pi's GPIO?
  8. Have you tested with the fan disconnected? Unless you live in the tropics and the Pi is under heavy load there is no real need for a fan.
  9. Can you share your wiring diagram and code?
If you're running the relay directly from the Pi's GPIO, be aware that you can source a maximum of 16mA from a single GPIO and the total 3.3v load across all GPIO and, I think, the 3.3v power pins should not exceed around 60mA. Go over those limits and bad things will happen.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

hmzi1234
Posts: 9
Joined: Fri Oct 28, 2022 10:25 am

Re: Screen going black

Tue May 30, 2023 9:42 am

1. RPi model 4b 4gb
2. RPI OS
3. The HDMI one
4. A 5v generic relay
5. I didn't find any info regarding that.
6. Don't think so, i'm not good at electronics and how they work or so.
7. Yes, i've tried using a breadboard power syupply but i dont think that is possible.
8. Yes, it's still the same problem, even tried without the camera and the 16x2 lcd screen disconnected. And also the fan is 100% needed in this because the temperature of the cpu gets to 70-80 while running the program.
9. Ill provide a code that uses only the relay connected and nothing else, but still has the same problem, blacking out the screen

Code: Select all

import RPi.GPIO as GPIO
from time import sleep
GPIO.setwarnings(False)

GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.OUT)

while (True):    
    
    GPIO.output(24, 1)
    sleep(1)
    GPIO.output(24, 0)
    sleep(1)

hmzi1234
Posts: 9
Joined: Fri Oct 28, 2022 10:25 am

Re: Screen going black

Tue May 30, 2023 10:12 am

After a lot of testing with a lot of different relays and different connections, I've managed to fix the issue.
The issue was somehow related to the monitor I'm using, or at least the cables i was using.
I've had the RPi connected to its own monitor, with a micro hmdi-hdmi cable and a dvi adaptor ( it's an older monitor), and I thought to try it on my PC monitor with a microHMDI-HMDI adaptor and a HDMI HDMI cable. And the problem stopped without changing the code or anything, with all the parts still conected to it.
Thanks though for your answers!

User avatar
kerry_s
Posts: 6001
Joined: Thu Jan 30, 2020 7:14 pm

Re: Screen going black

Tue May 30, 2023 10:17 am

i think it's a common thing with loops as there's a bit of a restart/relaunch of the script.
depending on the script, most of the time it's not noticeable when the script is fast.

what's the refresh on the problem screen ?

Return to “Beginners”