Ford Focus RS Forum banner

21 - 40 of 85 Posts

·
Registered
Joined
·
180 Posts
Discussion Starter #21
This project is on the back burner until the guys and I in that thread can figure out how to get the Euro switch to run the fogs, but if you want turn signals or extra brake lights is super easy to do.
If I get the itch and free time to pick my LED project up again I would like to make a rear fog light mode that would be activated by the euro rear fog button. It would be pretty easy to do with a few more line of code. Hardest part would be installing the OEM euro switch and running a wire from front to back.
 

·
Premium Member
Joined
·
614 Posts
This project is on the back burner until the guys and I in that thread can figure out how to get the Euro switch to run the fogs, but if you want turn signals or extra brake lights is super easy to do.
If I get the itch and free time to pick my LED project up again I would like to make a rear fog light mode that would be activated by the euro rear fog button. It would be pretty easy to do with a few more line of code. Hardest part would be installing the OEM euro switch and running a wire from front to back.
After all you went through with your rear refector project the switch and routing wires for a rear fog are really simple!

The euro switch is super easy to install, I can do it in less than a minute now! You just need to pop off the dash side panel and push on the back of the switch. You could do it by pulling on the light selection knob but I didnt like the idea of doing so!

If someone figures out how to pickup a switched power source from either the bcm or the switch, fishing wires to the front is also super easy by pulling the door seals off and running the wires in the gap between the body edge and the plastic trim panels along the door sills!

I need to update the rear fog thread with all the info I gathered so far. As Phillofoc said we’re close but not quite there yet, I personally have reached the limits of my knowledge buy others have jumped in who also are determined in finding a solution!

Great job on the reflector mod btw! And it sucks about what happened to your car...I have a few bad stories about mine too and cant believe I still love this car after all!
 

·
Registered
Joined
·
180 Posts
Discussion Starter #23
I'm attaching a couple screen shots of some voltage logging I did to try to diagnose the interference problem I was seeing with my set-up.

To recap, I'm taking the +12V from the rear tail-light turn signals to an opto-coupler which takes the +12V and turns it into a +5V signal which is then fed as a digital input to an Arduino.

When the engine is Off everything works great. My code, the Ardunio, the LEDs sweep spectacularly. Here is the voltage log that the Arduino is seeing from the optocoupler when the engine is off and the turn-signal is on. You'll see a very clean 0V, +5V, 0V, +5V etc. signal as the turn signal flashes on and off.
Engine Off.png

And now here is what the Arduino is getting for a signal from the optocoupler when the engine is on and the turn-signal is on. The voltage is rapidly bouncing from 0V to +5V several times while the turn-signal lamp is on.
Engine On.png

Most recently, I made my own optocoupler from scratch and it showed the exact same signal response as the optocoupler I purchased, so pretty confident the optocoupler is not the culprit now.
 

·
Registered
Joined
·
95 Posts
Old thread but you could do some digital filtering with the Arduino. For example, once you see the voltage go to 5v, ignore the signal for a tenth of a second (or whatever timing works). Or take an average of the signal over a tenth of a second if that works.
 

·
Registered
Joined
·
180 Posts
Discussion Starter #27
I wonder if you could add a small capacitor to smooth out the voltage spikes
Hey kamik - at some point I tried a 10K ohm resistor and 0.47µF capacitor to make a RC low pass filter. I think the time constant for that set up was sub 5ms, so since then I'm wondering if I should have tried something with a higher cut off frequency. The noise I'm seeing might be more on the order of 50ms. So that may be worth a revisit.

Old thread but you could do some digital filtering with the Arduino. For example, once you see the voltage go to 5V, ignore the signal for a tenth of a second (or whatever timing works). Or take an average of the signal over a tenth of a second if that works.
I've too wondered about this approach using code rather than hardware to filter out the noise. I came across a few Arduino threads about "debouncing" a digital input, and it seems like my input definitely had some bounce to it looking back at the plots I posted in #23. I might have to do some reading on this.

It still bothers me I got about 95% done with this project, only to have it fail when the car is physically running. I may have to pick this thing up again this winter yet and see if I can get anywhere with code filtering. I have no background in coding so I'm guessing i'll have to spend some time figuring out what I did a year ago. I had something like 300+ lines of code to get everything working to where the brake, turn, hazard, and running light signals weren't fighting with each other, like when you're driving at night with your lights on, signal a left turn, and then hit the brakes. Figuring out how to give priority made it a long code.
 

·
Registered
Joined
·
11 Posts
Yea, figuring out the frequency of the voltage spikes will be necessary for the hardware approach.

If you decide to tackle it again and want some help let me know. I'm software engineer by day and I've done a few small arduino projects. You've done some impressive work and I'd be happy to see you rocking a totally custom mod like this.
 

·
Registered
Joined
·
180 Posts
Discussion Starter #29
You guys have given me enough motivation to give this project another shot. I now have an open-source oscilloscope on order so we shall see where this little rabbit hole leads. Yet one more thing to learn. If I'm able to get that device working and sniff out anything meaningful from the interference I'm seeing I'll be sure the share.

The "scope" was only $30 and seems to offer some interesting claims, "All-in-one USB Oscilloscope, Signal Generator, Power Supply, Logic Analyzer and Multimeter." If interested:

Yea, figuring out the frequency of the voltage spikes will be necessary for the hardware approach.

If you decide to tackle it again and want some help let me know. I'm software engineer by day and I've done a few small arduino projects. You've done some impressive work and I'd be happy to see you rocking a totally custom mod like this.
I really appreciate that offer. My code is almost certainly an embarrassment; might be good for a laugh if nothing else!
 

·
Registered
Joined
·
180 Posts
Discussion Starter #31
Alright - I found a cool little, open-source o-scope and would now consider my skill level with it as "dangerous." I braved my freezing cold garage to take some measurements the other night and this is what I've found. It think it's very interesting and might be getting me closer to a solution.

In the image I've pasted there are two graphs. The left (blue) shows the turn signal's voltage measured when the car is off. Note the beautiful Off-->On-->Off one would expect from a blinker. The right plot (orange) was taken when the car is running. Note the Off-->ON/OFF/ON/OFF/ON-->Off voltage! So, I can say with confidence the reason why my set up doesn't work when the car is running is because my code looks for a voltage change from Low to High thinking that a blinker is coming on and it is seeing this hyperfast voltage change and keeps triggering over and over, thereby causing the flickering I see.
339030

I was able to measure how fast the flickering was occurring and it looks like the voltage drops last less than 4 milliseconds. So, what I'm going to look into next is a way add a simple capacitor as @kamik suggested. I'm hoping I can figure out how to size one that charges relatively fast but will discharge to even out the choppy 14V signal my Arduino is getting. Hopefully more to come...
 

·
Premium Member
Joined
·
4,505 Posts
Sign me up once you have a set ready!
 

·
Registered
Joined
·
95 Posts
I'd think it would be easier to trigger on a 0->12V then ignore everything for 0.25 seconds. No hardware change required. Interesting that the voltage swing goes up to 15V when the car is running.

But awesome debugging skills!
 

·
Registered
Joined
·
11 Posts
I can't decide if the hardware or software approach would be better. I'm leaning toward software because it's more flexible. If there are variations in the flicker rate you haven't yet discovered you can change the software a lot more easily than the hardware. It's also easier to do an instant-on, delayed-off with software like @wobbletop mentioned.

The code should be dead simple too. Record the time each time you read a low-to-high transition. Turn on as soon as you see that. Then turn off when timestamp + delay has passed. Hopefully it's well less than 0.25s. Alternatively, you could keep a moving average, but that's likely overkill here and would add a small delay to turning on anyway.
 

·
Registered
Joined
·
95 Posts
Many ways to do digital filtering. The other way is to make sure the input has been 0V for more than a tenth of a second before the 0->12V transition.
 

·
Registered
Joined
·
180 Posts
Discussion Starter #37
Update: Good news FINALLY!

Had some time to research filtering methods to deal with the modulated charging scheme Ford uses in our cars. Ended up putting together a simple resistor/capacitor low pass filter and getting everything hooked back up to test it out. Took a couple iterations to size the resistor and capacitor but I think I may have solved the issue. Knock on wood! I've learned from the last round of this not to claim success just yet.
Next I need to clean up all the wiring again, incorporate filters on all the inputs, and test again. If that works, then need to build a new right-side LED signal since I broke it last year with all the in/out from troubleshooting. Hope to chip away at it in the coming weeks as it's looking like I won't be travelling to Asia any time soon for work...

Some happy footage from today :) :
 

·
Premium Member
Joined
·
4,505 Posts
So.......... what's the paypal account do I send the payment to?!

LOL!

Great job man!
 
21 - 40 of 85 Posts
Top