Maker Pro
Maker Pro

Micro motor control with 2 detector switches

I have a discontinued drone that uses 2 "worm servos" to raise and lower its landing gear when a toggle switch is flicked on the transmitter. (see pic)

I put "worm servo" in quotes because it's not a worm servo at all. It's actually a small micro motor that turns a geared threaded post that moves a small brass bar back and forth until it makes contact with one of two detector switches. (see pic)

Unfortunately these worm servos are impossible to replace and I am forced to replace their PCBs that have been burned out. The 1" x 1/4" PCB looks extremely complicated for what it's actually doing, so I'm hoping to dumb it down as much as possible.

There are three wires that power the PCB.

Red (+4.61v) constant
Black (GND)
White (+0.16v) that changes voltage to (+0.27v) when the transmitter toggle switch is flicked.

So the circuit works like this:

1. On power up, the white wire voltage is +0.16v
2. The motor moves forward until it triggers the detector switch on the right.
3. The motor stops
4. The transmitter toggle switch is flicked and the white wire voltage changes to +0.27v
5. The motor reverses until it triggers the detector switch on the left
6. The motor stops
7. The transmitter toggle switch is flicked back and the white wire voltage changes back to +0.16v
8. The motor goes forward until it triggers the detector switch on the right again

I would like to try to do this on a white project breadboard first with non-SMD components. I have a sample box of ICs including NE555, LM339, LM393, LM324, LM358, LM386, NE5532, TDA2822 as well as capacitors, resistors, diodes, mosfets, etc.

My simple logic says, "Hey, this is easy. The detector switches just cut the power to the motor so all I need to do is reverse the motor." This is wrong because if I reverse the motor, the switch is released and the motor will try to go back again and then smoke and kaboom. Now diodes or a comparator will probably need to come into play.

Now here's the fun part. I have the electronics skills of a child so I'm asking a-lot of this community. So without any expectations, I'm hoping someone can point me in the right direction circuit-wise. It was suggested that I use a 555 timer to start but I don't even know where to begin. I can read schematics, BTW, but I haven't found much online to direct me when it comes to using these components, especially when it comes to reversing a motor when the +0.16v changes to +0.27v.

That's it. You can stop laughing now.

View attachment 53845 View attachment 53846 IMG_20220111_151826.jpg tali.jpg IMG_20211220_153208.jpg
 
Last edited:

Harald Kapp

Moderator
Moderator
That's it. You can stop laughing now.
Nothing to laugh at ;)

I imagine a solution along this schematic using an H-bridge:
upload_2022-1-12_7-13-45.png

I assumed:
- 3.3 V operation. This could be any other voltage as present in your circuit.
- Inverters with a low threshold above 0.16 V. A typical CMOS inverter operated from 3.3 V will fulfill this condition. But a typical CMOS inverter operated from 3.3 V will not recognize 0.27 V as high. You'll probably have to use a comparator to generate proper logic level signals from this Vin. It may well be that a pull-up resistor is sufficient, that depends on the driving stage delivering Vin which we don't know.
- Logic level MOSFETs with |VGSth| < 1.5 V or so.

Operation:
Initially Vin is at 0.16 V.
The output of the left inverter is high which turns Q3 on and Q4 off.
The output of the right inverter is low which turns Q2 on and Q1 off.
Motor turns left until the left limit switch is reached. Once the left limit switch is reached, it opens and the motor stops.

Vin goes high (>= 0.27 V),
The output of the left inverter is low which turns Q4 on and Q3 off.
The output of the right inverter is high which turns Q1 on and Q2 off.
Motor turns right until the right limit switch is reached. Once the right limit switch is reached, it opens and the motor stops.

As soon as the motor starts turning right, the left limit switch will no longer be operated and will close (note that I used normally closed switches). However, as Q2 is by then off, there will be no current and thus no risk of a short circuit.
This works at the other end in the same way.
 
Last edited:
Nothing to laugh at ;)

I imagine a solution along this schematic using an H-bridge:
View attachment 53853

I assumed:
- 3.3 V operation. This could be any other voltage as present in your circuit.
- Inverters with a low threshold above 0.16 V. A typical CMOS inverter operated from 3.3 V will fulfill this condition. But a typical CMOS inverter operated from 3.3 V will not recognize 0.27 V as high. You'll probably have to use a comparator to generate proper logic level signals from this Vin. It may well be that a pupp-up resistor is sufficient, that depends on the driving stage delivering Vin which we don't know.
- Logic level MOSFETs with |VGSth| < 1.5 V or so.

Operation:
Initially Vin is at 0.16 V.
The output of the left inverter is high which turns Q3 on and Q4 off.
The output of the right inverter is low which turns Q2 on and Q1 off.
Motor turns left until the left limit switch is reached. Once the left limit switch is reached, it opens and the motor stops.

Vin goes high (>= 0.27 V),
The output of the left inverter is low which turns Q4 on and Q3 off.
The output of the right inverter is high which turns Q1 on and Q2 off.
Motor turns right until the right limit switch is reached. Once the right limit switch is reached, it opens and the motor stops.

As soon as the motor starts turning right, the left limit switch will no longer be operated and will close (note that I used normally closed switches). However, as Q2 is by then off, there will be no current and thus no risk of a short circuit.
This works at the other end in the same way.

Yikes! Definitely appreciate to quick reply Harald. Unfortunately this already hurting my brain. I'll certainly have my work cut out for me to lay this out on a breadboard. Looks like I'm going to need a pair of inverters, 4 low voltage mosfets and will need to stuff a comparator somewhere in the mix. It's safe to assume you meant pull-up resistor and not pupp-up....at least I hope so ;-) And of course I already ordered the wrong detector switches (NOs instead of NCs)

If anything, it's a start...so it's off to Digikey I go.

Thanks again.
 
It looks to me as though the servo has a linear feedback potentiometer for position control. Won't you need to use this in your project?
If so, the circuit required will be more complex than an H-bridge.
 
It looks to me as though the servo has a linear feedback potentiometer for position control. Won't you need to use this in your project?
If so, the circuit required will be more complex than an H-bridge.

It's not really a servo, nor does it act like one. Upon power up or power down, the position will always be set against one of the detector switches (ie. landing gear up, landing gear down). There is no in between.
 

Harald Kapp

Moderator
Moderator
What came to my mind is the somewhat obscure voltage levels you observed. Make sure these are truly steady logic signals. These could also be a pwm signal that is switched between two different duty cycle ratios. This would allow the use of a standard "analog" rc-channel. In that case you would have to build a detector for the pwm signal to distinguish between the two duty cycles and convert these to true logic levels as required by my circuit proposal.
 
What came to my mind is the somewhat obscure voltage levels you observed. Make sure these are truly steady logic signals. These could also be a pwm signal that is switched between two different duty cycle ratios. This would allow the use of a standard "analog" rc-channel. In that case you would have to build a detector for the pwm signal to distinguish between the two duty cycles and convert these to true logic levels as required by my circuit proposal.

Yes, they are steady. Obscure, but steady. I'm starting to think that maybe a microcontroller would be a better option. Kind of a "If voltage = 0.16 then pin 1 do something". I'm dabbling with the idea, but it's way beyond my skill set, if you can call it that. Who knew there would be so much entailed to move a motor back and forth with a transmitter.
 
It looks to me as though the servo has a linear feedback potentiometer for position control. Won't you need to use this in your project?
If so, the circuit required will be more complex than an H-bridge.
I originally thought the same but I think the board with the two limits is just a guide plate.
A pot would have a black trace on it.
After all, it;s just either full up or full down.
 

Harald Kapp

Moderator
Moderator
I'm starting to think that maybe a microcontroller would be a better option.
It would be another option. I wouldn't necessarily say a better one.
The charm of a microcontroller is that you could also feed the limit switches to the controller and use this information to control the gate drive of the H-bridge without the need for the switches to be inside the bridge. A microcontroller can also easily provide the necessary timing. A Attiny85 would be sufficient for this. You'd have to do some bare metal programming though.Nothing extraordinary but less comfortable than e.g. an Arduino with its extensive eco-system of libraries.
The Microchip Studio for programming can be freely downloaded. My preferred language for this case would be "C" (assembler is possible but has an even steeper learning curve).
Or, should you not feel comfortable with "C", use any of the small modules with MicroPython (you'll have to use one with an ADC and at least 4 digital IOs for the limit switches and the H-bridge control signals).
 
A simple ATtiny85 program (only a couple of lines) would be needed to convert the (for arguments sake) less than 1400 and more than 1600 signal into drive for the h-bridge. Inputs from the limits to kill and watch for override with short delay.
 
I've been doing a little research on the ATtiny85 and that seems to be the way to go. It's also a heavily used option for robotics and has a huge forum presence so I've already ordered an Arduino Uno and a bunch of tinys. There's also plenty of SMD breakout board options so stuffing it into the landing gear module won't be as painful as I thought. There really doesn't seem to be an all-component way to differentiate the .16v and .27v from the same wire so it's back to school I go. I've already found some code that reads the voltage and performs an if..then statement so it looks like this might work and seems fun to try. If anything it will be a learning experience. I have a feeling that it will come in handy in the future especially when dealing with outdated drone technology.
 
Last edited:

Harald Kapp

Moderator
Moderator
If you encounter difficulties with using and programming the attiny, I suggest you open a new thread specific to these issues in our microcontroller forum.
It shouldn't be too difficult to get this running. Once you have done the proper initialization (mainly setting the clock options, setting port pin directions an setting up the ADC), its simply readig the ADC and the limit switches, then issuing the appropriate control signal for the H-bridge. Remember to use pull-up (or pull-down) resistors with the limit switches to ensure definite logic low and high levels. The Atmel processors have internal pull-up that can be configured, but these are comparatively high resistance and thus the inputs will be sensitive to external noise. It is imho preferable to use low-resistance (1 kΩ ... 4.7 kΩ) resistors.
Remember also to debounce the switches. In this application this can easily be done in software. Otherwise the gear may act spuriously.
 
Top