Author Topic: Control a servo from a potentiometer, WITHOUT a microcontroller?  (Read 2455 times)

0 Members and 1 Guest are viewing this topic.

Offline I wanted a rude usernameTopic starter

  • Frequent Contributor
  • **
  • Posts: 662
  • Country: au
  • ... but this username is also acceptable.
Control a servo from a potentiometer, WITHOUT a microcontroller?
« on: December 04, 2019, 03:41:22 am »
You may have heard of code golf, which is trying to solve a problem in the fewest lines of code.

Using a microcontroller to read a potentiometer and PWM a servo accordingly is a favourite Arduino task, and can probably be done in a few lines of code.

But can it be done in zero lines of code? Is there a non-microcontroller solution to this problem? I have one in mind, but it uses a bunch of discrete components.

Presenting electronics golf: solve this problem to minimise Σ(electronic components, lines of code)!
 

Online oPossum

  • Super Contributor
  • ***
  • Posts: 1472
  • Country: us
  • Very dangerous - may attack at any time
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #1 on: December 04, 2019, 03:44:01 am »
 

Offline I wanted a rude usernameTopic starter

  • Frequent Contributor
  • **
  • Posts: 662
  • Country: au
  • ... but this username is also acceptable.
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #2 on: December 04, 2019, 03:48:02 am »
Yeah, I have a hunch it can be done with fewer parts, but lack the electronics background to improve on that solution. Also it's an interesting exercise.
 

Offline ebclr

  • Super Contributor
  • ***
  • Posts: 2331
  • Country: 00
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #3 on: December 04, 2019, 08:04:09 am »
74HC14 1 capacitor, 2 resistors, 2 diodes, the pot is everything you need, to make a variable duty cycle oscillator,  who will drive the servo position
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #4 on: December 04, 2019, 09:41:20 am »
That's more complex (and has more pins to solder) than a CMOS 555 (so you can gamble on no decoupling) + a resistor , a capacitor, a pot and a diode.  Add an extra resistor in series with the pot to limit the minimum pulse width.

It can't really be simplified any further in the analog electronic domain - you need two RC time constants to set the timing so that's four components straight off, even if you cheat and use a mechanical stop for the pot knob to set the minimum pulse width.

An electromechanical solution could be simpler - imagine a tiny bimetallic strip with a heating element wrapped round it and a pair of NC contacts as a thermal oscillator controlled by a set-screw bending the base of the strip towards the fixed contact to increas the on time.  Tap off the output across the heating element.  :-DD
« Last Edit: December 04, 2019, 09:49:40 am by Ian.M »
 

Offline leeatljs

  • Contributor
  • Posts: 31
  • Country: gb
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #5 on: December 04, 2019, 10:26:29 am »
Are we allowed to modify the servo?
 

Offline Wolfram

  • Frequent Contributor
  • **
  • Posts: 414
  • Country: no
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #6 on: December 04, 2019, 11:48:43 am »
How about a relaxation oscillator built around a neon lamp? A variable resistor between the neon lamp and the capacitor would allow the pulse width to be adjusted. It might not win on the lowest overall part count, but it's hard to beat it on the number of active components!

If ICs count as one component, then an LT6992, a resistor and a potentiometer would do.
 
The following users thanked this post: I wanted a rude username

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #7 on: December 04, 2019, 02:14:16 pm »
I presume output would be across a 4.7V Zener in series with the lamp?
 

Offline dferyance

  • Regular Contributor
  • *
  • Posts: 202
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #8 on: December 04, 2019, 02:30:35 pm »
It sounds like the goal is to avoid code and not so much avoid micro-controllers. This might be possible with a PSoC via schematic entry. It has analog blocks and digital blocks that can be wired together.

Another possibility is a FPGA. If verilog or VHDL qualifies as code, it is still possible to do via schematic entry.

Not saying those are good solutions, but just solutions you shouldn't rule out in your quest to not have code.

To me it seems to defy the point to have 0 lines of code. The challenge is to optimize an algorithm to be as simple and small to solve a problem. You are going down the path of having no algorithm -- so you aren't optimizing anything. As soon as you go the route of no computation, you could introduce solutions such as a person manually turning a servo in response to a nob. Being outside the world of Turing computers is a totally different kind of problem to solve.
 

Offline Wolfram

  • Frequent Contributor
  • **
  • Posts: 414
  • Country: no
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #9 on: December 04, 2019, 03:10:11 pm »
I presume output would be across a 4.7V Zener in series with the lamp?

That's the simplest way to ensure solid logic levels on the output. I'd maybe add a resistor in parallel with the zener as well, to get a well defined logic low output value. Given that the output pulse length only needs to change by a factor of 2:1, it might be possible to skip the zener and take the output across a resistor in series with the lamp, depending on the valid logic input levels of the servo.
« Last Edit: December 04, 2019, 03:19:27 pm by Wolfram »
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15797
  • Country: fr
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #10 on: December 04, 2019, 03:23:32 pm »
Presenting electronics golf: solve this problem to minimise Σ(electronic components, lines of code)!

There's a slight contradiction between your title "without a microcontroller" and the last line "minimise Σ(electronic components, lines of code)".
I guess here, the goal is to do without an MCU, so no lines of code at all. (Or maybe you were thinking about a CPLD/FPGA?)

Any programmable component, such as an MCU or FPGA, may actually hide a lot of "lines of code" via libraries (/respectively ready-made IPs), so generally speaking, "code golf" contests have to be strictly defined, otherwise they don't mean much. You could be using a crapton of external libraries and make your own code only a 1-liner, is that a valid approach? Is the goal about designing something with the least amount of code/components overall, or is it about doing it with the least amount of effort? The two can be almost completely opposite and contradictory.

Anyway here, assuming 1/ you said NO MCU and 2/ you didn't say "only with discrete parts", one of the simplest solutions in terms of both design effort and number of parts would be to use, for instance, an LTC6992. It would only require 1 resistor to set the period, and it has a control input for the duty cycle. Then to do it "right" (design it such that the output pulse width is settable in the standard range for a servo, which is often 1ms to 2ms, with 1.5ms being neutral), you'd need two additional resistors (at each end of the pot), along with the pot. Then pot wiper to the MOD input. Add a decoupling cap for good measure on the power supply. That's 1 IC, 3 resistors, 1 cap, zero code or configuration, and you'll get something relatively stable.
« Last Edit: December 04, 2019, 03:25:29 pm by SiliconWizard »
 

Offline m98

  • Frequent Contributor
  • **
  • Posts: 634
  • Country: de
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #11 on: December 04, 2019, 04:23:55 pm »
Another solution: One GreenPAK
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15797
  • Country: fr
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #12 on: December 04, 2019, 05:27:08 pm »
Another solution: One GreenPAK

Nice devices. But they are "programmable", aren't they? So requiring some "lines" of "code". Or I don't know exactly how you configure them.

Which raises the question: if we want to minimize both part count AND "lines of code", how are we going to "normalize" both measures?
If one solution requires 5 components but zero line of code, is it better or worse than one requiring only 1 component and using 5, 10, 100 lines of code? How can we compare hardware and "software"?
 

Offline Etesla

  • Regular Contributor
  • *
  • Posts: 154
  • Country: us
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #13 on: December 04, 2019, 05:35:52 pm »
Here's one solution:
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 21226
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #14 on: December 04, 2019, 05:39:37 pm »
Using a microcontroller to read a potentiometer and PWM a servo accordingly is a favourite Arduino task, and can probably be done in a few lines of code.

But can it be done in zero lines of code? Is there a non-microcontroller solution to this problem? I have one in mind, but it uses a bunch of discrete components.

How do you think servos were controlled when computers were the size of rooms and cost 1000 times your annual salary?

It does require a basic understanding of analogue electronics, control theory, particularly PID loops and backlash - but that's equally true for a software control loop.

Alternatively look at and understand the concepts in analogue computers.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22436
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #15 on: December 04, 2019, 06:06:47 pm »
No need for an oscillating solution.  A couple transistors and their supporting resistors (and maybe an R+C or two for compensation) will do it.  Mechanical setup, probably a pot on the servo shaft to indicate position, and the error amp controls the servo to match input voltage to position.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline m98

  • Frequent Contributor
  • **
  • Posts: 634
  • Country: de
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #16 on: December 04, 2019, 06:40:27 pm »
Another solution: One GreenPAK
Nice devices. But they are "programmable", aren't they? So requiring some "lines" of "code". Or I don't know exactly how you configure them.
They have a schematic entry tool, so no "lines of code" required. In fact, as far as I know, that's the only official way to configure them.
But this boils down to the question if programmable hardware is permitted by the rules the OP had in mind, really.
One could even make the case that a PCB created by a CAD-tool contains "code", since it is stored in markup language and "programmed" in the manufacturing process.
 

Offline m98

  • Frequent Contributor
  • **
  • Posts: 634
  • Country: de
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #17 on: December 04, 2019, 06:45:38 pm »
No need for an oscillating solution.
There is, unless re-specifying the used servo was allowed. In that case, he could simply use one that takes analog input off-the-shelf...
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 6420
  • Country: de
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #18 on: December 04, 2019, 07:49:02 pm »
No need for an oscillating solution.  A couple transistors and their supporting resistors (and maybe an R+C or two for compensation) will do it. 

My reading of the OP is that he's talking about RC servos.

These need a 0...4.8 V input amplitude, 20 ms period, 1...2 ms pulse input; 1.5 ms being neutral position. I don't see a solution without an oscillator.

 

Offline I wanted a rude usernameTopic starter

  • Frequent Contributor
  • **
  • Posts: 662
  • Country: au
  • ... but this username is also acceptable.
Re: Control a servo from a potentiometer, WITHOUT a microcontroller?
« Reply #19 on: December 04, 2019, 09:04:57 pm »
What have I started?  :o

It's best if the set of rules emerges organically. If you want clarification, then personally I would make the number of components/lines of code follow the complexity of the solution in some way.

Programmable devices like FPGAs and PLCs may need to count as having some number of "function points", even if they're programmed via a 4GL, Node-RED style Web interface, etc. ... otherwise of course you could build pretty much any solution in an FPGA and hope the decoupling caps don't push you over someone else's solution.

Existing libraries are OK, because they're just other building block. But the library should exist publicly when the challenge is put forward ... no MyLibrary.solveTheProblem();D

Anyway, those are just suggested rules. And yes, I was thinking of a generic, unmodified PWM servo, but it's also fun to consider hacking it.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf