So, many of you who read my previous post on the TEVO Black Widow 3D printer might have thought, oh hes bought another toy. Well, while that is mostly true I had an actual reason for getting one. Continue reading “My First “Thing””
Why did I do this?
Take a look, that’s why!
Ok, so now I know you want one! If you do, they can be made to order. Cost is £150 + shipping as they are hand made. Want one?
Its probably worth recapping as to why this project came about. Essentially, whilst on a mission to replace every bulb in my car with a LED version, I stumbled across the fact that my high level brake light was not LED as you would typically expect, but instead had a strange row of bulbs on a common rail power system that clipped into the back of the reflector housing:
This was not ideal and lead me to need to replace it. An initial investigation showed me that it would be very simple to replace the bar with a row of LEDs hot glued into place and powered from the +12 feed into the unit, but after some initial consideration I thought it might be more interesting to be able to run each LED individually and control the sequencing etc. for some special effects.
Aside from the need to upgrade the unit, the primary reason behind going down the Arduino route was an excuse to really get my head around the ATMega and micro-controllers in general, as well as basic electronics principles. Having never being formally taught this stuff and only ever watching my dad do electronics as a hobby while growing up (pre 10 years old that is), I wanted to progress from my first Arduino “simple flashy LED” experiment to a reasonably complex endeavour. This project was ideal for that as I have had to learn how to design power supplies, switch different voltages, work with Pulse Width Modulation (PwM) and Oscilloscopes, de-couple components, “boot load” my own blank ATMega328P chips, program in C++ and take a conceptual prototype to production. Below are some of the conceptual prototype boards:
All in, this learning experience has taken me around 3 months of spare time, but has been a great journey and now has me hooked!
What are the key aspects of the design?
The design comprises a series of individual circuits combined to overcome some issues discovered along the way, which is why the current version at the time of writing this post is actually V5.2. As this was an evolution of design I will explain the major releases and changes along the way:
V1 & V2
This was a simple venture into lighting up 10 LEDs with nothing more than 10 LEDs connected to the digital outputs of the Arduino. The problem with this design is that the Arduino (ATMega328P) only has 6 PwM outputs, and to do a decent Larson effect you need PwM to fade up and fade down each LED, so that meant that I could only do this with 6 LED’s or I had to not use PwM. – not ideal!
This was a complete hack solution to the PwM problem. Essentially, I used a library I found that creates a software PwM effect across all of the digital outputs, allowing me to run 10 LEDs with PwM on each of them, although this seemed like a perfect low tech solution, the main issue was that once I built the unit and installed it in the car, I noticed that there was around 300ms of delay between the brake lights on the car and the high level brake light illuminating. After some investigation and generally messing around with the circuit on a breadboard, I figured out that this was the time it took for the ATMega382P to load the arduino boot loader and execute the program. This was unfortunately a serious problem as 300ms of delay in braking is the reaction time of someone behind you and could mean the difference between having an accident or not, so it had to be fixed.
This version brought a solution to this problem into play by way of 2n7000 Mosfets. These awesome little components allowed me to route the power to the LEDs from the +12, and switch between a full time ground connection and a PwM controlled ground using a +5v switch feed. So essentially what happened was, as soon as power was available the LEDs had a connection to +12 & GND by virtue of +5 holding the mosfets closed, then as soon as the ATMega woke up and was able to do PwM it shorted the +5 feed to the mosfets and opened them handing over the ground to the ATMega to handle PwM. This was a near perfect solution and gave me instant on, however, the software PwM Library had issues with the handover between the instant on and the PwM and resulted in what I can only describe as a very ugly transition!
This was the biggest jump in the architecture and was essentially me giving in and realising I needed to go down the hardware PwM route. After a couple of misguided attempts at using shift registers, I found the right component for the job, a Texas Instruments TLC 5940 hardware PwM unit. It provided 16 native PwM channels with a 12bit duty cycle and 4095 shades of grey on each channel. This unit is serial controlled by the ATMega and offloads the control of the LEDs to a second micro-controller dedicated to the task, so gave me the 10 hardware PwM channels I needed. Combined with the instant on concepts from V4 it allowed me to have a sub 10ms start-up to the circuit and a smooth handover to the effects unit, where I could refine and polish the desired effects given the more granular control over fades (Atmega has only 256 shades vs the TLC with 4095 shades).
V5.1 & V5.2
These final tweaks to the architecture reflect some power protection circuitry concepts that allowed me to better protect the circuits in an automotive environment. Specifically, a transient voltage protection circuit that gave me a hard limited +12 circuit upstream of my voltage regulation circuit that made things much smoother and safer.
One thing common to all of the versions was the need to temporarily bypass the effects in case a particularly anal MOT tester decided he wasn’t going to pass it with this unit installed. As a result the need for an MOT switch has always been present, however the way it is handled has changed over time. As of V4, the use of the mosfets allowed for a rather cool and quite awesome way of dealing with this issue. Essentially, what happens as explained before is that the +12 & +5 circuits power up and hold the mosfets closed allowing the LEDs to run on what is a standard power circuit with no PwM. The ATMega has a digital output connected to the +5 circuit that connects the Mosfets and once its booted it sets this output to a “LOW” state which essentially drags the circuit to ground and opens the mosfets so the PwM control can happen. All the MOT switch now does is literally break that connection, leaving the Mosfest closed and the LEDs lit without any interaction from the micro-controllers.
A very neat side effect of this is that this has created a “fail on” redundancy to the brake light. What I mean by this is that if the ATMega or TLC fail the LEDs will still light as normal, they just wont do any effects. This is a great safety feature as the components most likely to fail are these and if they do, the brake light still works like any other brake light would.
What does it look like?
The final schematic is below and available for download here (You will need a copy of RS Components Design Spark if you want to edit it, else there is a PDF in there for normal viewing & printing. Design Spark is free btw, and very awesome!)
What about the code?
The code is very simple. It simply provides the three primary states of operation for the desired time periods required. The three states of operation are:
- Full On
- Breathe Effect
- Larson Effect
Each state of operation is timed for a specific period to allow for typical use, for example, the initial state of Full On, i.e all 10 LEDs on at 100% power, is set to exist for 2 seconds to allow for short presses of the brake pedal. The next sate is the Breathe effect, where the luminosity of the LEDs is reduced from 100% to around 25% over a 2 second period, and then restored back to 100% over a further 2 seconds. This provides a very smooth breathing style effect that runs 3 times or about 12 seconds, which is ideal for longer “slowing down” style braking, before handing over to the final effect. At this point the Larson effect takes over and literally runs back and forth in a loop indefinitely from this point forward, as if you have had your foot on your brake pedal for more that 12-14 seconds chances are you are coming to a stop from high speed, or your sat in traffic stationary so such an effect is either going to help attract attention to your deceleration, or make someone behind you smile for a second as they remember Kit from night rider!
Given the unit only powers up when the brake is pressed, I didn’t need to handle interrupts, or additional switches to make the effects happen, as they run from boot each time, so a simple millis() counter is sufficient to work with as it always starts from zero.
The final code is a typically hacked/adapted version of a million tutorials and is split into a few sections. Each main “void” handles the primary effect functions, i.e Breathe & Larson, then the final void loop just knits them together in the desired quantities. All the horribly complex stuff required to run the TLC is handled by a library that you need to install into your arduino projects libraries folder to make it all happy, which is fortunate as its a proper nightmare without this!
So how did the prototype work out?
The problem with the prototype was that I wanted a like for like replacement part for the current bulb bar which limited the available space to work in. Essentially I had a space 300mm x 16mm x 30mm which meant it had to be very long and thin. The second major issue with this was that the LED’s would have to be spaced about every 30mm so that meant that I couldn’t just make one long circuit board, I had to have two, one for the LEDs and one for the logic and power. That lead me to the prototype design which took a while! Essentially what I have is two separate boards, one for the LEDs and one for the Logic and Power. They are bolted together using nylon bolts & spacers and then a ribbon cable provides power and PwM control between the two. the final design fits within my space constraints (just) and clips onto the back of the reflector housing perfectly, with just a power and earth back to the original connector for the high level brake light.
Below is a screenshot of the breadboard layouts from Visio:
These are accurate and can be used to build your own, so feel free to use them. Here is the original Visio version which may be more helpful to you.
Once its all bolted together it looks a little bit like this:
What does it look like in the car?
Well I like it, but then I am a bit geeky like that and like a flashing light or two, so decide for yourself !
Here is a nightime video for much better effect… The Cylon starts at 3:00 mins in:
A few mad people are interested in having this in their own Alfas, so I have committed to designing a final PCB layout that can be manufactured, if enough people commit to buying one. Other than that, I plan on a few more Arduino based projects in my car, so more will definitely follow!
Here is a simple scheme for 12V approx 10s OFF Relay. It’s very easy to build. Scheme and part list are shown below.
- R1 – 6.8 Ω
- R2=R3 – 100 kΩ
- D1=D2 – 1N4007
- T1 – 2SD892 (Darlington NPN transistor)
- C1 – 100μF/25V
alternative (if you cannot find 2SD892 transistor you can use one below)
- T1 – BC517 (this one has higher hfe than 2SD892, so you also have to change capacitor)
- C1 – 33μF/25V
- BROWN – ignition (+12V)
- GREEN – to relay (No.85)
- RED – constant power supply (+12V)
- BLACK – ground (-12V)
If you want to change delay-off time, you can change the capacitor. For longer delay use higher value capacitor, for shorter time, use lower value capacitor. Change only capacitance, not voltage.
Buy one 4-pin car relay (NO-normally open)
Bring constant power to relay pins No.86 and No.30.
Relay pin No.87 will give power (+12V) to DC-DC converter when ignition is ON and 10s after ignition is off.
And here are the images how I have coupled it along with DC-DC converter.
Thanks to rjc_147 who pointed out for D2 diode & Credit to Razor AMD for the content.
What follows is the front bumper removal procedure as described by Alfa Romeo in their in-house dealer level procedure software, eLearn. This is a descriptive and pictorial guide to removing the bumper as used by Alfa Romeo trained technicians – but I am pretty sure use mere mortals can follow it too!
This procedure is taken from the 159 procedures catalogue, although should follow for all models in the range: 159 (saloon and Sportwagon), Brera and Spider.
My comments have been added in italics to add some detail along the way
There is no specific tooling required for this job, only commonly available spanners and sockets are required.
All bolts are listed in the procedure as being M6x22, however depending upon the life of your vehicle and more probably what Alfa Romeo had in the factory at the time, this may be different.
I know for example that my “under engine protection / guard” is held on with torx bolts, not M6.
Step 1: Position the vehicle on a lift (place on axel stands) and raise the vehicle. You can either turn the wheels on the steering rack or remove the wheels to gain access to the wheel arch liner bolts. “Working on both sides of the vehicle, undo the bolts fixed to the wheel arches (1a) and the nuts fixed to the bodyshell (1b).
Step 2: Undo the lower bolts fixing the bumper
These are the front three bolts that link between the engine tray and the bumper – be careful though as the mounts are very thin metal plates welded off the front of the sub-frame and tend to rot into nothing at an alarming rate. If you’ve got the time, give these a quick rust proof.
Step 3: Lower the vehicle (only if you’ve got it up on a lift) and undo the upper bolts fixing the bumper.
Step 4: Move bumper (1a) slightly to one side by releasing from the side retainers. Essentially with a good wiggle it should just pop off, but by move slightly to one side, it means don’t run off with it just yet, it is still plugged in!!
The disconnect the electrical connections.
What isn’t mentioned here is headlight washers, for some reason. You may well have these nested in your front bumper also and will need to disconnect the pipe to these. Remember if you disconnect you will need to crimp or bung this pipe or chances are you’ll empty your washer bottle all over the floor.
And that’s a wrap as they say in show business.
For the purposed of Project Halo this allows you to remove the bumper and access the lower mount of the headlight, which can only be removed with the bumper off the vehicle.
Be sure to clean dirt and grit out of any panel joins and hard to access places, particularly in the join between the bumper and the wing, to extend the life of the panel and prevent the dreaded tin worm from setting in.
The Halo units require good, clean regulated power to run or they will burn out. A cars power supply is the exact opposite of this, its dirty, unregulated and a very bad place for electrical items to live! As such, most electronics in a car have additional protective mechanisms to keep then safe. The Halo controllers & rings are no different.
Please refer back to the Parts List to see what components you need for this phase. Also please note that this wiring can be completed at any time, ahead of the Halo’s being installed as it will not effect anything in the car.
The basic idea is to provide a direct feed from the battery to the power supply unit that is switched via the ignition feed, and then to run 2 x power leads from that power supply to the headlight locations ready for connection to the Halo controllers.
Start by opening the bonnet of the vehicle to access the area where you will be working.
- Un-clip the cover to the fuse holder on the top of the battery (Figure 1)
- Remove the lid of the fuse box next to the battery by removing the 3 philips head screws (Figure 1)
Now you will be able to access all the parts you need to.
Using Figure 2 as a point of reference, follow the following steps:
- Cut a 18-24″ length of 12v twin core 8.75A wire and crimp circular tabs onto the end of it. It is useful to cut the red / power wire shorter that the black / negative wire so the wire runs neatly along the battery and to leave room to attach the in line blade fuse holder and integrate this unit either through crimping or soldering it in line on the Positive feed. (Figure 2, #1 & #2)
- On the opposite end of that length of wire, crimp 2 female spade connectors and attach the negative one to the connector of the relay labelled 85. (Figure 2, #3)
- On the same length of wire, attach the female spade connector on the Positive wire to the connector of the relay labelled 30. (Figure 2, #3)
- Cut a further 18-24″ Length of 12v twin core 8.75A wire and strip away the positive leaving only the negative feed. Crimp a circular tab onto one end of it and strip 0.25″ of bare wire on the other end. Attach the bare wire end to the screw terminal on the Power Supply labelled “IN -” (Figure 2, #4).
- Cut 6″ of the spare single Positive 18-24″ length from the previous step and crimp a female spade connector to one end and attach it to the relay terminal labelled 87. Strip 0.25″ of bare wire from the opposite end and attach it to the Power Supply terminal labelled “IN +” (Figure 2, #4).
- With the remaining length of Positive wire from the last 2 steps, crimp a male spade terminal to one end and a feral spade terminal to the other. Insert the male spade terminal into the fuse box as show in (Figure 2, #5) and connect the female spade terminal on the other end to the Relay terminal labelled 86.
- Now connect the two negative circular connectors to the negative side of the battery using a 8mm spanner or socket (Figure 2, #2) and the positive circular connector to the positive side of the battery, before the fuses (Figure 2, #1)
You can now test if the power supply is working by switching on the ignition of your car and observing if the power supply’s green LED lights up. If it does not, double check all of the connections as per the above.
NB: I personally found that I could just push the power supply and the relay easily into the space between the fuse box and the suspension turret in my engine bay and the look that runs over the top holds things in place quite well. Your engine bay may be different and as a result you may need to find an alternative location. If that is the case you will need to adjust the cable length suggestions in the above steps to account for a different location to be used.
Standard Relay Diagram:
Durite Timed Off relay Diagram
Once the power supply is in and running all that is left to do is to run the remaining cable 12v twin core 8.75A cable to each headlight location.
- Cut a length of wire long enough to reach the closest headlight and fit the 2 Pin Superseal Female connector to one end of it.
- Cut a second length of wire long enough to reach the headlight the furthest away and fit the 2 Pin Superseal Female connector to one end of it.
NB: make sure in both of the above steps you leave enough wire near the headlight to account for fitting & removal of the units.
- Strip back about 0.5″ the positive and negative of both wires at the end with no connector on.
- Twist both positive wires together
- Twist Both negative wires together
NB: At this stage it is recommended to solder these twisted connections to keep them secure and stop them working apart.
- Attach the Positive wires to the power supply terminal labelled “OUT +” (Figure 2, #4)
- Attach the Negative wires to the power supply terminal labelled “OUT -” (Figure 2, #4)
- Run the wires neatly around the engine bay, cable tying them to suitable locations en-route to keep them away from the engines moving parts.
NB: Some project members have had issues with their power supply spiking and destroying the controllers. It is therefore recommended that an in line fuse of 2A is added to each headlight run. This will protect the controllers in the event of a power surge due to a faulty PSU.
After this is done you will have a dedicated feed to the Halo controllers that is both regulated & protected, as well as switched on and off via the ignition of the vehicle. If you have chosen to use the timed off relay, this power supply will stay powered for the time you chose when you purchased the relay (10s suggested).
Tuning the voltage
The PSU unit has two small screws near the LEDs that are attached to trim pots inside the unit. Each of these adjustments lets you tune the amount of power (voltage & amps) that the supply is delivering. The Halo’s & Rings are low power units so will tax the PSU much. To that end, adjust the PSU as follows:
- Start with a multimeter and set the PSU to 10v output
- Connect it to the controller and connect the rings
- With the rings lit through the controller put a meter between +ve input to the controller and the +ve output to the ring and adjust for about 1v
- 1v should be about right (the NUD datasheet says it needs to be more than 0.7v and, thermally, less than 1.5v)
NB: You can measure the amps a system draws using a multi-meter by putting it in-line to the feed to the controllers: https://www.youtube.com/watch?v=HWA9WqSEjg8
NB: If you put too much voltage into the controllers, the electronics have a tougher job to get rid of the excess, and excess power is always turned into heat which can and will cause the controllers to fail. Way Too much input voltage will just blow the input regulator to the micro-controller and fry the board.
It is easy for me to detect if the controllers have failed this way and refunds will not be given!
Installation of the rings is very easy. Each ring is a near exact size match for the lens so they are easy to place in the right ones. For reference, the rings are:
- Inner lens = 95mm
- Middle Lens = 90mm
- Outer Lens = 85mm
Each ring comes with a small black box attached to it. This is n in-line power regulator that if you connected them directly to the cars battery, would save the rings from bursting into flames and generally being quite terrible at their job.
First job is to get rid of them! That’s right, we don’t need them as the controller modules regulate the power instead and use an electronics principle known as Pulse Width Modulation to alter light intensity.
If you leave them attached the controllers wont be able to regulate the light and it will all generally just fail quite badly, so literally cut them off and leave yourself a ring with two wires (x3).
Start by covering the outer lens plastic with tape or other material that will prevent accidental scratches. It is also recommended to wear latex gloves whenever you are working with the reflector or lens housing to prevent fingerprints and grease marks.
First separate the reflector from the plastic lens by removing the 4 screws holding it in and gently pulling it apart.
Next, just place the correct ring into each of the lenses and secure them with a small amount of glue on the back edge of the ring. They are a tight fit so glue is optional.
Make sure that the wires from the rings are towards the top of the headlight as we will run the wires over the top NOT underneath. This is due to the fact that the bonnet slightly overhangs the light units on the car and so the wires at the top cannot be seen unless the bonnet is lifted. If you run them underneath it is possible to see a small amount of wire when looking at the lights on the car.
Make sure you have double checked all surfaces for fingerprints, smudges etc and removed and cleaned as necessary and then install the reflector housing back into the lens unit and screw it back together.
The goal of the wiring is to create a positive (+) and negative (-) feed from each of the following bulb feeds inside the headlight unit:
- Main Beam
- Driving Lights
The only bulb feed not used is the sidelight feed. This is so that you can turn on your sidelights at dusk and not alter the intensity of the Halo rings, keeping them at the daylight level.
- Try and make your joins as small and as neat as possible
- Where possible keep all cables routed away from the lights
- Do not let cables foul the reflector housing or the motors will strip there gears trying to adjust the beam angle!
First create a 3 into 1 cable for the earth. Each feed to the controller is a + & – pair so splitting a single common earth into the 3 feeds needed for the controller inputs is fine. Once you have your earth cable, cut the black earth cable coming from the junction area in the light. This will be the cable that already has a split into a number of earths for the bulbs. Join the new earth splitter cable and route the earths through the headlight and through a hole in the bottom of the headlight case above where the controller box will be located underneath. Now cut into the coloured wire for each of the bulb feeds and join a length of wire to be routed along the same path as the earths. Colour coding these wires can be useful later on in identifying which input is which. Alternatively, consider labelling the wires.[Not a valid template]
Once you have completed the 3 feeds you will have something like this:
Controller Wiring Digram – V2.1 Controllers (Green)
The following image is a simplified wiring diagram for the V2.1 Controllers easily identifiable as having a green circuit board. Each of the wires you create in the above steps are connected onto the controller like this:
There should be 6 new pairs of wires from the headlight. Positive & Negative feeds from:
- Main Beam
- Driving Lights
Positive and negative feeds to:
- Inner ring
- Middle ring
- Outer ring
Please leave enough wire on these 6 feeds to locate the controller where you would like.
Controller Wiring Digram – V2.2 Controllers (Black)
There are differences in connections between v2.1 & v2.2 due to revisions of the board requiring a fresh routing of positive and negative tracks. This means that the polarity is the different on the V-IN (Power input from PSU) the connector handing is also reversed. Please therefore take care when wiring up your connectors to ensure that the positive is in the correct side of the connector as per the diagram.
This issue will be most apparent if upgrading from a V2.1 controller to V2.2