I haven't really worked with electronics in around ten years but I'm starting to play with arduino and relearning what components work and how.
I've gone through some arduino exampls, forum posts on mostfet control, optocouplers, pull up/pull down resistors, and some instructables. I think I have it figured out, I just wanted to double check that I'm on the right track while I wait for more components to arrive in the mail.
The intention behind the circuit is to control power to motorcycle turn signals and monitor that same power.
Sounds slightly redundant but the handlebar switch is between the flasher relay connector and the ground. The stock wiring harness of the motorcycle will not be modified so the arduino must function within the constraints of the original wiring schematic.
Pin D10 will be set to output and high initially so that the 12V circuit will be completed when the handlebar switch is closed. When current down not flow, the 4N25's LED is not illuminated and input pin D3 is high.
If I've drawn this correctly, when the switch closes, current flows, illuminating the 4N25's LED, sending input pin D3 low.
The arduino will sense the current flow via pin D3 and start alternating pin D10 between high and low to flash the turn signals. After a predetermined time or distance the arduino will automatically turn off the turn signals.
It is not illustrated in the schematic but the arduino will be powered by an LM2940CT-5 voltage regulator run off the bike's 12V supply.
If someone could confirm that my understanding of general electronics and arduino controls is sound I would really appreciate it.
Also the P mosfet requires a voltage to the gate larger than that which feed the drain. Other wise once the D-S conducts, the voltage on the source is the same as the gate so it will not turn on.
Thanks for the suggestions.
I understand that pin 2 needs to go to ground. Would it not conduct to ground through the switch when the switch closes? Its entire purpose is to detect when the switch closes but to do so on the positive side of the switch.
As for the MOSFET, I initially started the design with an n-channel but I believe n-channel mosfets need to be between the load and negative rather than between the positive source and the load.
My schematic isn't clear but as this is an automotive application the 12V is the positive source.
New schematic but the only change is the 4N25's pin 2 going straight to ground. Almost seems too simple.
Would the 4N25's LED always be lit when the mosfet is high, regardless of the state of the switch, or will it turn off when current goes to ground through the switch?
Still not 100% sure about the mosfet. Some of the examples in the data sheet seem to be the same as mine but some are not. Hard to decifer some of the examples online as many people, myself included, will post incorrectly wired schematics in the process of discovering the correct way to wire them.
Might come down to simply trying it when the parts arrive.
Still a little confused. What is the purpose of this circuit?
Is it to replace the flasher unit? Is the Arduino continuously pulsing and when the switch is closed, the lamp is lit?
Is it to monitor that current is flowing through the lamp or just having voltage applied?
If you want to be certain that the lamp is being lit, you are not going to get that as you are not monitoring the current, only voltage.
Once the switch in series with the lamp is closed, the voltage is developed across the load so there will still be voltage to turn on the LED when the mosfet turns on.
The circuit is meant to replace both the flasher relay and the flasher auto-cancel unit that came stock with this line of bikes. Unfortunately the stock auto-canceller does not work with LED replacement bulbs.
I was hoping to come up with a solution that would reproduce the flashing action of the relay and the cancelling function while supporting both stock incandescent bulbs or more efficient LED bulbs.
The auto-canceller unit receives 1 pulse from the speedo for each revolution of the front wheel but that sensing function is not illustrated in the schematics above.
I figured it would be easiest to apply voltage through the mosfet at all times. The flashing function would only engage when the switch closes and current actually flows through the mosfet.
I'm beginning to think that might not have been the best way to go about it. There is another way to sense when the handlebar switch is activated.
The handlebar lever closes when turned to left or right, but another separate but integrated switch opens at the same time.
I'm now thinking it will be a lot more straightforward to only flash the lights with the mosfet rather than flash and sense current flow.
None of your circuit is capable of monitoring current flow. The opto LED is being pulsed continuously if the mosfet is being pulsed. It is irrevalent if the switch is open or closed. This circuit is simply monitoring if a pulse is available to be switched to the lamp.
Even if you move the LED to the other side of the switch, you are still not monitoring current through the lamp.
If the lamp is burnt out, the LED will still work in the opto.
Thanks, yeah, I see that it wouldn't work that way. The signals would flash but the arduino would have no way of detecting when the switch is closed and the lights themselves actually flash.
I will figure out an alternative way to monitor the switch state.
The mosfet itself should work fine. I'll try it out when the parts arrive.
That would work, of course. I just don't want modify the stock wiring harness.
The cct will be a straight plug and play replacement for the stock units.
The alternative solution really is a lot simpler than what I was trying to do.
Just for anyone's curiosity. I believe the circuit should work as shown but I could be completely wrong.
The Brn wire on both connectors is +12V.
The Black wire on auto-cancel is the wire harness ground.
The W/Gr wire goes to ground through the speedo's reed switch.
The Y/R wire goes to ground through the handlebar turn signal switch, opening when either the left or right signals are engaged.
The Br/W wire on the flasher goes to ground through either the left or right turn signals depending on which way the handlebar switch is pushed.
The Y/Gr wires on both connectors simply connect to each other, functionally useless.
The additional inputs on the TLP521-4 are for additional possible inputs. It'd be nice to incorporate RPM monitoring eventually.
The arduino will handle the flashing and automatic cancelling of the flashing based on input from the reed switch.
The stock auto-cancel unit stopped the signals after around 500'.