LowPowerLab Forum

Hardware support => Moteino => Topic started by: ulnpiper on November 13, 2014, 08:25:22 PM

Title: Separating USB Power from Vin [SOLVED]
Post by: ulnpiper on November 13, 2014, 08:25:22 PM
I've searched and can't seem to find if anyone has done this.

First the background.  I'm using a Beaglebone Black rev. C to drive a Moteino r4 (with RFM69W radio not in use + 4M flash also not in use) via a USB cable and FTDI to USB board to control my beer fridge fermentation chamber.  The code I'm using is http://www.brewpi.com/ and have it hooked up identically to this  ( http://www.homebrewtalk.com/f51/howto-make-brewpi-fermentation-controller-cheap-466106/ ) except using a BBB and Moteino instead of a Rasp Pi and Arduino UNO.

When I first put it together, I didn't have relays yet and was using it for just a monitor (fridge temp controlled by an STC-1000).  I was also stealing 110v power off of the old icemaker connector and powering the BBB via a 1amp 5V old blackberry wall wart.  This periodically would lose connectivity to the ttyUSB port connecting the BBB to the Moteino.  The Moteino is powered by this USB via the BBB.  I tried troubleshooting this, but all I could see is that the tty port would start loosing sync with the Moteino and would shut down, causing the Brewpi Python script on the BBB to stop running with an error message "serial write failed, no such device."  This would happen every 20 mins to 5 hours.

Other people complained that if they didn't have enough power for their RPI + UNO combo, they experienced similar issues.  So I ran an extension cord into the fridge to power the BBB + Moteino, and that made the problem go away.  No errors in over 10 days.

Now I've connected relays to the system to control cooling and heating, and am powering them off of the 3.3V pin on the Moteino for the control circuit (should draw about 20 ma to power the LED indicator) on the Sainsmart relay board.  5v to power the relay side I'm taking off of the Vin pin on the Moteino (another 20 ma to drive the relay itself).  This pin is also powering 3 x ds18B20 1-wire temperature sensors. (4 ma max current draw each).

Now my ttyUSB port problem is back!  While I don't have any direct evidence that it is power related (e.g. when I measure Vin it's 4.7v, 3.3 source measures 3.29v from the Moteino), I strongly suspect that is my issue.  When it's in the failed state, the BBB USB port no longer supplies 4.7 V to the Moteino, but if I do an >ls usb the OS can still see the USB FTDI device.  When I do a soft reboot of the BBB via shutdown -r, everything starts working again until the next failure 20 mins to a few hours later.

According to the BBB, if you're powering it off of the USB connector the max it can supply to it's USB host port is 50 - 100 ma.  So as you can see I'm pushing that already between running the Mote, driving the temp probes, the relay control circuit and the relay itself.

Two solutions:
1) I've ordered a 5v 2A power supply to drive the BBB via the actual power plug rather than via the USB port.  That should be here in a couple of days and should help.  According to the specs, then the USB host of the BBB should be able to supply 500 ma when powered this way.
2) If #1 doesn't solve the problem, is there a way to separate the USB communications from the USB power on the Moteino + FTDI <-> USB?  In other words, I believe the next step would be to use one power supply to drive the BBB and another to drive the Moteino + relays + temp probes.

In the meantime, any recommendations on how to troubleshoot this and pin down the exact root cause?

Thanks!
Gary
Title: Re: Separating USB Power from Vin
Post by: Felix on November 13, 2014, 08:53:11 PM
I definitely think you are having a power issue. You are trying to do a lot of stuff off a very small power supply. The relays should be transistor driven, and powered from a dedicated power supply or isolated from the digital power supply. The relays are inductive and can spike on order of a few hundred mA or more when switching depending on size so that can throw off your BBB right there. A protection diode helps avoiding most of that inductive kickback, but it's not clear if your relay board has that but I assume the relay board does use transistors to power the relays. The Moteino probably needs on the order of 20-25mA at most by itself if you power it through USB. A few low power sensors will not have a dramatic impact so a 100mA supply is probably plenty for that purpose. But driving relays can add more especially if there are LEDs and other bells and whistles on that sainsSmart relay board. The relays is where I think you should look into, to me it really sounds like that's where your problem is.

Any chance you can share your project/photos/progress in this forum or a link if you blogged about it?
It would be interesting to see how you use the Moteino for brewing :)
Title: Re: Separating USB Power from Vin
Post by: ulnpiper on November 13, 2014, 10:24:35 PM
Felix, I'd be happy to post progress here (I'm assuming you want it in the projects forum).  I'm also planning to write an article about it for Homebrewtalk.com.

Your suggestion is spot on.  I took a second wall wart and am using that to power the relays by themselves.  The sainsmart board has opto isolation between the control circuit and the relay power circuit. (see below)

This also caused me to find that I had the power crossed and was using 3.3v to power the relays and 5v to drive the control circuit...oops!

Thank you!  So far it's been running for 1 hour without a problem.

Here is a pic of what I have so far.  It's mounted on a board for the moment until I get the bugs worked out and then I'll put it into a real box.  It's a little fuzzy, but you can see the Moteino on the top right.  I labeled it #2 as it was originally node #2 when I was using the radio.
(http://southeastpipersclub.org/files/brewbeagle2.jpg)


(http://southeastpipersclub.org/files/sainsmartrelay.jpg)
Title: Re: Separating USB Power from Vin
Post by: ulnpiper on November 13, 2014, 10:33:25 PM
Just an fyi.  The way Brewpi works is the Arduino controls the fridge using the sensors, PID and relays.  The RPI collects logs, displays it on a webpage and provides a user interface to adjust parameters.

My plan is to separate the BBB and Moteino via the radio link, essentially extending the USB cable over the radio link.  So Moteino will control the fridge and BBB with another Moteino as a gateway will collect the data and pass commands.  Then the BBB can be located anywhere in the house and you don't have to run a network cable or use wifi to get it on the network.

The guys who wrote brewpi have used almost all the code space on the Arduino to pack as many features in as they can. Fortunately it's all open source, so I can fork their code and build on what's already done. 

Once I get the system as designed stable, that'll be the next step.
Title: Re: Separating USB Power from Vin
Post by: Felix on November 13, 2014, 11:07:39 PM
Oh a bit fuzzy but yes I think the Projects forum would be more suitable.
If you write a blog post be sure to include that!
But great stuff, I am somewhat familiar with BrewPi, and I'm thrilled you are using Moteino to eliminate cables. I love Moteinos put to great use :)
Title: Re: Separating USB Power from Vin
Post by: ulnpiper on November 14, 2014, 09:02:38 AM
Felix, glad to say the BrewPi scripts ran all night last night without a problem.  It looks like your idea solved the issue!

Thanks, and I'll get something project-wise posted in the next couple of weeks.

-gary