spookbag
Posts: 4
Joined: Tue Jul 15, 2014 2:39 pm

Capabilities question

Tue Jul 15, 2014 2:50 pm

Hi guys,

Please excuse me introducing myself with an immediate question but I'm just trying to establish whether I'm barking up the wrong tree or not.
I have no actual hands on experience of Raspberry Pi although I've been aware of it for a long time. I have a project that I think may suit a Pi but I'd like to ask some knowledgeable people whether this is possible before I go and invest in the hardware and start experimenting.

In a nutshell - I want to monitor a dry contact. When the contact is closed I would like to display one jpeg image on a screen. When the contact is open I would like to display a second image on the screen instead. That's literally it.
I'd need the system to boot into this application/function if it was powered off and on again.
Is this possible?

I really appreciate anyone taking the time to give me any info on this subject.

Many thanks :)

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Capabilities question

Tue Jul 15, 2014 3:58 pm

very possible, Richard Robust had a similar one so his code should work for you (with a small amount of modification).
Doug.
Building Management Systems Engineer.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26659
Joined: Sat Jul 30, 2011 7:41 pm

Re: Capabilities question

Tue Jul 15, 2014 4:00 pm

Pretty sure that is pretty easy, but just to be sure - what do you mean by dry contact - a simple switch plugged in to the Pi, or switch controlling something else that you want to monitor with the Pi? I expect the latter from your description, and if so what sort of switch is it?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

spookbag
Posts: 4
Joined: Tue Jul 15, 2014 2:39 pm

Re: Capabilities question

Tue Jul 15, 2014 5:57 pm

Thanks for the replies.

The dry contacts are basically a continuous circuit that is opened or closed by the device - in this instance a relay.
I guess electronically it is the equivalent of a simple on off switch. When the switch is open the path from wire A through to wire B is broken. I assume that kind of functionality is fairly basic with some sort of circuit board attached to the Pi?


BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Capabilities question

Wed Jul 16, 2014 7:13 am

spookbag wrote:Thanks for the replies.

The dry contacts are basically a continuous circuit that is opened or closed by the device - in this instance a relay.
I guess electronically it is the equivalent of a simple on off switch. When the switch is open the path from wire A through to wire B is broken. I assume that kind of functionality is fairly basic with some sort of circuit board attached to the Pi?
Trivially easy, switch 3v3 to a GPIO with a resistor in circuit (and a 2nd resistor pulling the GPIO to Gnd to prevent the signal bouncing).

Trivially easy, switch a GPIO to GND with a resistor in circuit (and a 2nd resistor pulling the GPIO to 3v3 to prevent the signal floating).
Last edited by BMS Doug on Wed Jul 16, 2014 10:29 am, edited 1 time in total.
Doug.
Building Management Systems Engineer.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Capabilities question

Wed Jul 16, 2014 7:42 am

BMS Doug wrote: Trivially easy, switch 3v3 to a GPIO with a resistor in circuit (and a 2nd resistor pulling the GPIO to Gnd to prevent the signal bouncing).
That makes no sense. A resistor to ground does not prevent contact bounce. We do it in software these days anyway.

User avatar
rpdom
Posts: 17173
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Capabilities question

Wed Jul 16, 2014 8:10 am

ame wrote:
BMS Doug wrote: Trivially easy, switch 3v3 to a GPIO with a resistor in circuit (and a 2nd resistor pulling the GPIO to Gnd to prevent the signal bouncing).
That makes no sense. A resistor to ground does not prevent contact bounce. We do it in software these days anyway.
It does stop the input from floating though, and removes EM noise a bit.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Capabilities question

Wed Jul 16, 2014 8:56 am

rpdom wrote:
ame wrote:
BMS Doug wrote: Trivially easy, switch 3v3 to a GPIO with a resistor in circuit (and a 2nd resistor pulling the GPIO to Gnd to prevent the signal bouncing).
That makes no sense. A resistor to ground does not prevent contact bounce. We do it in software these days anyway.
It does stop the input from floating though, and removes EM noise a bit.
No. The pullup to 3.3V stops the input from floating. Adding a pulldown just turns it into a potential divider.

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Capabilities question

Wed Jul 16, 2014 10:31 am

ame wrote: No. The pullup to 3.3V stops the input from floating. Adding a pulldown just turns it into a potential divider.
error corrected.

Spookbag: yes the Pi can easily do what you want it to.
Doug.
Building Management Systems Engineer.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13092
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Capabilities question

Wed Jul 16, 2014 10:42 am

To be clear, the second resistor, the one in series with the GPIO, is a current limiting resistor that will limit the GPIO's output current when you accidentally program the GPIO as output and the switch contacts happen to be closed (shorted to GND) a safe current limit would be 3.3mA, for which an 1K resistor is suitable.

spookbag
Posts: 4
Joined: Tue Jul 15, 2014 2:39 pm

Re: Capabilities question

Wed Jul 16, 2014 11:45 am

Thanks again for the responses guys.
I have to admit most of this debate is lost on me but if you're all confident it is possible that's good enough for me.
Are there any pitfalls to avoid when I purchase gear? I've noticed they sell it in Maplins up the road but it seems to be a 'Starter Kit' and I've read about different hardware versions etc.
Failing that am I better to just buy online?
Sorry for all the questions but you guys know the inside track! :)
Hopefully in a years time I'll be on here answering all the noob's questions. :D

Many thanks.

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Capabilities question

Wed Jul 16, 2014 12:39 pm

I wouldn't buy a starter kit unless you needed an overpriced mouse and keyboard combo.

buy the raspberry Pi B+ you can get one from RS or element 14

Pimoroni Have a B+ and case + NOOBS card for £45.00

USB Keyboard and mouse (if you can't just borrow them from your PC) can be purchased anywhere.

a WIFI dongle can be found on amazon from about £3.00 if you want that.

2a 5V power supply (not too cheap, the cheap ones can't be trusted).

HDMI cable can be borrowed from existing equipment if you have any.

details of exactly what you need will vary depending on your desired application but you will need to do initial setup with a keyboard and (preferably) an HDMI screen.
Doug.
Building Management Systems Engineer.

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Capabilities question

Wed Jul 16, 2014 12:50 pm

spookbag wrote:
In a nutshell - I want to monitor a dry contact. When the contact is closed I would like to display one jpeg image on a screen. When the contact is open I would like to display a second image on the screen instead. That's literally it.
I'd need the system to boot into this application/function if it was powered off and on again.
Is this possible?

Do you already have a screen in mind (using a screen that you already own) or were you planning on getting a screen just for this project?

There are quite a lot of options for small screens until above a certain size it becomes more cost effective to just use a HDTV (unless touchscreen input is required).
Doug.
Building Management Systems Engineer.

spookbag
Posts: 4
Joined: Tue Jul 15, 2014 2:39 pm

Re: Capabilities question

Wed Jul 16, 2014 2:28 pm

Thanks Doug,

I've got a small (HDMI input) Monitor that I used to use for configuring CCTV so I'll use that initially.
In the fullness of time I will need to find some sort of compatible wall mounted screen (approx 8-12 inch) but I suspect that may be easier said than done. :)

shdwmstff
Posts: 1
Joined: Mon May 01, 2017 5:39 pm

Re: Capabilities question

Mon May 01, 2017 5:50 pm

FYI
Newbie user

I'm looking to do something similar.. Just want to make sure "electronically" I do this correctly.


I want to monitor a dry contact. No voltage.. just open/closed
pretty much like a switch , I want to log the date/time the switch closes .. then will log the date/time it opens.
I will do more with the data later on but getting the open/close data in without burning out the PI is the first goal.

I intend on using a 120v AC relay , that when powered up it will close a dry contact that the Raspberry Pi can read.
http://www.alliedelec.com/opto-22-120a10/70133850/

Would I need to put a resistor between this or just connect the dry contact to the GPIO.?

Thanx

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: Capabilities question

Thu May 04, 2017 3:12 pm

shdwmstff wrote:FYI
Newbie user

I'm looking to do something similar.. Just want to make sure "electronically" I do this correctly.


I want to monitor a dry contact. No voltage.. just open/closed
pretty much like a switch , I want to log the date/time the switch closes .. then will log the date/time it opens.
I will do more with the data later on but getting the open/close data in without burning out the PI is the first goal.

I intend on using a 120v AC relay , that when powered up it will close a dry contact that the Raspberry Pi can read.
http://www.alliedelec.com/opto-22-120a10/70133850/

Would I need to put a resistor between this or just connect the dry contact to the GPIO.?

Thanx
The inline resistor is to stop the GPIO from burning out if you set the GPIO to output while the relay is closed. 1k will do the trick.
A pullup or pulldown resistor stops the GPIO from floating while the relay is open, which could give you false positives for relay operation. Internal pullup/pulldown resistors are available and can be set in software.
Doug.
Building Management Systems Engineer.

Return to “General discussion”