False triggering IR light gate

Hello all.

I have the following circuit set up (see atttached). The problem is that whenever I drive the 24v motor (analogWrite(4, 255)), the EE-SX1108 IR transmissive sensor triggers its interrupt even though nothing has passed through it. I have tried isolating the power to the LED side of the sensor because I was thinking that the LED might have been flickering but it made no difference. I have also tried isolating the 24v power supply ground, but again, to no avail.

I thought that this would be relatively simple to set up…but now humbled, I am asking for some advice. I am probably doing something stupid but I really cannot figure this out. Any input would be very much appreciated.

TIA

hi!

maybe the starting motor (an inductance) causes spikes on the ground "rail"?

u could try a flyback diode that points from GND to +24V... http://en.wikipedia.org/wiki/Flyback_diode

when my fridge motor starts, i get noise on my computer's ground line... :~

bye

Probably noise, as RIDDICK suggested. I’m not sure if it will work in your application but you could use smoothing (using a running average from the past X readings) as a means to avoid false positives from spikes. I had to do this on some IR beam sensors in a house installation where there was enough noise. I used the code posted here:

and everything was immediately stable.

u could try a flyback diode that points from GND to +24V…

Thanks for the suggestion. The h-bridge I am using incorporates flyback diodes.

I think I will work around the problem in software, a simple digitalRead seems to work well, and I do not need a resolution finer than one millisecond. An interrupt would be more elegant, (but only I see the code),…as long as it works! :~

That smoothing code looks nice but it will not work for this particular case (the IR sensor is detecting a flag on a motorised shuttle). I will keep it in mind for other sensors though, thanks for posting the link.

what about some decoupling capacitors? http://en.wikipedia.org/wiki/decoupling_capacitor

the LMD18200 datasheet says on page 5, that one may use 1.2mF and 1uF at GND and +24V (close to the LMD18200 pins)... they seem to be missing on the Acroname board... take care that the caps can take more than 48V and that the caps r connected the right way (+ on +, - on -) or they may explode and spill some acid in the room (which smells bad and might be bad for the body)... it might be a good idea to use a ceramic 1uF cap (it is most likely non-polar), because it can react faster... wag tail

Thank you for taking the time to research the issue, I really appreciate it! :)

...or they may explode and spill some acid in the room...

I have done that before! :D

it might be a good idea to use a ceramic 1uF cap (it is most likely non-polar), because it can react faster...

I will certainly try that and let you know how it goes. I should connect the capacitor between the high voltage input (Vs) and ground, is that right?

Thanks, Riddick.

yo - i think so, 2...

here (on page 5) u can c the schematics from the manufacturer of that part: http://www.ti.com/lit/ds/symlink/lmd18200.pdf

is this the board u use: http://www.acroname.com/robotics/parts/S11-3A-EMF-HBRIDGE.pdf ?

it seems to be generally a good idea to put sufficiently big capacitors near the power supplies (even the 5V line)... but not on signal lines... ;) the minimum size of the cap should be found by trial-and-error and/or experience, i think (the capacitances should be as low as possible, because power supplies hate caps, because they act like a short circuit at startup...)...

is this the board u use: http://www.acroname.com/robotics/parts/S11-3A-EMF-HBRIDGE.pdf ?

Yes, that is it.

I am going to be terribly busy over this coming weekend so I will probably not get a chance to try this out until early next week. I will let you know then.

Thanks for your help.

np... i will check at least once per week...

i have some other riddles in the meantime, so it wont be boring for me, 2... :)

have fun...

Well, I finally got the capacitors ordered and I have started playing around with them. I have installed a 0.10uF ceramic cap between pins 6 (Vs) and 7 (GND), but with no luck yet.

I will try adding a 47uF next.

Here is the board so far:

oki…

interesting picture…

u soldered the cap on board?
that is not necessary… and it might be bad for the chip if it is heated again and again…
it would be close enough if u just stick it into the incoming voltage clamp (i think it is the upper clamp)…
or would that be electrically unsafe? if u use a thick bunched conductor it should adapt nicely…
maybe it would be better to solder the caps to the wires such that the leads can go into the clamp?

the datasheet recommends 1200uF… :slight_smile:
oh: and u should take care that the cap can take clearly more than 24V (but: much too much might be not so good, 2… it is more expensive… and there is rumor that the cap will age overly fast…)…

and u should try 1uF or 10uF ceramic caps, 2… because: 100nF (=0.1uF) sounds a little bit low…

and they (the fast acting and the big one) should be used both at the same time…

interesting picture...

It's a mess I know, sorry! :astonished:

u soldered the cap on board? that is not necessary... and it might be bad for the chip if it is heated again and again... it would be close enough if u just stick it into the incoming voltage clamp (i think it is the upper clamp)... or would that be electrically unsafe? if u use a thick bunched conductor it should adapt nicely... maybe it would be better to solder the caps to the wires such that the leads can go into the clamp?

Okay, I have put a 1uF capacitor in the upper screw terminals (24v in) and a 1000uF cap in the 24v leads about 4 cm back from the terminals. (I removed the capacitor that I soldered on the chip itself.)

The IR light gates are still triggering when the 24v motor starts driving, so it does not seem to be working. I am not sure what to try next.

Thank you Riddick for being so patient and kindly continuing to help.

hm

1. the arduino has sufficient capacitors on-board...

2. my last idea would be: opto-couplers... :)

3. but before the opto-couplers u could test what happens when u turn on the motor manually... :) with and without separated power supplies... maybe there is some electromagnetic influence... long cables without shielding...

Hard to say exactly what the problem is without seeing the entire layout, but the following may help:

  1. If you haven't already done so, connect a large decoupling capacitor (say 1000uF) between the motor supply +ve and ground, close to the motor H-bridge. Use the negative side of the capacitor as a star point to connect the ground lines to the H-bridge (which should be as short as possible), the 24V power supply, and the Arduino. The idea is to prevent the motor current inducing any voltage on the ground lines.

  2. Keep the motor wires well away from the wires to the IR sensor.

  3. If you have a spare ground pin on the Arduino, connect the ground side of the sensor to that and not to any other ground.

  4. Use shielded cable between the IR receiver and the Arduino, shield connected to ground pin in point 3 above.

  5. An external pullup resistor between pin 19 and +5v will reduce the sensitivity of that pin to noise. Try 2k2 or 4K7. Too low a value will stop the sensor working.

  6. A capacitor between pin 19 and ground will also reduce the sensitivity to noise. Try 0.1uF. Too high a value will reduce the speed at which the sensor responds.

Why have you got a 10K in series with the step and direction pins to the controller? That is making them more prone to picking up interference, why can’t you just connect the pins directly?

It is going to take me a little while to try out all of these suggestions, but I am very grateful for them! :)

As you have probably all already guessed, I am still quite new to electronics.

but before the opto-couplers u could test what happens when u turn on the motor manually... with and without separated power supplies...

I will try that, the H-bridge board uses 5v and 24v so I will have to connect an additional adapter.

  1. If you haven't already done so, connect a large decoupling capacitor (say 1000uF) between the motor supply +ve and ground, close to the motor H-bridge. Use the negative side of the capacitor as a star point to connect the ground lines to the H-bridge (which should be as short as possible), the 24V power supply, and the Arduino. The idea is to prevent the motor current inducing any voltage on the ground lines.

I dont quite understand. Do you mean to connect the capacitor before (Vs) or after (output) the H-bridge?

  1. Keep the motor wires well away from the wires to the IR sensor.

They are never closer than 6 inches and they run perpendicular to each other.

  1. If you have a spare ground pin on the Arduino, connect the ground side of the sensor to that and not to any other ground.

I have tried that, but not in conjunction with the other suggestions, I will try it again.

  1. Use shielded cable between the IR receiver and the Arduino, shield connected to ground pin in point 3 above.

I will try to find some shielded cable. Will twisted pair be any help?

  1. An external pullup resistor between pin 19 and +5v will reduce the sensitivity of that pin to noise. Try 2k2 or 4K7. Too low a value will stop the sensor working.

2k2 = 220 ohm? and 4k7 = 470 ohm? :blush:

  1. A capacitor between pin 19 and ground will also reduce the sensitivity to noise. Try 0.1uF. Too high a value will reduce the speed at which the sensor responds.

I did try that without success, but I will try again.

Why have you got a 10K in series with the step and direction pins to the controller? That is making them more prone to picking up interference, why can't you just connect the pins directly?

Well I can and I used to have it like that. Installing the resistor network was one of my shots-in-the-dark in trying to figure out this problem. BTW, I have been reading your website, Grumpy Mike, it has been incredibly informative (although a lot of it is still over my head).

Connect the 1000uF capacitor before the H-bridge, that is, across the power (for the motor) and ground pins. 2k2 = 2.2 kohms (2200 ohms), 4K7 = 4.7 kohms. I think you mentioned that you already had such a capacitor connected about 4 inches from the H-bridge, however it should be closer than that.

When you connected the capacitor between pin 19 and ground, which ground did you connect the capacitor to? It should be grounded very close to the Arduino, to ensure that it doesn't pick up any noise induced in ground wires due to the motor current.

Are you certain that the power supply is capable of supplying the current needed by the motor at startup? If it isn't and the same power supply is powering the Arduino, then the Arduino could be resetting. Would that account for what you observe?

Connect the 1000uF capacitor before the H-bridge, that is, across the power (for the motor) and ground pins. 2k2 = 2.2 kohms (2200 ohms), 4K7 = 4.7 kohms. I think you mentioned that you already had such a capacitor connected about 4 inches from the H-bridge, however it should be closer than that.

Its about 4 centimetres.

When you connected the capacitor between pin 19 and ground, which ground did you connect the capacitor to? It should be grounded very close to the Arduino, to ensure that it doesn't pick up any noise induced in ground wires due to the motor current.

It was connected to an Arduino ground pin (right next to pin 54 on the original Mega).

Are you certain that the power supply is capable of supplying the current needed by the motor at startup? If it isn't and the same power supply is powering the Arduino, then the Arduino could be resetting. Would that account for what you observe?

The power supply is only supplying the motor, but the grounds are connected. The Arduino is definitely not resetting because the code keeps running. (I have the code set to do nothing until it receives some input, so a reset stops all activity.)

Thank you dc42.

  1. An external pullup resistor between pin 19 and +5v will reduce the sensitivity of that pin to noise. Try 2k2 or 4K7. Too low a value will stop the sensor working.

I was just thinking about this. My sensors are configured to ground the pin normally and to open the circuit when triggered by a flag (pin19 is using a RISING edge). In this scenario a pullup resistor would make the sensor read “on” all the time would it not?

Pokey: I was just thinking about this. My sensors are configured to ground the pin normally and to open the circuit when triggered by a flag (pin19 is using a RISING edge). In this scenario a pullup resistor would make the sensor read "on" all the time would it not?

Only if the value of the pullup resistor is too low so that the sensor isn't sinking enough current to ground it effectively.

However, I now realise that the problem is you are getting an apparent low-to-high glitch on the input pin, not the other way round (my fault for not reading carefully enough). Decreasing the pullup resistor isn't likely to improve this, so ignore my point #5 in my earlier email. The possible causes I can see are:

  1. Transient on the power that supplies the IR emitter. You said you had tried isolating the power to the emitter - what do you mean by this? Do you mean you tried driving it from a separate battery or wall wart? The circuit you posted shows the emitter being driven from 3.3v through a 470 ohm resistor. Even a 1v transient might be enough to cause a glitch. I suggest driving the emitter from 5v instead. Also the resistor looks a little high to me, I thought these devices usually wanted around 10mA.

  2. Noise on the ground line connecting the receiver to the Arduino. See point #3 in my earlier email.

  3. Induced voltage in the wiring between the receiver and the Arduino. Shielded or twisted pair for this wiring will help prevent this.

  4. A transient in the ground wiring or power supply to the Arduino causing the Arduino to malfunction. However, you said that it can't be resetting. Have you checked that nothing observable happens if you press the reset button? Even if your code does nothing, output pins become floating after a reset until the pinMode call is made, also internal pullups get disabled until they are enabled again. Either of these could cause something to happen.