Friday, December 30, 2011

Silk Screened controller boxes

Labeling the controllers, in a way that is out-door ready, has been more difficult that I originally anticipated.

I had vinyl labels made by a sign maker, that stick on. Those work but it's difficult to get them put on right, then you have to x-acto knife all the edges and openings. It's time consuming. So I made this jig to hold the box lids so they could be silk-screened.
























I found some t-shirt makers that were willing to take a shot at screening the box lids. They used outdoor, UV resistant ink. I made the original artwork with Photoshop and Gimp.


















The finished result turned out well. The paint doesn't rub off.

































Now I have a process for making a lot of high quality controllers boxes.

Thursday, October 13, 2011

Solar Controller - Board ICSP header

The ICSP header allows you to plug a programmer onto the board so you can download new code to the microcontroller, (uC) as well as debug code that's on there. You can also use the programmer to read data off the uC.

There are other standards besides ICSP (In Circuit Serial Programming) it's used by the Microchip products. I use the PIC microcontrollers made by Microchip because they are very efficient and beat the Atmel chips at low power applications.

You can Google ICSP pinout to get the low down on the pins but it's pretty straight forward. MCLR is used to put the chip into programming mode, connect that to the MCLR pin on your uC (the uC datasheet will have all this listed out in the pin descriptions).

+5V, power and GND, ground. It needs power and ground like everything else.

DAT this is the data line where serial data (e.g. your code) gets transferred

CLK clock is used to negotiate timing between the programmer and the uC

Sparkfun.com has a nice Eagle part for this header which has the pins slightly offset so the header sticks in there and is easier to solder (or to just hold and program if you don't want a soldered in header).

To make a microcontroller board you just need power, a voltage regulator like the LM7805, a programming header like this one and your uC.

Monday, September 19, 2011

Silkscreen jig for labeling the controllers

You have to have some kind of label on the controller, that looks decent. I've been getting vinyl labels made at sign making shops and then trimming them with an X-acto knife. It turns out nice but is time consuming. So making a silk-screen jig made, so I could get some quality labels and artwork on the controller has been one of many necessary things that I didn't think I'd wind up doing when I started this project two years ago.

So the idea is that the box lids can't slide side to side and they have a common surface that is level so that they can be silk screen effectively.
























This is the finished jig. The clear acrylic was cut on my buddy's laser cutter (very handy tool, although it's a project in itself).




















Another shot of the finished jig with four box lids in place.















View from the back. Cutting holes in the back so you can pop the lids out easily once they have been screened.



















Another shot of the jig with the acrylic cover, that holds the box lids stationary. I think the acrylic will be glued down to the wood. The box lids can be installed and removed with the acrylic in place.











I let my 13-year-old daughter test drive the router. Cutting lines in plywood is still a novelty.




You can get a screen made and screen it yourself or find someone that regularly does screen work, like a T-Shirt shop, do it for you. There's plenty of instructables and resources on silk screening available online.

Monday, September 12, 2011

Solar Controller - LED/Pump Driver Circuit

The LED/Pump driver circuit is where the work get's done. Everything else is just so this section and do it's thing and make stuff move or light up or whatever.

In electricity; they like to call what's using the power the "load". So this section controls the load. It has the ability to turn the load on and off via the transistor (labeled IRL3714ZPBF for the part number I'm using).

For high power (lots of amps and volts) you need to use a MOSFET style transistor (look for an upcoming post all about them). The other BJT, bipolar junction field, transistors are just wussy and can't hang with the high power stuff. Plus, which would you rather talk about? A BJT or a MOSFET? It just "sounds" cool. This one is rated for 36 Amps, which is a lot more amps than most of your house circuits can handle. You can't run that much power without handling the heat that gets generated somehow (like with a big heat sink, chunk of metal, or a fan or something). 10 amps is a lot for a device this size.

This circuit sends power directly from the micro-controller output pin to the gate of the MOSFET transistor to turn it on. This particular MOSFET has a "logic level" gate, meaning it can be switched on and off with zero to five (5) volts (which is really handy).

The really cool thing is that you can switch the MOSFET on and off really fr**ck'n fast. Like 5,000 times per second... and that's considered slow for this kind of stuff. Getting the switching process to run cleanly when there's a lot of power running through the MOSFET is where things get tricky. If it's not switching cleanly then the MOSFET's silicon parts will be in an "in-between on and off" state for too long and they get hot because it's basically a resistor turning energy into heat in that in-between state. You need a scope (Oscilloscope) to be able to see what's going on electronically at those kinds of speeds. You can get scopes that plug into your PC for <$250.

The resistor R1, should be labeled something like 300 Ohms because it needs to current limit the output pin to a max of less than 20 milliamps in order to preserve the life of the output pin circuitry. Good MOSFET driver IC's claim drive currents in the amps (like 1.5 or even 3.0 Amps) range so the power applied to the gate, and how quickly it gets there, and goes away, is key to really running them cleanly. A MOSFET driver is not used here because the amperage is relatively low and it's cheaper not to use one.

The diode, D2, is there if you are driving a motor, like a pump. A motor is what they call an "inductive load" meaning you're powering an inductor (a piece of iron wrapped with copper wire). This makes an electro-magnet. When you suddenly stop current from flowing in an inductor the electricity wigs out and does all kinds of crazy, chaotic, explosions and things because the nature of inductors is that they want to keep current flowing. Power electronics has a lot to do with the electro-magnetic properties of inductors. So the diode is there to prevent this possible electro-magnetic explosion of energy from coming back from the motor and zapping your MOSFET dead by puttting a sudden, super high voltage spike into the drain of the MOSFET. I've heard a lot of robotics guys say they just left them off and nothing bad ever happened. But it's pretty standard knowledge that a "back EMF" protection diode is needed when switching an inductive load (such as an irrigation pump or a robot motor).

The extra cool thing about this circuit, is that when you're switching it on and off thousands of times per second you can vary how long it stays "on" for each on/off cycle. Known as PWM (Pulse Width Modulation) or changing the width of the pulse of energy your letting through your circuit, you can vary the speed of the motor very accurately. Robotics nerds are really into complicated motor driver circuits that support reverse and super quick, accurate, turning, for each wheel, etc.

This can be used as an energy conservation technique too. You can dim your LED's by varying the PWM ratio (how long the switch stays "on" for each on/off cycle). You can slow your pump motor down when the battery is nearing it's discharged level and extend battery life. So you have very accurate control of the load with a circuit like this.

For LED's you don't need the back EMF protection diode. Also worth saying that this circuit is not an LED Driver in the way that those limit current or voltage precisely. You would connect your LED driver to this circuit in order to control your LED's brightness and power consumption.




Here's a picture of the entire board. The load driver MOSFET is in the bottom right corner, with the resistor right below it. The back EMF diode is not installed and the silk-screened outline can be seen between the two MOSFET's near the bottom of the picture (the one on the left controls the solar panel - covered in a previous post)


That's a lot of words for such a simple looking schematic. It is really pretty simple and very powerful once you get a handle on how the MOSFET's work.

Water-proofing adhesive test

Silicone or Polyurethane? May the best water-proofing adhesive WIN!!!

(The seedy underbelly of solar controller construction revealed)

It will be interesting to see if there's a difference in either one after they setup for a day or so.

This is one of those things I never imagined I'd be doing when I set out to build solar powered electronic stuff; but it turns out weatherizing is a major part of the problem for solar stuff because it has to be outside.

Wednesday, August 24, 2011

Light Sensor - Let there be light, but how do you know?


Sensing light is pretty simple. Most stuff I've found on it for microcontrollers (uC's) uses LDR's or Light Dependent Resistors. The problem I have with these is two fold. 1) They mostly come in non-weather proof packages so if you left them out in the yard they'd corrode/delaminate and fail within a few months. 2) They're butt-ugly and not as accurate as a photo-transistor. Plus doesn't photo-transistor (PTR) sound cooler?

So just like a regular BJT transistor, more current passes through based on current at the base. In the case of a PTR, the base is stimulated by light. So more light = more current (less resistance). So basically you have another voltage divider (like in the battery voltage sensor) but the resistor on top varies based on the ambient light picked up by the PTR. Simple enough?

Then you just put that voltage divider middle node (between the two resistors, or PTR) into your uC analog input and read the voltage level. A little trial and error and you quickly know what a good sunset level is. You have to do a little hysteresis (use the history of what's happened and feed it back into your algorithm). I.E. let it be dark enough for a few minutes before turning on your solar powered LED lights, then don't assume it's light again until you read a voltage somewhat different than your trigger voltage. You don't want the thing to spasm and turn on/off for 20 minutes at sunset. Just turn on and stay on. Also, turn on the lights when it's just dusk. It looks cool to be able to notice the lights when it's still a little light out.

Tuesday, August 9, 2011

Solar Panel Regulator

Here's a snippet of the schematic that shows how the solar panel is regulated. It's connected to the battery when the battery needs to be charged and disconnected when the battery is fully charged (that's the simplistic explanation). Actually it's connected and disconnected many thousands of times a second in order to control the current flowing into the battery in order to get the optimum charge.


The part in the middle marked IRL3714 is the power transistor it's an N-Channel MOSFET transistor. The connection labeled RC3/CCP2 is the connection to the microcontroller's (uC) PWM peripheral (the CCP2 part). When the uC asserts that pin high (5 volts) then the MOSFET conducts from the Drain ( the top part, connected to the panel positive lead) to the Source (the bottom part connected to ground (labeled GND). So this is just shorting the panel positive and negative leads together. You can short a panel and it won't hurt it. It will just send it's maximum current through the lines.

When the uC pulls that pin low (0 volts) then the MOSFET does not conduct and the current will flow through the diode D3 to the battery, thus charging it. The diode keeps the current from flowing from the battery to ground (that would be very bad as it would waste all the energy in the battery and batteries don't like to be shorted and in some cases they can explode).

So it's just that simple to control energy from a solar panel. You can just build a cutout type charger and not use a PWM peripheral to switch at high frequency. It won't charge the battery to capacity but it will get you 70% of the way there and it will save the battery from over charging.

With the PWM you can control the voltage of the battery by varying the PWM percentage based on the battery voltage coming in from you battery voltage sensor (see previous post). This way you can hold the battery at whatever voltage you set. For a 3-stage lead acid battery charger it's something like this (check the data sheet for your battery to be sure).
1) Bulk charge - 100% until the battery reaches the saturation level, around 14.5 volts
2) Saturation charge - hold the battery at 14.5 volts for a set time (based on the batteries Ah rating (75 Ah would be about an hour).
3) float charge - hold the battery at 13.8 until ready for use

A benefit of the short type circuit shown here is that current through your panel lines stays somewhat constant, instead of turning on and off dramatically during every switching cycle. The current on/off can cause other problems in your circuit as well as creating an unintentional radio transmission antenna out of your wires that connect your panel to your controller.