-
1Study the schematic diagram
Before jumping into the electronics part you need to get familiar with the circuit so it holds no surprises.
This isn't too hard. Grab the schematics off github or the files section and take a look.
I'll wait while you download and view the diagram....
Ok, got it? Now I'll talk you through it from left to right.
On the left are four squarish boxes that represent the MAP sensors. I'll assume you are following my exact build. Anyone doing their own mods should know what they are doing, right? The diagram is set up so that the pins in the diagram correspond to their real-life locations. This makes it easy to wire it up and check your work as you go.
Beginners please note that wires drawn crossing each other in the diagram are only connected if they have a dot on the junction. Rectangles are resistors (its a Euro-style diagram), US style uses squiggly lines but they mean the same.
Sensors
The sensors are really simple (electrically speaking). They each need a wire to +5V and Ground to do their thing. Then they will constantly output a voltage (the third wire) that is proportional to the pressure sensed. Less voltage is lower pressure down to 0V at 150Mbar above absolute vacuum, and up to almost 5V at atmospheric (sea level, nice weather, no hurricane touring the neighborhood).
The signal wires from the sensors are connected directly to the Arduino analog inputs A0 through A3 where the software can measure the voltage they give off. Keep these short in your project and don't go through a connector but solder directly to the board or to a pin header. This reduces interference.
Arduino
Now comes the Arduino. It too just needs V+ and Ground to work. Actually, you can feed it anything up to 18V (It will make its own 5V if it has to) so you could directly connect it to the vehicle power. If you want to go this route, feed the higher voltage into the Vin pin. Use the +5V for the sensors. You'd probably fry them with anything even slightly above 5V. The schematic uses a model of the arduino with all the pins in the proper places. This is an Arduino nano v3 type.
Switches
The next thing you may notice is the four switches. These are just plain and simple push buttons that make contact when you press them. One side is connected to an Arduino digital pin and another is wired to ground. This keeps things nice and simple to hook up.
However, if you like to play around with stuff then be very careful you NEVER set the Arduino pins connected to these switches to output HIGH (5V) or the switch will short the pin to ground when pressed! If that happens you may be lucky and find another pin that still works, but don't bet on it.The lone resistor
R4 is a resistor that is in there as protection for the Arduino. The power used to drive the backlight LED of the display is limited by this transistor so the Arduino doesn't fry. Some LCD modules have this resistor, some don't. I figure a slightly dimmer backlight is better than a Kentucky Fried Arduino. In fact my second prototype screen came with a resistor already. I noticed it was rather dim after I fired it up. I just cut out the resistor and it now draws 28 mA, which is perfectly acceptable to me and my Arduino.
The dynamic Duo: R3 and C1
These connect to the contrast setting on the LCD display. You often see some sort of adjustable resistor or (POTentiometer) used for this but I thought I'd rather do this in software.
R3 is there to limit the current flowing into C1. C1 is used to smooth the signal coming from the Arduino. This is a pulsating PWM signal that can make these types of LCD flicker horribly and even become unresponsive. Don't ask me how I know. These two together do a great job at the frequency the Arduino software does PWM. This is known as an R/C network and you can forget I said that.
LCD display.
Last but not least is the display. Its a HD44780 compatible 20 characters by 4 lines display. These are easy for the Arduino to drive and can be tricked into displaying nice bar graphs with up to 100 segments. They can also be read in the dark or even in bright sunlight (if you turn off the integrated backlight!) In fact, there are displays without a backlight altogether, you may prefer using one and can then skip the backlight wiring.
This display has a 4-bit parallel mode of working which we use that saves 4 pins. The other lines we need to connect are signalling lines that tell it t o turn on and accept commands offered up on the four data lines we are using. The other four data lines are happily hooked up to the +0V.
I've got the Power!
Finally there's the issue of power. As I explained above you could just plug vehicle power into the Vin pin of the Aruino (that's +12-14.8v) which should work just fine. In theory its scary as hell, but it works for a lot of folks. The MAP sensors we have are automotive and can handle some abuse. I have run Arduino's on worse (Joule thief anyone?).
What I recommend for beginners is just hook up a 9V alkaline block, which will happily power your circuit for up to 7 hours, more if you are diligent with the on-off switch!
Power switch
It goes in the V+ line between the battery and Vin on the arduino. Its a simple single pole single throw rated for peanuts and low voltage.
-
2Think about a layout or box
If you want to build this project I suggest you think about a box first. My prototype proves the electronics and software works. For the new prototype CarbOnBal Basic, I wanted a box, it looks better and is much easier to handle.
My design (if you can call it that) was quickly thrown together on the workmate in the shed. Then I improvised my way out of trouble. I sawed the box by hand out of MDF I had available. To aid in futzing around with the prototype I screwed the six boards and the perspex together without applying any glue.
Lessons learned
What I might do differently is leave more room for all the components. My LCD fits snugly and I had to cut down the tabs on the sensors to get them to fit four in a row. To its credit it s easily handheld this way. Whatever you choose to do I recommend waiting till you have the sensors and LCD in hand so you can fit them in place as you go. I'd also recommend mounting the sensors upside down to prevent stuff getting in there and messing them up. The spec sheets also recommend doing this, but I only really studied them after I built my prototype.
Front panel
The front panel is simple perspex with some carefully drilled holes. Drill in small increments to prevent tearing the ridiculously fragile perspex. I have an SVG drawing as a design inspiration in the files section and on Github. I printed the SVG on plain A4 paper with a laser printer and cut out the holes with an x-acto knife. It was made using Inkscape, which allows you to precisely adjust the layout to match your real-life version.
After fitting the paper I screwed in the switches and wired them up.
Display mounting
I mounted the display on four threaded rods (3mm) that were simply drilled into (almost through) the bottom of the box and glued there. Then I wound a 3mm nut down each rod to the required height for the display, and it rests on those. I applied some loc-tite to keep them there. Four bent paper clips would do as well! The display is held in place by the perspex panel and does not need to be screwed down.
Sensor mounting
The sensors had to be trimmed down so I used the old dremel and a mitre-saw to carefully pare them down so they'd fit snugly. Then I grabbed a scrap strip of aluminium and drilled four holes for the air hose fittings. This strip holds the sensors in place and I just screwed it into the sides of the box.
Battery
The battery sits in the space behind the sensors and is easily reachable by removing the back cover. There is an option to power your CarbOnBal unit using cheap AA batteries. Tale a look at the included schematic in the files section. Reserve space in your housing if you decide to use three or four batteries, as they take up much more space than a simple 9V block!
Arduino.
I ordered a micro to mini USB adapter which I fit into the wooden side. The Arduino goes into that and it is held at the other end using a tiny little screw. Of course, you may have a box made of thinner material, and in that case an adapter would not be needed at all.
-
3What You'll Need
To build the electronics you will need:
Tools:
A soldering iron. Any cheap soldering Iron will do just fine.
A pair of small side-cutters for cutting the wire.
A wire stripper, although you can use the side cutters or a knife if you're very careful.
Some insulation tape or gaffer tape to cover the resistors that go to the display. Or use some shrink stocking if you have it.Materials (in addition to the 'official' parts):
Soldering tin, 60/40 flux core works best, or use the new lead free rubbish if you have to.
Tinned copper wire on a roll, or re-use some wire from an old ribbon or network cable you have lying around. In that case, take care to pre-tin all stripped wire ends before making the definitive solder joints or you risk overheating the Arduino.If you want to make use of the option to use AA batteries, then you'll also need a clip for them and a DC-DC Boost converter.
Mounting hardware:
You will need to put the electronics into a box and may need an assortment of screws, tie-wraps plus whatnots and thingamybobs. This all depends on your particular solution.
-
4Prepare the Arduino (Optional step)
If you got a cheap Arduino clone like I did, you may have to solder the pins to the Arduino board.
This step is optional! I soldered pins in mine because I was building a prototype and wanted to use female in strips to make it easier to change stuff around. In the end you may be better off just skipping this step and soldering wires directly to the Arduino.
I recommend soldering them so they stick up from the board. Begin by carefully inserting the pin strip on one side. Heat up your soldering iron and clean and pre-tin the tip. I recommend using a small, clean tip.
Tack the pins on both ends then solder the pins in between in more or less random order so the heat is spread out evenly.
Repeat for the other side. The six pins on the end are for an ISP programmer, I didn't bother soldering them in but it can't hurt if you do. This makes it easier to rescue the Arduino should something happen during programming and the boot loader becomes damaged.
That's all for the Arduino.
-
5Wire up the switches
If you have a front panel ready then you could mount the switches and solder them in mounted. There should be two pins on each switch. One of the pins on each switch must be connected to ground.
I connected one copper wire that hops for one switch to another.
Starting at the right most switch I soldered the wire, then moved over to the next switch and scraped the insulation off at the site of the pin. Then solder the 'naked' copper to the switch pin. After the last switch I made sure the lead I left was long enough to be able to remove the panel and access the insides. It needs to go to the Arduinos GND (pin 19) and can be soldered directly or via a female pin cut from a pin strip. Soldering directly is much more reliable though and I recommend it!
Now each switch should have one free pin. Solder a separate wire from each of these to the relevant pins on the Arduino (
OK to pin 20, D2 (right next to the GND pin we soldered above).
Left/UP to pin 21, D3
Right/Down to pin 22 (D4)
Cancel to pin 23 (D5)
That's all for the switches!
-
6The display
I started by wiring all the pins that need to be grounded together.
Just take a length of wire and start at pin 1, solder it down then jump to pin 5 leaving enough extra wire that it does not cover up the intervening pins and prevent access to them. I find you can easily strip away a bit of insulation in the middle of a wire and solder it down to the connector pad, then hop to the next and repeat until you've connected all the ground wires together. Pins 7 to 10 can be just shorted together with an off-cut of wire. No need to leave a half loop of wire between each pin. We won't be connecting anything else there. In the end I left about 15cm (+/-6") of wire to use as the ground for the display unit.
The capacitor.
I couldn't find a decent electrolytic cap anywhere so I just stuck an SMD onto the back of the board, behind the pin3 connector there was a ground plane, so I scraped some of the laquer off that and mounted my surface mount capacitor that way. Alternatively you can just wire it up as shown between pin3 and any nearby ground pin. If your capacitor has a + or - indicated, then take care to wire the - to ground.
The 1K resistor (brown-black-red stripes).
I soldered this in-line, by first soldering a short bit of wire to the LCD pad pin3 (5cm or 2")), then the resistor, then another wire to make it just as long as the ground wire.
I find with resistors you either need to mount them on a board or in-line, but never with one wire on a board and another on a wire. Do that and it will break in no-time. If you have shrink tube, now's the time to apply it over your resistor and its exposed connections, you don't want it shorting out. I have shrink stocking but I used Gaffer tape anyway, just to be defiant.
The 220 Ohm resistor (red-red-black)
This one is much the same as above, I soldered it in-line and made the lead just as long as the others.
Last I just soldered equally long leads onto the remaining pins.
Before doing anything else, check all your connections for solder bridges and shorts. Do it now you can still see both sides of the LCD board. Fix any shorts and bridges you find by heating with a clean soldering tip, thus drawing up the molten solder onto the tip. If that is not enough, you may need a desoldering tool or lint.
Now what I'd do is solder the leads directly to the Arduino. Alternatively you can connect everything via a female pin strip. Its your call, but I'd do it the easy way and just solder the leads to the Arduino. Take it one by one and double check each wire before you solder it in. Just work in one direction. No need to alternate like when soldering pins in. This is slower going and it leaves enough time for the Arduino to cool.
The GND and 5V
This is a special case because all our stuff wants these connections one way or another. I did this by soldering a pin into the ardiuno and connecting my wires to that. The GND isn't so bad because the display and switches share the ground connection on the right-hand side of the Arduino, and the rest uses the connection on the left. It can get fiddly though and you may want to use a piece of Printed Circuit board. I just botched it all together and it works fine. You can see what I did in the pictures in the gallery. Be sure not to wire the display to Vin by accident or it will last about 15 nanoseconds, way too short to display a "goodbye World" message.
-
7Sensors
These have 5V and ground in common. I was lazy and wired the mounted sensors by connecting a single wire across all their ground pins and another wire across all the 5V pins. The ends of those I just soldered to the Arduino's corresponding pins. Do take care not to wire the sensors to Vin, but to pin 12 on the Arduino or you will fry them.
Technically it would be better to solder a separate 5V and ground wire to each sensor and connect them all together at the Arduino end, but I have not noticed any significant problems doing it my way. These units can obviously handle more abuse than their low price seems to suggest. Lastly I ran a wire from each sensor to the corresponding pin on the Arduino. Easy peasy! -
8Battery Options
I used a 9V block and clip. Nice and simple, but it won't last that long and those batteries are expensive.
Just connect the black lead (negative) to the Arduino's GND pin and the Positive, red lead to one side of the power switch. The other side of the power switch gets a wire soldered on which goes to Vin on the Arduino (Pin 15).
For a much better alternative see the ArduinoPower.pdf document in the Files section:
https://hackaday.io/project/27569-carbonbal#menu-files
This log describes this optional but recommended add-on:
https://hackaday.io/project/27569-carbonbal/log/101994-just-add-betteries
-
9Pre-Power on check
Before you attach the battery and power it up, double check everything against the schematic diagram!
Before you attach the battery and power it up, double check everything against the schematic diagram!
Before you attach the battery and power it up, double check everything against the schematic diagram!
Power it up and you should see nothing much happen. If something does happen at this stage its probably very bad news. A light on the Arduino will probably light up, that's fine.
-
10Flash the software!
Download the latest https://www.arduino.cc/en/main/software Arduino software
I use the IDE. I've never used the new web version so I can't advise you there.Download the https://github.com/dennisMe2/CarbOnBal/releases CarbOnBal software and unzip it somewhere. I'd recommend going for the latest release because its stable. The repository version will be broken from time to time as I add new features or rearrange the code to be more legible etc. You will need to rename the unzipped folder to "CarbOnBal". That is, strip off any extensions such as a release number or "-master", otherwise the Arduino IDE won't recognize it. Thanks TheRedOne51 for the tip!
With the Arduino IDE installed all you need to do is double click on CarBonBal.ino and Arduino will open up with CarbOnBal loaded. You can press the "tick mark" icon in the menu to verify that the code will build. If it doesn't you may need to add the LiquidCrystal library first. This is available from the Arduino Library Manager in the menu.Once it builds you can connect the Arduino via a USB cable and upload the 'sketch' to the Arduino. You will need to indicate that the board is an Arduino Nano with an Atmega 328P processor. These options are in the tools menu.
Uploading will take something like 20 seconds because the software is quite a big program as far as Arduinos go.
When CarbOnBal starts up it will display random characters falling down the screen, like a tiny version of "The Matrix". Press any key to proceed. This demo can be switched off from the menu.
If you run into trouble you can always flash the Blink demo from the menu and see if you can get that to work as a test. After that re-open and upload the CarbOnBal software.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.