ROBO Mobile Set mit Arduino

Alles rund um TX(T) und RoboPro, mit ft-Hard- und Software
Computing using original ft hard- and software
Forumsregeln
Bitte beachte die Forumsregeln!
Antworten
Brian
Beiträge: 13
Registriert: 23 Jan 2015, 23:18
Wohnort: Enzkreis

ROBO Mobile Set mit Arduino

Beitrag von Brian » 24 Jan 2015, 11:53

Hallo ft-Gemeinde,

ich bin gerade dabei, das ROBO Mobile Set mit einem Arduino zu "verheiraten":
Anstelle des Robo Interfaces erfolgt die Steuerung über einen Arduino Uno R3 mit Adafruit Motorshield V2, Versorgung über 9V (6 x 1,5 AA-Batterien bzw. Netzteil)
Die beiden Taster an den Motoren (quasi die "Ersatz-Encoder") sind jeweils an einen Digitaleingang (interner PullUp aktiviert) und an GND des Uno angeschlossen, die Impulse (jeweils die wechselnden Flanken) werden über die beiden externen Interrupts des Uno gezählt.
Allerdings - und nun zum Problem - werden auch Interrupts ausgelöst (also Impulse gezählt), wenn der Taster gar nicht betätigt wird.

Meine verschiedensten Versuch haben folgendes ergeben:
- die Interrupte werden nur dann ausgelöst, wenn mindestens einer der beiden Power-Motoren läuft
- wenn ich statt eines Power-Motors einen MiniMot1 oder sogar einen alten 6V-Motor (ein "Grauer") anschließe, gibt es keine unerwünschten Interrupts
- frage ich die Impulse in der Loop des Uno-Sketches ab (polling), erhalte ich einwandfreie Werte (inkl. softwareseitiger Entprellung) auch bei laufenden Motoren

Daraus ergeben sich für mich folgende Fragen:
- Sind die im Robo Mobile Set verwendeten Motoren solche Störquellen, die in die elektronische Schaltung des Uno ausstrahlen?
- Ist das bei allen Power-Motoren der Fall, sprich: Hat schon jemand ein vergleichbares Problem mit diesen Motoren erlebt oder davon erfahren? Oder könnte ein Austausch beider Motoren Besserung bringen?
- und das wichtigste: Wie kann ich dieses mein Problem lösen?

Auf der HP von Adafruit wird empfohlen, am Motor zwischen den Anschlüssen einen 0,1uF Kondensator einzulöten. Ein testweiser Anschluss eines solchen Kondensators brachte allerdings keine spürbare Verbesserung. Kann es tatsächlich helfen, auch jeweils zwischen den Anschlüssen und dem Motorgehäusen so einen Kondensator anzulöten? Gibt es auch andere Möglichkeiten?

Über sachdienliche und zielführende Hinweise und Anmerkungen würde ich mich sehr freuen! Vielen Dank im Voraus! 8-)
Bei Bedarf stelle ich natürlich den Code gern zur Verfügung.

Herzliche Grüße
Thomas
ESP8266 ersetzt RoboIF bzw. TX(T) Controller,
mit Fischertechnik Aktoren und Sensoren.

Ad2
Beiträge: 304
Registriert: 31 Okt 2010, 22:20

Re: ROBO Mobile Set mit Arduino

Beitrag von Ad2 » 24 Jan 2015, 17:10

Hi,

I hope you read english. It seems indeed that the motor is the cause of the problems. You can indeed try to reduce the electrical noise the motor makes (due to its commutation) but apparently the capacitor was not sufficient. The noise can enter the arduino in two ways: galvanic (typically over the power or ground connections) or "over the air" (electric or magnetic coupling). To avoid problems with the power connections you need a good low-impedance power supply and keep the high power wires (motor) separate from the low power wires (arduino, sensors). The best is to have only 1 ground connection close to the power source and supply everything from there in a star configuration. The idea is that the arduino and the sensors have the same ground reference. Magnetic coupling can be reduced by keeping the motor wires together such that the area of the electric circuit is minimised, the same goes for the sensor wires. The worst you can do is to connect the ground of your sensor to the ground of your motor (or motordriver) and route your sensor signal via a completely different route to the arduino. Electric coupling can be avoided by shielding but also by lowering the impedance of the circuit. You say you get false interrupts when the switch is not active, I take it that in that case you have an open circuit with on the other end of the wire the input and the pull-up (high impedance circuit). In that case it may help to use an external pull-up of only 1k or so.
If, on the other hand, the false interrupts occur with the switch closed (low impedance circuit) you may have a ground reference problem or an inductive problem.
If there is no way you can avoid that noise arives at the input, you can try to filter it out because the noise usually contains higher frequencies than your sensor. If the interrupts occur with an open switch it might help to connect a capacitor between input and ground. You choose the time constant (RC product) about ten times shorter than the shortest pulse you expect. A disadvantage of this technique is that it takes longer for the signal to cross the voltage region between definitely low and definitely high. In this region the input is very vulnerable to noise and should in fact only be used with schmitt-trigger inputs.
You say that with polling the circuit works reliably, this can be explained by the short duration of the noise pulses. The chance that you sample during one these pulses is very low. An interrupt on the other hand is sticky. When the number of interrupts is not too excessive you can filter the noise in software by testing, in your interrupt handler, whether the signal is really low (or high) and if not, just ignore it. Remember however that also when using interrupts you have to debounce the signal. Another technique that does not require debouncing is to sample the input on a timer interrupt (e.g. every 5 or 10ms) This is slow enough for noise reduction but fast enough for counting your pulses and again low enough to reject contact bounce.

Brian
Beiträge: 13
Registriert: 23 Jan 2015, 23:18
Wohnort: Enzkreis

Re: ROBO Mobile Set mit Arduino

Beitrag von Brian » 24 Jan 2015, 18:13

Hello Ad2,

thanks a lot for your answer!
You gave me some additional hints I must investigate ;)
I will come back with some results.

Perhaps I will find a solution - at least I hope so!

THX again!

Best regards
Thomas
ESP8266 ersetzt RoboIF bzw. TX(T) Controller,
mit Fischertechnik Aktoren und Sensoren.

Brian
Beiträge: 13
Registriert: 23 Jan 2015, 23:18
Wohnort: Enzkreis

Re: ROBO Mobile Set mit Arduino

Beitrag von Brian » 24 Jan 2015, 20:18

Hello Ad2,
Ad2 hat geschrieben:...
It seems indeed that the motor is the cause of the problems. You can indeed try to reduce the electrical noise the motor makes (due to its commutation) but apparently the capacitor was not sufficient.
...
May it help to decrease the capacity of the capacitor?
Ad2 hat geschrieben:...
The noise can enter the arduino in two ways: galvanic (typically over the power or ground connections) or "over the air" (electric or magnetic coupling). To avoid problems with the power connections you need a good low-impedance power supply and keep the high power wires (motor) separate from the low power wires (arduino, sensors). The best is to have only 1 ground connection close to the power source and supply everything from there in a star configuration. The idea is that the arduino and the sensors have the same ground reference.
...
I build my circuit in this way. The high power wires go to the input of the Motorshield and via Vin to the Arduino. So the sensors (just the black mini switches from ft) are connected to the Arduino on Pin 2 and Pin 3, with the internal Pull-Up activated.
Ad2 hat geschrieben:...
Magnetic coupling can be reduced by keeping the motor wires together such that the area of the electric circuit is minimised, the same goes for the sensor wires. The worst you can do is to connect the ground of your sensor to the ground of your motor (or motordriver) and route your sensor signal via a completely different route to the arduino. Electric coupling can be avoided by shielding but also by lowering the impedance of the circuit. You say you get false interrupts when the switch is not active, I take it that in that case you have an open circuit with on the other end of the wire the input and the pull-up (high impedance circuit). In that case it may help to use an external pull-up of only 1k or so.
...
I tried this: Deactivate the internal PullUp and use an external PullUp with 1k and 220ohm. With the first one no difference - just false interrupts again. But with the second one, those false interrupts on one sensor circuit were gone! :D But on the other sensor circuit the still exists, less, but still there. :?
Ad2 hat geschrieben:...
If, on the other hand, the false interrupts occur with the switch closed (low impedance circuit) you may have a ground reference problem or an inductive problem.
...
That's not the case.
Ad2 hat geschrieben:...
If there is no way you can avoid that noise arives at the input, you can try to filter it out because the noise usually contains higher frequencies than your sensor. If the interrupts occur with an open switch it might help to connect a capacitor between input and ground. You choose the time constant (RC product) about ten times shorter than the shortest pulse you expect. A disadvantage of this technique is that it takes longer for the signal to cross the voltage region between definitely low and definitely high. In this region the input is very vulnerable to noise and should in fact only be used with schmitt-trigger inputs.
...
Can you please explain that more exactly to me? How and where to connect the capacitor? And what do you mean with "RC product"?
Ad2 hat geschrieben:...
You say that with polling the circuit works reliably, this can be explained by the short duration of the noise pulses. The chance that you sample during one these pulses is very low. An interrupt on the other hand is sticky. When the number of interrupts is not too excessive you can filter the noise in software by testing, in your interrupt handler, whether the signal is really low (or high) and if not, just ignore it. Remember however that also when using interrupts you have to debounce the signal. Another technique that does not require debouncing is to sample the input on a timer interrupt (e.g. every 5 or 10ms) This is slow enough for noise reduction but fast enough for counting your pulses and again low enough to reject contact bounce.
I thought about using a timer interrupt, but at the moment I didn't follow this idea because I want my motors to run without that noise.

Thanks again for your help!

Best regards
Thomas
ESP8266 ersetzt RoboIF bzw. TX(T) Controller,
mit Fischertechnik Aktoren und Sensoren.

Ad2
Beiträge: 304
Registriert: 31 Okt 2010, 22:20

Re: ROBO Mobile Set mit Arduino

Beitrag von Ad2 » 25 Jan 2015, 13:00

May it help to decrease the capacity of the capacitor?
Typically not, you want a low impedance for high frequencies. The impedance (in Ohm) of a capacitor is 1/(2*pi*f*C) where f is the frequency and C the capacitance. So the higher the capacitance the better. On the other hand the large electrolithic capacitors often have a large ESR at high frequencies which makes them unsuitable. So use a non-electrolithic one in the range 0.1uF - 2.2uF. In any case do not connect an electrolithic capacitor directly across the motor terminals because they tend to blow up with reversed polarity. You can use them across the supply of the motorshield however.
The high power wires go to the input of the Motorshield and via Vin to the Arduino. So the sensors (just the black mini switches from ft) are connected to the Arduino on Pin 2 and Pin 3, with the internal Pull-Up activated.
I'm familiar with the ATMega328 but not really with Arduino or the shields so I don't know if this is the best solution.
But with the second one, those false interrupts on one sensor circuit were gone! :D But on the other sensor circuit the still exists, less, but still there. :?
Funny, are there any differences like cable routing?
Can you please explain that more exactly to me? How and where to connect the capacitor? And what do you mean with "RC product"?
Motor noise is often a spikey noise rich in high frequencies. You can try to filter those out by making your circuit "slower". When you connect a capacitor between input and ground, the input voltage can rise only slowly because the capacitor has to charge through the pullup. It will discharge quickly however through the switch. The time for the signal to rise is the RC time, the multiplication of resistance and capacitance. The RC time is the time needed for the capacitor to discharge itself, through the resistor, to 37% of its initial charge. Or, in your case, to charge itself, through the pullup to 63% of its final voltage. So a capacitor of 0.1uF and a resistor of 1k give an RC time of 0.1ms or 100us. In a formula: Vc=Vsupply(1-exp(-t/RC)) where t=time and exp is the inverse natural logarithm. Such a filter makes the signal analog rather than digital. With a schmitt-trigger you can make it digital again. That circuit provides a hysteresis to prevent the signal to flapper between 0 and 1 when it is close to the threshold.

Antworten