PLCGuy
Posts: 22
Joined: Sat Aug 10, 2013 12:01 pm

Critique Please: 1st RPi Circuit

Wed Aug 14, 2013 5:47 pm

Hi - Before I blow up or burn down something, I'm hoping to get feedback on my first RPi circuit. This isn't built yet, I don't have the RPi yet (on its way!), so I could be completely wrong and not know it.

I'm building a sous vide cooking controller. A common project I know, but this seemed like a fun way to kill time. The general setup is this:
  • Temperature sensing using a high-temperature waterproof packaged DS18B20: (http://www.adafruit.com/products/642
  • Display and user inputs via a 16x2 LCD + 4 button keypad, connected using a GPIO expander over I2C: http://www.adafruit.com/products/1109
  • Power to the PI via 5V supplied to the GPIO pin, not through the USB mini - I *will* be cannibalizing a USB mini charger for parts, but intend to hardwire the power in the final assembly.
  • The unit will be used to switch power on and off to a a plain old on/off slow-cooker. The slow cooker will be 1000W or less.
  • Switching of the slow cooker will be done via a mechanical relay (I'm worried about an SSR failing in the On state).
  • The relay will be a 5V coil, driven through a ULN2803A chip to provide a buffer, level change, and increased current.
Down the road I may choose to improve the fail-safeness of the device by using a monostable timer (discussed in this post: http://www.raspberrypi.org/phpBB3/viewt ... 08#p374008. I am only worried about failures caused by my code crashing, or the RPi OS crashing. I am not worried about edge cases of the relay failing on. This will be running a slow cooker which is inherently safe to leave on for long periods, especially when it's full of water anyway.

Attached is my schematic - I'd really appreciate any feedback or corrections anyone might be generous enough to offer.

Looking forward to the build!

Thanks
Attachments
YASV_M1 E.JPG
YASV_M1 E.JPG (60.01 KiB) Viewed 1972 times

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2351
Joined: Thu Jul 11, 2013 2:37 pm

Re: Critique Please: 1st RPi Circuit

Wed Aug 14, 2013 9:21 pm

I am enamoured by your diligent use of the classic black-on white colour scheme. Your congruent main AC busbars are also appealing and de rigeur.

But seriously - if you're using mains electrik in your design then you need to think protection - both from fingers and from fire. Your 10A fuse is a good start - but I'd put in the smallest fuse you can get away with. I would also put a branch fuse in for your USB 5V adapter - this will catch fire way before the 10A fuse pops. 1-2A would be a typical value.

Your relay should be sufficiently rated for switching a resistive load at ~10A - which most are. Your 2803 is wired correctly.

As a fail-safe, you should use the hardware watchdog. You can set this up through mmap, or the kernel driver will do this all for you and only actually reset should the Pi itself lock up. If you enter your program and set up the watchdog via mmap'd IO addresses, then in your main loop kick said sleepy dog, the kernel is none the wiser and does nothing to interfere. If your program gets stuck for any reason then it won't kick the watchdog, the Pi will reboot and all GPIOs end up as inputs* which won't turn on your 2803.

[1] for given values of GPIO, some restrictions apply.
Rockets are loud.
https://astro-pi.org

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

Re: Critique Please: 1st RPi Circuit

Thu Aug 15, 2013 9:54 am

jdb wrote:... Your 2803 is wired correctly...
Your relay appears to be wired from pin 18 - the collector of the darlington pair - to ground.
Shouldn't it go to the 5v rail?

PiGraham
Posts: 3929
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Critique Please: 1st RPi Circuit

Thu Aug 15, 2013 11:03 am

jdb wrote:But seriously - if you're using mains electrik in your design then you need to think protection - both from fingers and from fire. Your 10A fuse is a good start - but I'd put in the smallest fuse you can get away with. I would also put a branch fuse in for your USB 5V adapter - this will catch fire way before the 10A fuse pops. 1-2A would be a typical value.
The 10A fuse is inline with the slow cooker so it may need to be more that 2A

I suggest a visual indicator, possibly a neon indicator, on the output to indicate it is live. Even if the Pi fails on it will show the state.
The cooker may have an indicator that will serve that purpose.
Burngate wrote:Your relay appears to be wired from pin 18 - the collector of the darlington pair - to ground.
Shouldn't it go to the 5v rail?
Agreed, the relay should wire between the 5V rail and pin 18.

Check that your 5V supply holds up when the relay switches. If the relay current slogs the PSU it could reset the Pi.
You could connect a 100uF capacitor between the power rails close to the relay coil (keep the wires short) if that's a problem.

PLCGuy
Posts: 22
Joined: Sat Aug 10, 2013 12:01 pm

Re: Critique Please: 1st RPi Circuit

Thu Aug 15, 2013 1:28 pm

Everyone thank you for your replies - I really appreciate it. Some specific responses, and a new schematic are attached...
jdb wrote:I am enamoured by your diligent use of the classic black-on white colour scheme. Your congruent main AC busbars are also appealing and de rigeur.
Unfortunately, I don't feel I was able to capture the sense of ennui felt by the temperature probe but nevertheless I feel this was an artistic statement that had to be made, given our times.
But seriously - if you're using mains electrik in your design then you need to think protection - both from fingers and from fire. Your 10A fuse is a good start - but I'd put in the smallest fuse you can get away with. I would also put a branch fuse in for your USB 5V adapter - this will catch fire way before the 10A fuse pops. 1-2A would be a typical value.
Ok, so I didn't explain this very well - I intend to steal the entire contents of a MicroUSB charger, including any internal fusing. Since the charger itself is expecting to plug into a 15-20A wall outlet, I assume it's well protected internally. But why assume when I can just add a fuse and not have to worry about it again, so that is done. I'll be careful about touch-safe. I'm not fully sure how I'm going to build the enclosure, but the 120VAC will be full enclosed and touchsafe, probably physically separate from the DC side.
As a fail-safe, you should use the hardware watchdog. You can set this up through mmap, or the kernel driver will do this all for you and only actually reset should the Pi itself lock up.
Can you explain this a bit more or point me at some resources? I understand the watchdog part and overall concept, I don't fully understand what I need to do to implement it. From the sounds of it, this is exactly something I was hoping to be able to do, except I was thinking I'd have to write a separate safety thread/program myself.
PiGraham wrote:You could connect a 100uF capacitor between the power rails close to the relay coil (keep the wires short) if that's a problem.
I added it in - even if it might be a problem I'd rather not worry about it for the cost of a capacitor.

Rev 2:
Attachments
YASV_M1v2 E.JPG
YASV_M1v2 E.JPG (26.41 KiB) Viewed 1862 times

PiGraham
Posts: 3929
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Critique Please: 1st RPi Circuit

Thu Aug 15, 2013 1:39 pm

The capacitor should go between 5V and 0V so it sits charged to supply voltage. The idea is that it will supply a little extra kick when the load is energised. Don't connect it across the relay coil terminals, which are normally not energised. That could actually cause a problem due to high initial charging current. You could put it between pins 9 & 10 (5V & 0V) of the ULN2803A. Don''t use it uneless you have a problem with resets when the relay fires. Keep it simple.

PLCGuy
Posts: 22
Joined: Sat Aug 10, 2013 12:01 pm

Re: Critique Please: 1st RPi Circuit

Thu Aug 15, 2013 2:53 pm

PiGraham wrote:The capacitor should go between 5V and 0V so it sits charged to supply voltage. The idea is that it will supply a little extra kick when the load is energised.
Ah - I got it, when you said keep it close to the coil, I thought it was there to give that extra kick to the coil itself. I understand now that it should be on the supply near where the coil connects to draw power, so that when the coil does start to draw power the capacitor can help.

But, as you suggest, I'll drop it unless it proves necessary. Thanks!

boyoh
Posts: 1468
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Critique Please: 1st RPi Circuit

Thu Aug 15, 2013 9:38 pm

You seem to be building your house, before you lay the foundations.
First stick to using a purpose built power adapter
Don't connect the Domestic mains Earth wire to the Pi GND
The Pi GND is at 0.0v relative to the Pi 3.5v & 5v .it is the negative side of the
DC power supply
The AC mains primary side is totally isolated from the secondary side of the adapter
The secondary side is the low AC voltage that is full wave rectified to 5v DC
Feeding the Pi ,using the Micro USB from the power adapter is best way
You could hit Boot up problems, not doing it the correct way
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

PLCGuy
Posts: 22
Joined: Sat Aug 10, 2013 12:01 pm

Re: Critique Please: 1st RPi Circuit

Fri Aug 16, 2013 12:22 am

boyoh wrote:First stick to using a purpose built power adapter
I am - I'm just going to be removing it from it's case and direct wiring a cable to it, rather than plugging it into the wall. I need both 120VAC and 5VDC inside my enclosure, so I don't want to run two power cables from the wall.
boyoh wrote:Don't connect the Domestic mains Earth wire to the Pi GND. The Pi GND is at 0.0v relative to the Pi 3.5v & 5v .it is the negative side of the DC power supply
Ok, great point - I guess, now that I think of it, the USB power adapter doesn't have a grounding prong - so it must be floating as you recommend. So that will be the plan then for me as well. Thanks for pointing that out!

boyoh
Posts: 1468
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Critique Please: 1st RPi Circuit

Fri Aug 16, 2013 2:19 pm

Another way of switching your oven, would be to look into using
A Opto isolator switching a Power Triac, ,( AC solid state switch )
This will give you total isolation between your Pi low voltage and
Mains 120v Ac , Also no relay Contact bounce or spark noise
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

PLCGuy
Posts: 22
Joined: Sat Aug 10, 2013 12:01 pm

Re: Critique Please: 1st RPi Circuit

Fri Aug 16, 2013 6:53 pm

boyoh wrote:Another way of switching your oven, would be to look into using
A Opto isolator switching a Power Triac, ,( AC solid state switch )
This will give you total isolation between your Pi low voltage and
Mains 120v Ac , Also no relay Contact bounce or spark noise
I considered it. I decided against it for a few reasons:
1) I couldn't find one in a local store and didn't have anything else to order from an online reseller to amortize the shipping cost.
2) I'm worried about the SSR failing - especially if I order a cheap one online.
3) My switching frequency will be rather low - it's be either on or off for minutes at a time.

Return to “Beginners”