0
\$\begingroup\$

I'm trying to make circuit which will allow me to sense some platform presence at the ends of some rail.

I'm using the limit switches, here is schematic:

enter image description here

SENS-* signals connected to MCU pins, that is configured to trigger an interrupt on a rising edge of a signal. When I trigger manually only one of the switches - then both interrupts are triggered - right one first and wrong one second. It seems like signal from switches interfere each other through GND line, but I cant figure how exactly.

How to prevent triggering of a second interrupt? I feel, that there is some well known solution, but I could not find it.

\$\endgroup\$
  • 1
    \$\begingroup\$ What is the outcome when you measure the condition of the pins? \$\endgroup\$ – PlasmaHH Jun 18 '15 at 10:00
  • \$\begingroup\$ @PlasmaHH, What do you mean by condition of the pins? Their logical states? I dont read states of pins directly. I'm using STM32 MCU with an external interrupt controller (EXTI), configured to trigger an interrupt when signal on a pin goes from logical 0 to logical 1. And I'm using that handler routines, not the values from the pins. \$\endgroup\$ – Vasilly.Prokopyev Jun 18 '15 at 10:31
  • \$\begingroup\$ @PlasmaHH, Sorry, now I've got what you meant, I'l try to measure pin states directly \$\endgroup\$ – Vasilly.Prokopyev Jun 18 '15 at 10:38
1
\$\begingroup\$

Since you are trying to manage mechanical limit switches using interrupts generated from the edge of the signal be aware that you could get multiple interrupts when the switch first closes. This is caused by the bounce of the switch contacts.

Depending upon how the platform limit switches are used in your application you may want to consider a more robust solution that is commonly used in motion control systems. Each end of travel uses two sets of sensing. The first one that the platform would trigger near the end of travel would be one that does not use a mechanical switch. Instead it may be an optical interrupter or an indexing pulse of an optical encoder. Such signal is your logical end of travel and will be much more repeatable in terms of position detect. In fact with a controlled positioner this may be repeatable to the same position each time.

The second limit to be triggered would be the mechanical switches as you have now but connected is an emergency cutout. Such contacts would be wired directly to disable the drive signals to the platform positioner. Under normal operating conditions these contacts would never trigger and there would be some range of platform motion between when the logical trigger and when these emergency switches would engage.

Mechanical switches have a lot of hysteresis in them and will not give a repeatable end of travel position reading when you are using a servo or stepper to control the platform motion.

One final note on the emergency cutout switches. The limit cutout switch for the (+) direction wants to only cut out the drive control of (+) direction stepping. Likewise for the (-) direction of the platform. This is important because it still allows the control system to move the platform away from the emergency stop position to regain control of the platform in recovery positioning.

\$\endgroup\$
  • \$\begingroup\$ Thank you, I wanted to delete question, but this answer... My project is easy and cheap DIY project, so there is no need for any precise or robust approaches. Still, could you provide me with an example of mentioned optical sensor? \$\endgroup\$ – Vasilly.Prokopyev Jun 18 '15 at 16:44
0
\$\begingroup\$

Thanks to PlasmaHH comment, I found the problem - there was some solder error in my circuit. Now everything works.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.