Drakondman
Posts: 19
Joined: Mon Mar 09, 2020 6:32 pm

Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Mon Mar 09, 2020 7:04 pm

Hello, I'm fairly new to this and i've been stumped with this problem for awhile now.

I currently have a pi 3B+ hooked up to a relay:
https://www.amazon.com/JBtek-Channel-Mo ... 1993&psc=1

And also it is hooked up to the official raspberry display

The problem I have is that my application is constantly switching the relay in order to turn a DC 24V power supply and for some reason my touchscreen starts acting weird and occasionally will fade to white then to black and then will just start the whole thing over again. I've tried powering the screen separately which did not help. So I think something that the relay is doing is messing with the DSI Ribbon Connection.

I made a video showing this issue here: https://www.youtube.com/watch?v=LvV8tr9 ... e=youtu.be

I've heard that it might be relay fly-back but im not that sure. The relay should already have something inside to deal with that sort of thing

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 12:36 pm

How are you powering the relay board and how is it connected to the pi ?

Is the relay board active low or active high ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Drakondman
Posts: 19
Joined: Mon Mar 09, 2020 6:32 pm

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 3:41 pm

Thanks for the reply. The Pi is being powered via a 5v power supply and the monitor is being powered from the pie but I have also tried to power it separately but that did not help. It still flickered.

The Relay has to get power from the pi to be controlled by the Pi I've tried powering it separate as well. It is connected via GPIO pins and the 5v pin ( it does not work with the 3v3) it is also grounded on one of the pi's ground pins.

The relay is active whenever I use GPIO.OUTPUT.LOW so I guess low.

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 5:43 pm

So powering the relay board from the pi can cause several problems , sudden voltage dips due to the relay/relays being activated and electrical noise being put on the pi 5v or ground rails by the activation/deactivation of the relays.

Also by powering the relay board completely at 5V you are using the gpio pins as grounds for the 5V being passed through the opto isolator circuits, which is not good for the pi gpio which is not 5V tolerant.

there are several ways you could try interfacing your relay board to the pi while using a separate power supply to power the relay board.

The first I suggest you try is this one.

1. on the relay board remove the jumper marked JD-VCC - VCC ( don't loose it you may need it if this does not work )
2. connect VCC pin to the pi 3.3v pin on the gpio header
3. connect a separate 5V power supply to JD-VCC pin and ground pin on the relay board
4. connect ground from pi to ground on relay board.

then test to see if your relays will actually work like this ( some board will work others don't its just pot luck as it depends on the component values chosen for the control circuit on the relay board ).

if the relays don't work like this or you still have problems then let me know and I will offer other solutions.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
Burngate
Posts: 6290
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 6:54 pm

Drakondman wrote:
Tue Mar 10, 2020 3:41 pm
The Relay has to get power from the pi to be controlled by the Pi I've tried powering it separate as well. It is connected via GPIO pins and the 5v pin ( it does not work with the 3v3) it is also grounded on one of the pi's ground pins.
The Amazon 4-relay board has a "JD-VCC - VCC" link. If you remove that link you can provide 5v to JD-VCC to power the relays, and 3v3 to the VCC pin for the optoisolators.

If you then power the relays from a separate supply, it may alleviate your problem

Drakondman
Posts: 19
Joined: Mon Mar 09, 2020 6:32 pm

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 7:13 pm

It did not work. I still get screen flickering. Whenever I take out the wire from the relay the screen does not flicker.

I did the JD VCC

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 7:46 pm

Drakondman wrote:
Tue Mar 10, 2020 7:13 pm
It did not work. I still get screen flickering. Whenever I take out the wire from the relay the screen does not flicker.

I did the JD VCC
Which wire are you removing that solves the problem.

Did you power the relay board from another supply not from the pi /screen supply ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Drakondman
Posts: 19
Joined: Mon Mar 09, 2020 6:32 pm

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 7:54 pm

pcmanbob wrote:
Tue Mar 10, 2020 7:46 pm
Drakondman wrote:
Tue Mar 10, 2020 7:13 pm
It did not work. I still get screen flickering. Whenever I take out the wire from the relay the screen does not flicker.

I did the JD VCC
Which wire are you removing that solves the problem.

Did you power the relay board from another supply not from the pi /screen supply ?
I removed my 24v line going through the relay to a solenoid. And yes I did

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 8:07 pm

In your video clip you appear to be turning the relay on / off fairly rapidly, I wounder if this is causing arching on the relay contacts with is producing a lot of RF interference.

Relays are not the best solution if you want to switch things on / off rapidly.

You could test this by powering the relay board from an external 5V supply, removing all wires between the pi and the relay board , replace the jumper on JD-Vcc - Vcc.
Then manually triggering the relay with a wire between ground on the relay board and the IN pin on the relay board, at the same rate your program does.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Drakondman
Posts: 19
Joined: Mon Mar 09, 2020 6:32 pm

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 8:12 pm

is there something better for what I want it to do? It does that every time it switches off regardless of the time in between

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 8:24 pm

Ok so is you 24V AC or DC ?

Did you try the test I suggested in my last post ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Drakondman
Posts: 19
Joined: Mon Mar 09, 2020 6:32 pm

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 8:34 pm

The 24v is DC, Yes I tried it, it just turned on and off without any issue

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 8:40 pm

Drakondman wrote:
Tue Mar 10, 2020 8:34 pm
The 24v is DC, Yes I tried it, it just turned on and off without any issue
Was that with the 24V connected and switching the solenoid ?

Just how short is the time between relay on and relay off ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Drakondman
Posts: 19
Joined: Mon Mar 09, 2020 6:32 pm

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 8:44 pm

pcmanbob wrote:
Tue Mar 10, 2020 8:40 pm
Was that with the 24V connected and switching the solenoid ?

Just how short is the time between relay on and relay off ?
[/quote]

Yes it is the wire connected to the solenoid

currently I have it set to 1000 ms on 1000 ms off

I also have a manual toggle on and off which the effect always is when it hits off

User avatar
PeterO
Posts: 5829
Joined: Sun Jul 22, 2012 4:14 pm

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 8:54 pm

Drakondman wrote:
Tue Mar 10, 2020 8:44 pm
Yes it is the wire connected to the solenoid

currently I have it set to 1000 ms on 1000 ms off

I also have a manual toggle on and off which the effect always is when it hits off
Have you got a "fly-back" diode across the solenoid coil ?
https://resources.altium.com/bill-of-ma ... r-circuits
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 8:57 pm

If you are switching that quickly you probably should be using a transistor circuit, as your relays won't last long.

Do you have a reverse voltage diode connected across the solenoid ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Drakondman
Posts: 19
Joined: Mon Mar 09, 2020 6:32 pm

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 8:59 pm

No i dont, how do i go about that.

User avatar
PeterO
Posts: 5829
Joined: Sun Jul 22, 2012 4:14 pm

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 9:00 pm

pcmanbob wrote:
Tue Mar 10, 2020 8:57 pm
Do you have a reverse voltage diode connected across the solenoid ?
Tap Tap Tap..... IS this thing on ?????? :lol:

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Drakondman
Posts: 19
Joined: Mon Mar 09, 2020 6:32 pm

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 9:01 pm

Should I use a fly back or a reverse diode or sky they thr same thing

User avatar
PeterO
Posts: 5829
Joined: Sun Jul 22, 2012 4:14 pm

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 9:04 pm

Drakondman wrote:
Tue Mar 10, 2020 9:01 pm
Should I use a fly back or a reverse diode or sky they thr same thing
They are the same thing .
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Drakondman
Posts: 19
Joined: Mon Mar 09, 2020 6:32 pm

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 9:06 pm

What's a transistor circuit I cannot find one

pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 9:11 pm

PeterO wrote:
Tue Mar 10, 2020 9:00 pm
pcmanbob wrote:
Tue Mar 10, 2020 8:57 pm
Do you have a reverse voltage diode connected across the solenoid ?
Tap Tap Tap..... IS this thing on ?????? :lol:

PeterO
I was probably typing on my tablet while you were posting. :D

Great minds think alike :lol:
Last edited by pcmanbob on Tue Mar 10, 2020 9:17 pm, edited 1 time in total.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported


pcmanbob
Posts: 9298
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 9:16 pm

Take a look at this site https://elinux.org/RPi_GPIO_Interface_Circuits
You will need to select a suitable transistor that you can switch with 3.3 V and can switch 24V at the current you solenoid needs to operate.

You will also need the reverse voltage / fly back diode across the solenoid or you will distroy the transistor very quickly.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
PeterO
Posts: 5829
Joined: Sun Jul 22, 2012 4:14 pm

Re: Offical Rasberry Pi 7in'' Touchscreen Flickering with relays

Tue Mar 10, 2020 9:21 pm

pcmanbob wrote:
Tue Mar 10, 2020 9:16 pm
Take a look at this site https://elinux.org/RPi_GPIO_Interface_Circuits
You will need to select a suitable transistor that you can switch with 3.3 V and can switch 24V at the current you solenoid needs to operate.

You will also need the reverse voltage / fly back diode across the solenoid or you will distroy the transistor very quickly.
As there is already an noise problem, I would strongly suggest including opto-isolation as well to avoid any potential ground loops that could couple switching noise into the PI/LCD.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Return to “Troubleshooting”