Ok, I have my optical switecs now but I need help .

Ok, I have my optical switecs now but I need help.
This could be an electronics issue or a MACH3 software issue.
After being triggerd, my active-low home-signals stay active despite the LED on the input-pin telling me that it no longer is.
http://marcuswolschon.blogspot.com/2018/07/problem-with-optical-input-switches.html

Not 100% sure I understand the Mach3 connection yet but did you try disconnecting the optical sensor from the board (without removing the sensors power) and manually verifying that it works as expected and does not “Latch Up” when interrupted?
I assume that when interrupted the sensor provides gnd to the input of the Mach3?

Have you toggled the active low pin on reset?

If the sensor works ok disconnected then it means the problem is the combination of the sensor and the Mach3 input circuit.

Another thing to consider [although not obvious why it would be creating these symptoms] is the current through the sensors emitter LED. The current in the sensors output is a function of the emitters drive current.

At a quick glance it looks like at 17ma through the LED emitter you will get about 4 ma through the detectors output transistor. I don’t think the TCST 2103 sensors output is being driven fully into saturation.

4 ma may not be enough current from the sensor to power the input circuitry of the Mach3 resulting in the TLP521 also not being in saturation.

The max current in the sensors LED is 60ma so you have some room to play with. I would 1/2 the 220 ohm limiting resistor and see if that helps. Note: it also could mean that this sensors output cannot drive the Mach3 input hard enough.

I have had this problem before with optical sensors and it created weird symptoms because the sensor was not acting non-linear holding logic levels near their threshold. Firmware doesn’t like that!

Of course this could be a bad guess :)!

Wow. That’s really strange. I’d consider putting a pull-down resistor on the signal, in the hopes that the problem is the photodiode is high impedance when it’s not illuminated, but if it’s measuring 0V, then it’s time to go looking inside Mach3.

@donkjr yes, it works well. Also when connected the status LED of the input port of the breakout board shows that it is still working as expeted.

@Mike_Thornbury I do not understand. I was refering to the big, red “RESET” button in Mach3. It does not do any hardware powercycle.

@donkjr I can try a lower resistor.

It looks like I should have used 180 Ohm (20mA) instead of 220 Ohm (just 15mA). Maybe the current on the input is enough for the status LED to be visible but not for the optoisolator on the input to give a clear signal to the electronics behind.

The strange thing is, that before it is interrupted, the input is triggerd and stable. Also the lack of input due to interruption is registered instantly and when ceasing to interrupt, the input status LED comes back on. I figured if the status LED visibly lights up, the LED inside the optocoupler would too. But I can try that next weekend. (60mA is the absolute maximum rating as far as I understand it.)

@John_Bump There is a 10K pulldown resistor on the signal.
Before connecting things, I did meassure it to drop from 5V to 1.9V when interrupting. This looked a bit much compared to 0V but this part seems to be registered instantly and always correctly in MACH3.
As after a MACH3 reset (that only resets any software error conditions and does no hardware changes) the signal is correctly registered as inactive=high again and the status LED on the input pin also reflects the interruption/no interruption status bright and clear, I assume a software issue.

I did the math for my 220Ohm current limiting resistor on the (E)mitter side and am coming up with 2mA on the digital input. (4mA with the proper 180Ohm one)

Would that still be enough to light up the red status LED just as bright as the other ones or is my math wrong?

Analog, non-linear electronics is not my strong side.

@Marcus_Wolschon
Attached is my napkin math for the corresponding circuit.
At (A):
…The If vs Ic graph guess = 4 ma
…The CTR calculation 1.7-3.4 ma

At (B):
CTR calculation 2-24 ma (big range :frowning: ! )
The If vs Ic graph guess 3-10 ma

It depends:
As you can see from above the #'s are quite broad so many times I have had to overdrive [albeit safely] these couplers to work reliably.

I don’t know what voltage LED D2 needs to turn on and what current is needed to illuminate it.

4ma can illuminate some of the newer led’s but I wonder more about D3 and if it is really outputting enough light at 4ma to properly turn on the output of the coupler on the Mach3 reliably.

The LED D2 in series with the input just bothers me …

That said and further bothering me is that I would imagine that it wouldn’t take much to get the output B to switch to grnd and am guessing that it is connected to a high impedance logic.

Try *
The TCST2103 is capable of a lot harder drive so I would just reduce the 220 to 110 and test it.

*Back up a moment
1.) I assume that this worked with a simple switch input at A? [perhaps obvious but I had to ask]
If the answer is yes then I would guess the problem is some weird combination of using an optocoupler driving an optocoupler (analysis above). It also suggests the software is not the problem.
If the answer is no then we are digging in the wrong ditch :).

Getting clues

If you are still stuck I would measure the voltage at A and B under interrupted and open conditions at the sensor to see if it is switching properly and also to verify that the napkin analysis is not misleading us.

If the uninterrupted sensors output is fully turned on the voltage across the sensors output (from the 5v to the output) should measure approx .4 vdc.

You could also measure;
… the current through D1
… the current going into A
… the voltage drop on D2 & D3

Break out the scope and look at B dynamically.

missing/deleted image from Google+

I don’t know specifics about optical sensors, but I got a work around for my NPN inductive proximity sensor. I had to put a 470 ohm resistor from the input signal wire into a +5v port to collect “leaking current” from the input signal. Later, I also had to wire the pc ground wires to the machine to eliminate noise. Now, they seem to work fine. I think mine were active low, but my estop had to be set active high.

Now this is strange.
I am back, switched everything back on, booted the MACH3 touchscreen PC again
and I meassured the voltage levels in the fully connected circuit… hig=4.4V low=0.3-0.39V

This looks perfectly normal.
I tested it and… with Mach3 everything just WORKS.

Maybe some connector (that I removed for testing) was not making full contact or I had the wrong GPIO selected in MACH3 and it was floating and affected by the input next to it.
I guess we’ll never know.

@Marcus_Wolschon … the phanthom left! He will be back… Glad your running again.

There is a good description of limit switches and optical isolators for noise immunity here: