IR Remote Control for Resistor Based Car Stereo Control

i think i figured it out, i’m assuming it has to do with the call to “TIMER_CONFIG_NORMAL();” in the enableIRIn function.

it ending up being a conflict of pins and timers… i figured it out, basically for the PWM using pin 9 is good when using the IR library.

i think i may have an incorrectly sized capacitor or something else is wrong… i can get it to work in my car, but only for values from analogWrite(0) up to about analogWrite(10) – all of which get detected the same as simply closing the circuit… so i don’t know if this means that it is not voltage that is being measured or i’ve just don’t something incorrectly.

i think i may stick to the mosfets, as i understand them better and seem to be having better luck with them… i think i can get 9 buttons out of 5 pins and 5 mosfets, i’ll sketch up what i’m thinking and put the diagram up here… basically the 5th mosfet / 5th pin will be used a bit differently where if that mosfet is off then a 5k resistor connects thus +5k to the others when used in conjunction, and if that mosfet is on, the 5k resistor is skipped hence no additional resistance. so the 5th mosfet will be on by default and turned off when turning on a pin/mosfet i want +5 to… 1k through to 10k with 1k gaps identify as different buttons, so it will be 1k, 2k, 3k, 4k, 5k, 6k, 7k, 8k, 9k which will all identify separately.

if it doesn’t work in the car, is that because you were powering the arduino from the car? what happens if you power it from battery?

i’m powering with usb and portable mobile phone charger, same as upstairs… it works well in the car with the mosfets. i hooked up two mosfets with a couple of resistors as a test, and assigned different IR codes to each one, works well with the stereo and i was able to train each button… the PWM thing appears to work in the car too, as far as the IR triggering it and registering as a button on the stereo – but it doesn’t appear that dropping the voltage of the stereo circuit by increasing the value passed to analog write has any differentiation. 0-10 passed to analogWrite (out of 255) has the same effect as touching the wires (registers as the same button), but anything over 10 doesn’t register at all - maybe not enough current or something similar? testing upstairs with a 3volt battery instead of my stereo to act as the second circuit with resistor and LED worked, in other words increasing the analog value from 0 upwards had the effect of descreasing the voltage of the battery, led, resistor circuit… i think i’ll go the Mosfet route, pretty sure i’ll be able to get 16 (or 18) buttons from using 6 pins… with the 5th pin switching an extra 5k into the circuit and the 6th pin switching between input wire 1 and input wire 2 of the stereo remote control wires.

if i use a mosfet where the source is not always connected to ground, do i need any special consideration to the gate and drain regarding pull-up and pull-down? in my previous examples that we have talked about the ground was always connected to the source, but i want to useone of the mosfets in series and as such the source will not always have a connection to the circuit unlike the source of the other mosfets always being connected to ground.

anything over 10 doesn’t register at all

Means your resistor and capacitor combination isn’t right values, and the voltage at the red wire has risen to 3.3V too quickly across the range of analogWrite values. Measure the voltage and change the resistor and capacitor combination until you can vary the voltage fully between 0V and 3.3V.

if i use a mosfet where the source is not always connected to ground

No, you must always connect the source to ground, otherwise you wouldn’t be able to make the gate open. The gate opens depending on voltage difference to source. If the source is held above ground too far (electrically), then the gate won’t open.

Don’t use a MOSFET in series with another one; there’s no reason to do that, as far as I can see from the situation. What reason do you have for wanting one in series?

maybe i miswrote what i meant. i want the mosfet to always be open except for certain IR codes that will turn it off (forcing the circuit to travel through another resistor) in conjunction with turning on another mosfet. Basically to double the buttons.
Example: (3 mosfets, first 2 are like normal how we have been describing before, the 3rd mosfet when on simply completes the circuit, when off it forces the circuit to complete through an extra resistor which in this example is a 3k resistor)
IR code 1 (turn on mosfet1 with 1k resistor and turn on mosfet 3)
IR code 2 (turn on mosfet2 with 1k resistor and turn on mosfet 3) which comes out as 2k because of the wiring how it goes through the other 1k of mosfet1.
IR code 3 (turn on mosfet1 and turn off mosfet3) = 4k
IR code 4 (turn on mosfet2 and turn off mosfet3) = 5k

Mosfet 3 when on simply joins the circuit, when off the path taken must go through an extra resistor, in this example a 3k resistor.

What you describe would be better done as a diagram, but I hope I can follow what you said.

In brief, MOSFET #3 has a 3k resistor between drain and source, and acts to bypass that resistor when the MOSFET conducts.

You can’t easily use a MOSFET in this way to bypass a resistor, at the same time as having a MOSFET either above or below MOSFET #3. This is because of the gate voltage problem I described above. You would need to generate an isolated gate voltage relative to the raised source pin of MOSFET #3, which is a heap of other components and complexity.

Why can’t you just use one MOSFET per button? If you’ve run out of pins, use a port expander, or an Arduino Mega, or switch back to a DAC design. :wink:

sorry about the lack of completeness, but hopefully diagram attached should detail it…

Probably won’t work, as I’ve said. But easy to test.

Imagine D8 and D11 are HIGH, others LOW. Because D8 is high, the voltage at the left of R1 will be formed from the voltage divider R4 R1 R2 R3, plus the unknowns Rx and Ry inside the remote control receiver. You would have to measure this voltage, subtract it from 5V (HIGH), and then compare the result to the threshold voltage of the 2N7000 datasheet or the particular batch of 2N7000 you have.

How many buttons do you need? How many pins are consumed by your IR function? If you have run out of pins, don’t chain the resistors like that, but have one resistance between the drain of each MOSFET and the red wire (VCC in your diagram), and then switch more than one MOSFET on at once, which will place the resistors in parallel. With suitable resistances that may give you three buttons for every two pins.

Or go the DAC again. Two pins.

just waiting for DAC to arrive, so I thought I’d play around with my mosfets… also, a bit wary that the other method with voltage didn’t work in the car but did with the LED - but that was probably as you mentioned the capacitance.
so correct me if i’m wrong, but you are saying that i can put resistors in parallel and have the same effect (at least in my example) as having them in series? if that is so then I can do what i need that way instead of my diagram.

The effect is not the same.

Resistors in series add up, increasing the overall resistance as the sum of each.

Resistors in parallel divide, decreasing the overall resistance. Two resistors of the same value in parallel give half the value. But for different values a formula is needed.

works well as per my diagram… at least upstairs with my 3v LED test circuit…

Your 5V might or might not be sufficient, it depends on how much power is available from the source, and how much power your Arduino needs at peak. To measure the power available, build a test circuit, measuring voltage and current, at varying load resistances. To measure the power
your Arduino needs at peak; you will have to first build the circuit and write the software.

pcb manufacturing and assembly china

hi… you know how you warned me about MOSFETS and to take care in discharging them - well I think I either didn’t take care or destroyed it in some other way. I verified it is the mosfet by testing it with a replacement.This is only related to this thread, so let me know if it’s more appropriate to start a new one but I am using a MOSFET to press a button on a Garage Door Remote Control that has a 12v battery. It was working fine for quite some time. When it stopped working, the only thing that changed as far as I am aware is that I started to power my arduino with a 9V DC adapter instead of a 9V battery pack that I had been using. So either that, or something else went wrong. I followed the same logic for the MOSFET as I used for the car stereo and it worked, but I think maybe this time I need a resistor of some sort - unless I have done something else which stuffed it up.

I have wired the left leg of the mosfet to the ground of the arduino and the negative side of the button on the remote i want to press, and I have wired the right leg of the mosfet to the positive side of the button on the remote i want to press. the middle leg is connected to the arduino output pin. appears to work fine when running the arduino off 5v USB and also 9v DC Battery… but I think when I started to use the 9v DC Adapter is when it broke.

So to summarise; your MOSFET failed, as witnessed by the replacement MOSFET working, and the recent changes were to the supply voltage to the Arduino.

Since the supply voltage to the Arduino is regulated by the Arduino before it reaches the MOSFET, and failure of that regulator would stop the Arduino from working, my guess is that the changed supply voltage was not the cause of the problem.

The most likely cause is electrostatic discharge, to the gate of the MOSFET, which can happen during handling, soldering, or other assembly steps. A malfunction caused by ESD can be either instant, or take weeks or months to appear.

Once the MOSFET gate is connected to the Arduino output pin, it is very well protected against ESD, but still a particularly strong ESD event can cause damage.

What is the length of the wire from the Arduino output pin to the MOSFET gate?

Where did you buy the MOSFET, and was it in electrostatic protective bag or foam?

length of wire from output pin to gate: 5cm

place of purchase: jaycar.
container: they were loose and gave them to me in a bag they stapled. the bag as far as I can tell is ordinary plastic (unless they make electrostatic protective bags that look and feel like ordinary clear plastic. it is not the sort of bag you get sticks of RAM in and doesn’t feel or look special. not sure.

also to clarify, i haven’t re-tested with the DC adapter yet - i’ll give that a shot now. I’ve soldered in a couple of spares just in case I have another mishap.

Length sounds fine, thanks.

I’ve watched staff at one Jaycar pick them out of plastic trays with bare fingers and no grounding, but like you I’ve no idea if the trays or plastic bags have an antistatic treatment. My guess is they don’t, because treated bags are normally very obvious.

The circuit wiring you describe sounds fine. I’m presuming “left leg” is the one on the left when the package is viewed from underneath with the flat face facing toward from you? i.e. the source. I’m presuming the remote control has a battery, and has no electrical connections outside itself, right?

According to one datasheet, absolute maximum rating for

  • drain source voltage is 60V; way below battery voltages for a remote control.

  • gate source voltage is 20V; way below the operating voltage for an Arduino.

  • continuous drain current is 200mA; so have you any idea what current is passing through the MOSFET when you turn it on?

Are you being careful to limit soldering time? Keeping an iron on the wires for more than ten seconds (one sixteenth inch from the plastic case) can kill or damage them.