Infrared Detector as Limit Switch?

Before I start breadboarding it, I was hoping for any experience or input on the following concept.

I want a limit switch, forward and reverse, triggered by an infrared signal. My original thought was to use a simple IR photodiode sensor, but the smart people out there have persuaded me that using an IR detector module helps with accuracy and rejection of ambient noise.

So, I set about looking at the generation of the 38khz signal needed. It’s pulsed or else it gets ignored by the IR sensor I am using. The output of the sensor module passes through the pulses. So I was designing a pulse stretcher to make sure the limit switch stays high when the following occurred to me:

WHY NOT pulse the 38kHz IR emitter with a duty cycle that can directly drive the PWM input on the driver board?

A pseudo-circuit would look like this:

(38 kHz signal x 50% duty cycle) -> IR LED -> IR Sensor Module -> 50% duty cycle squarewave -> Pololu PWM input set as limit switch

The option to use the pwm inputs as limit switch drivers, with a pre-set duty cycle triggering the limits in forward and reverse is almost too good to pass up?

Any thoughts?

EDIT: this is for the 18v7, one of Pololu’s Simple Motor Controllers

Hello.

Is there a particular Pololu part you are considering?

- Ryan

Ahhh, yes. I am using the 18v7, which, of course, is in the line of “Simple Motor Controllers” pololu.com/catalog/category/94

I should have said that up front.

Okay, so you are thinking about using an RC input as a limit switch? What is the frequency of your 50% duty cycle square wave?

- Ryan

Edited to add: Oops, I didn’t mean to post as a test user. Sorry.

Well, I have not constructed the circuit yet, so I can pick pretty much any frequency I want. I was presuming something within the normal range of pwm signals that are presented to servos, though I understand that to be pretty wide.

Have you a suggestion?

If you pick a frequency so that high pulse time in the normal servo range (1-2ms), the SMC could detect it as a valid RC pulse. You would need to be able to change the pulse high-time based on the state. From the users’ guide RC limit switch section:

I am not sure what exactly you are trying to do, but you might consider using something like our digital distance sensors and the analog inputs on the Simple Motor Controller.

-Ryan

Okay, this is close to what I imagined, so that is good.

The specific application is in a garden train. Train movement control is envisioned as blocks being open or occupied. An occupied block has a red light that means “stay out”.

Well, the “red” light for the train, controlled by the 18v7, will be an infrared light. When the detector sees it, the train should stop until the “red” light goes out. This could also serve as an anti-collision tool if the trains carry IR emitters on their front and back.

My initial scheme was indeed to use the analog input, and I may end up going that way, but with the ambient light rejection of the pulsed IR, and noting that the RC/pwm input just MIGHT serve the goal of the extra circuitry I was thinking of trying, I wanted to give it a try.

If this does not work, I’ll take another look at the distance sensors, but they may get too confused by ambient light to work for me.