Pages: 1 [2]   Go Down
Author Topic: False triggering IR light gate  (Read 3007 times)
0 Members and 1 Guest are viewing this topic.
California
Offline Offline
Full Member
***
Karma: 0
Posts: 144
One man with the truth is a majority.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Quote
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.

Quote
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?

Quote
2. 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.

Quote
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.

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

Quote
4. 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?

Quote
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.

2k2 = 220 ohm? and 4k7 = 470 ohm? smiley-red

Quote
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.

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

Quote
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).

Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

California
Offline Offline
Full Member
***
Karma: 0
Posts: 144
One man with the truth is a majority.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

Quote
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).

Quote
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.
Logged

California
Offline Offline
Full Member
***
Karma: 0
Posts: 144
One man with the truth is a majority.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

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?
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

California
Offline Offline
Full Member
***
Karma: 0
Posts: 144
One man with the truth is a majority.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Quote
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?

A wall wart at 5v. I tried 5v again this morning to no avail.

Quote
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.

I have the interrupt programmed to set pin/LED 13 to high. When I start the motor pin 13 goes high, and when I press the reset button pin 13 goes low. If the Arduino were resetting LED 13 would turn off.

I tried disconnecting the ground between the 24v power supply and the rest of the circuit, as Riddick suggested, and the problem did NOT occur when starting the motor manually. So the problem is definitely on the 24v ground. I think this eliminates point 2 (I did try again connecting the sensors directly to an Arduino ground pin though without result) and 3 in your most recent post.

I would rather not have to use optical isolation because I want to get current feedback from the H-bridge. Is there anything else I might try, perhaps and inductor or more/different capacitors on the 24v H-bridge supply (I am just guessing...)?

Thanks.
Logged

California
Offline Offline
Full Member
***
Karma: 0
Posts: 144
One man with the truth is a majority.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I tried disconnecting the ground between the 24v power supply and the rest of the circuit, as Riddick suggested, and the problem did NOT occur when starting the motor manually.

I spoke too soon! smiley-eek After doing some more testing, the interrupts still trigger when everything is disconnected between the H-bridge board and the Arduino.
Logged

Brunsbüttel, SH, F.Rep.GERM
Offline Offline
God Member
*****
Karma: 4
Posts: 596
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hm

maybe the cables between the arduino and the sensor act as an antenna?
what if u use really short cables?
or what if u put those cables far away from the motor?

or maybe it is like my fridge: the 24V PSU does something on the mains line that the 5V PSU picks up...?
what if u use batteries instead of the 5V PSU?
Logged

-Arne

California
Offline Offline
Full Member
***
Karma: 0
Posts: 144
One man with the truth is a majority.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
maybe the cables between the arduino and the sensor act as an antenna?
what if u use really short cables?
or what if u put those cables far away from the motor?

I really think this may be it. I tried grounding the interrupt pins to the Arduino board, using a few inches of wire, and the problem did NOT occur. After doing a lot of searching and reading yesterday, I am beginning to think that my machine's frame itself may be acting as an antenna too (something that had never occurred to me before). It has a 5-foot long rectangular metal frame that is not grounded. (See attached overview photo.)

The machine consists of several motors (including two high-amp AC motors) and several DC motors. I was focusing on getting each component running individually which is why I was looking only at the 24v motor. I have now discovered that any sudden power draw on the AC lines going into the machine will trigger the interrupts.

I will try now:

1) Grounding the machine frame.

2) Installing twisted pair conductors for the sensors.

3) Installing 0.01uF capacitors on the sensor lines.

This is turning into quite a saga, but it is the way I learn things. When I started this project I had no idea how complicated electronics could be... smiley-sad-blue

Anyway enough rambling, I will let you know how it works.

Gratefully,

Pokey


* frame.jpg (209.48 KB, 1024x844 - viewed 26 times.)
« Last Edit: January 21, 2012, 02:31:40 pm by Pokey » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Installing 0.01uF (or even 0.1uF) capacitors on the sensor lines may help, but make sure the ground sides of those capacitors are connected to Arduino ground as close to the Arduino as possible - preferably to an Arduino ground pin that is not the one you connect power in/out or output devices to. Otherwise the capacitors will transmit noise on the ground line from the power supply and/or devices you are controlling to the inputs, and make things worse.

Think of every ground or power supply wire as a potential inductor, which has a voltage appearing across it if the current through it changes suddenly.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

California
Offline Offline
Full Member
***
Karma: 0
Posts: 144
One man with the truth is a majority.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, here is the update.

Grounding the frame, using twisted-pair wires, and .01uF capacitors (to ground on the pin side) has resulted in 95% stability for the sensors. A huge improvement over my former 0% stability! smiley So I am very happy about that.

In the interest of gaining 100% stability I will try connecting a 1K pull-down resistor to ground on the pin side of the sensor.

I am very hopeful that this will work.


Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just a reminder of my earlier suggestion:

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.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

California
Offline Offline
Full Member
***
Karma: 0
Posts: 144
One man with the truth is a majority.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, dc42, I changed the emitter to 5v.

The circuit is now working well!

A big thank you to Riddick and dc42!

If I could, I would buy you both beers! smiley-grin
Logged

Brunsbüttel, SH, F.Rep.GERM
Offline Offline
God Member
*****
Karma: 4
Posts: 596
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

*wag tail*
Logged

-Arne

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If I'm ever in California, I'll drop by and claim a beer!
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Pages: 1 [2]   Go Up
Jump to: