View Full Version : Sensing a position

T Chap
03-07-2007, 05:40 AM
I need to have a Propeller on boot move a motor(Home) CW till it hits a limit switch then zero the HomePos variable, then it needs to move to the farthest CCW position and hit another switch, writing the MaxTavel position. The code with then use HomePos + X as it's home position, allowing some amount of distance offset. The same goes for MaxTravel = Maxtravel - Y

I have used current sense before to locate a hard stop, but have seen cases where it can fluctuate depending on temp and other factors related to the motor used. In this new case, it is a brushless DC servo motor, which will have some advantages over the stepper(a stepper can vary its current draw based on where it is sitting in the sequence when micrstepping). The DC motor may very well work out, but I can't test it yet.

The object being moved is a sliding door and is not ideal for mounting wire to it, the door frame is ok to mount to. The options I have so far are swithes or hall sensors with magnets on the door. There are concerns with each method, the switches may fail after so many years. The magnets and hall sensing(comparator) may lose some strength, and the calibration reading them may drift. Magnetic switches, like in the alarm systems seem reliable, but appear that they are not designed for precise positioning( tolerance is about +- .0025"

Anyone have any ideas they could share for a maintenance free solution for precision limit switching?

Post Edited (originator) : 3/7/2007 12:33:01 AM GMT

Chris Savage
03-07-2007, 06:16 AM

Does the position sensing need to be on the door side of the equation? I guess what I am saying is it may be possible depending on your application to monitor the other side of the mechanics for limits. That may offer and easier path for a reliable means to detect limits. Also, have you considered optical detection? Perhaps a slotted IR device in which a tab breaks the beam?

Chris Savage
Parallax Tech Support

Mike Green
03-07-2007, 06:27 AM
You could also use an LED/Phototransistor interrupter with a welded/screwed-on/riveted metal flag on the door frame. None of your suggested solutions (magnetic switch, Hall effect switch) will likely give you the tolerance you want. If you had a shaped hole in the flag, you could use the first loss of light (from the edge of the flag) to slow down the door, then measure the voltage from the phototransistor to see how far the hole had moved over the interrupter. I don't know how precise you could get with this, but it's a thought.

Phil Pilgrim (PhiPi)
03-07-2007, 06:46 AM

What are the conditions under which the sensor must work (i.e. temperature, moisture, ambient light, airborne dust, etc.)?


T Chap
03-07-2007, 07:11 AM
Phil Think typical residential door retrofits with a Star Trek door, so it is going in bathrooms, bedrooms, etc., generally air conditioned buildings, moisture/humidity will vary by state.

The door is a pocket door, so it goes inside a wall when open. Typically when closed, it will go into a 5/8" wide x 1/2" deep dado/slot in the door jam.

Chris, the system is auto tuning, so the limits have to be based on the physical travel of the door, which is unique in every case. Granted that the timing belt that moves the door could actually have something attached to it, a magnet or flag for example. Inside the wall where the actuator lives, there is much less ambient light btw.

A pin hole in a light "receiver" mounted above the jam may be workable, the door can easily have a metal glah attached to it to break the light, which can be extremely precise.

Thanks for the ideas.

The controller is shown below, a thumbprint scanner add-on coming soon, will mount just below it. This panel is a black anodized Qprox operated sensor I designed that controlls the motion/locking. The door is shown in black laminated glass, Starfire hardened glass, frameless, 1/2 thick.

Post Edited (originator) : 3/7/2007 12:24:06 AM GMT

Phil Pilgrim (PhiPi)
03-07-2007, 07:33 AM
I like the idea of a pinhole optical switch. But small holes can become occluded with dust rather easily. It might be worth the trouble to ensure that the flag containing the hole gets wiped clean with each actuation, using fuzzy weatherstripping or somesuch.


Chris Savage
03-07-2007, 08:36 AM
I agree with Phil…The optical system would need some self-maintenance. Easy enough to do though using his suggestions. The optical idea was more for inside the door jamb. The door itself would interrupt the slot. But weather stripping on the end would easily help remove line and dirt from the slot each pass. Nice idea Phil.

Chris Savage
Parallax Tech Support

T Chap
03-07-2007, 09:05 AM
The optical seems like the best idea. I failed to mention that the motor has encoders already being read by the Rotary Object.. There may be a better solution using the existing encoders. The Prop could look at the count, if a count doesn't arrive as expected, then it stops the motor(or motor move command rather), resets the HomePos variable. Any opinions on this idea? No additional costs/hardware, and dust free.

Current limiting is done via DAC from the Prop to the BLDC motor. Minimal torque and very low speed could be used to home each direction, avoiding damage to drive train.

PUB HomeMotorCCW 'move motor CCW towards HomePos (to set HomePos to 0)
cognew(MoveMotorCCW, @stack1) 'start the motor
CurrentPos := CounterVal 'set current pos to encoder val, motor is running
If Counter < CurrentPos 'check for negative count/motion on the encoder
Repeat while CounterVal < CurrentPos 'check CounterVal, if motor is moving it will be less than than
CurrentPos := CounterVal 'update current pos
HomePos := 0
cognew(MoveMotorCW(OffsetVal), @stack0) 'move motor away from the hard stop

Post Edited (originator) : 3/7/2007 4:20:03 AM GMT

kelvin james
03-07-2007, 01:48 PM
A couple of thoughts------- you will need a safety device for closure, that could get you the far limit, like the spring loaded pads on elevator doors or a garage door, or even a pressure sensor. I don't see why you can't run wires in the door, you won't see the outside of the inner frame in the pocket. If you are using external detection for safety, that kinda throws that out. How about a linear encoder strip on the top of the door frame and the encoder inside the pocket. " If the encoder has auto indexing, it should always know its position".

T Chap
03-07-2007, 02:06 PM
Thanks Kelvin, good ideas. I already have the motors current sense for safety, plus an inner layer of ITO in the glass door(clear metalized film) that is connected to the Qprox touch sensors and set very sensitive, even 4-6 inches away for a human body and the glass door will trigger and retract towards open. The edge of the glass is frameless and cannot have an edge of some sort as a contact switch, the slot the door goes in when closed cannot have visible components as well for cosmetic reasons, must be a clean look, no rubber or plastic. For safety I have it covered, just not for limit setting. I am liking the motor encoder idea more and more that was derived from the brain storming here. I am quite certain that method is used on other systems I have used that incorporate hard stop homing. I will program low speeds and low torque for the homing and it will work out nicely I think.

I have previously looked at the USdigital linear encoder strips, and ruled them out due to a number of reasons. One s that the system needs to self calibrate to the limits, which vary from situation to situation.

Post Edited (originator) : 3/7/2007 7:15:44 AM GMT

kelvin james
03-08-2007, 01:24 AM
Won't there be an issue with the edge of the tempered glass being exposed to contact? I have seen many a piece of tempered glass been reduced to a pile of glass bits from being hit on the edge.

T Chap
03-08-2007, 01:56 AM
Somebody said...

Date Joined Oct 2004
Total Posts : 309
Posted Today 10:24 AM (GMT -8)
Won't there be an issue with the edge of the tempered glass being exposed to contact?

No we don't have a problem, unless you take a hammer too it. The edge goes into a small groove in the wall that does not have metal near it. The glass is laminated with a rigid poly innerlayer, so it is quite robust, I have really abused these things in testing, and thought many times they were going to break. There are other versions, stainless, wood etc.

kelvin james
03-08-2007, 02:13 PM
I have to say that using the Qprox with the glass as a sensor is super clever idea. I looked at the Qprox stuff a long while ago and was impressed with the possibilities, but the manual scared me off. Configuring the chip seemed to be fairly complex, it would be nice if you could give some feedback about it. Once you get this finished, if you put together a demo video, i am sure my employer would be interested, they are always looking at new technology along this line.

T Chap
03-08-2007, 02:40 PM
The Qprox is extremely simple. I use the 160, it is 6 inputs, with a feature called "adjacent key suppression". I built the touch panels out of one solid piece of .25 aluminum, the routed out the back to create a glue pocket to support it when I cut out the front. When the glue is cured, I route out a .05 separation over the front and the part is then electrically 5 pieces, although it was never separated, it is perfectly fitted together. The front is then filled with black epoxy, grainged and anodized in various colors. Since the aluminum parts are so close, you need the supression to avoid false triggers. The field can be set to put you hand even 6" inches from the metal panels or glass, but that really isn't needed on the panels, I like to actually touch the panel. The glass is set sensitive, for several inches. With Qprox, a single cap sets the sensitivity. There is a hardwire setting for how long the output will remain on for each press, 10 seconds or infinity I think. The 161 doesn't have the suppression, you can find a part that suits you needs. There is nothing like touch stuff though for a nice effect. Below the basic 160 layout, you just run the leads to something metal, I use a bolt from a circtuit board to contact the back of the panel sections, I drilled a .20 hole in the .25 alum using a square cut end mill, then thread milled 1/4" 28 threads in it with a multi tooth(one pass around), then mount the PCB to the rear with 1/4" bolts .375 long.

The Qprox glass thing took a long time to solve, I spoke to many consultants, 3m, you name I talked to them, finally after a 100 calls found an ITO clear film that is great. I send it to the laminator and they press it in between the glass.

The 160 has been replaced with 1081 8 inputs

www.qprox.com/downloads/datasheets/qt1081_r1.03.pdf (http://www.qprox.com/downloads/datasheets/qt1081_r1.03.pdf)

Post Edited (originator) : 3/8/2007 7:45:29 AM GMT

kelvin james
03-09-2007, 01:49 PM
Thanks for the info on the qprox, guess i was reading into it a lot more than was necessary.