Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: Flying Robots on March 07, 2013, 10:55:05 AM

Title: How can I drive a digital potentiometer with a hobby RC receiver servo signal?
Post by: Flying Robots on March 07, 2013, 10:55:05 AM
Good day to all,
I have a need to combine a hobby RC receiver with a digital potentiometer using the 1ms-2ms PWM servo signal. I would also need to set the wiper resistance range (to be determined). My need for the output of the digital pot (in conjunction with a mechanical pot and a JFET) is to drive an LM555 timer which in turn will be used to adjust the servo position of a servo that is normally controlled by one of the other servo channels. (i.e. three variables will be used to correct  the servo position independent of the operator.) As a second part to the project, I will also need to remotely turn the system OFF with a PWM signal of 1ms or less and turn it ON when the signal is over 1ms.

That’s my project in a nut shell. I was hoping to complete this project with a discrete system rather than getting involved with programming a micro controller; which is way out of my league as if this is not. If there is a better approach I will be open to it. After poring over data sheets and everything I can find on the internet, I haven’t found the recipe I think I need. Any help would be greatly appreciated.

Thanks for reading.
Some like their robots to roll, I like mine to fly!
Title: Re: How can I drive a digital potentiometer with a hobby RC receiver servo signal?
Post by: jwatte on March 07, 2013, 11:22:02 AM
A digital potentiometer uses a digital signal like a I2C or SPI bus to set its value. There is also a kind that has "step up" and "step down" signals. If you seriously want to do this without a microcontroller, then you'd have to build something like a phase-locked loop that ran on the current value of the potentiometer, and gated a high-frequency clock to generate step-up/down signals based on the phase difference between the incoming PWM and your PLL.

DON'T DO THAT!

It sounds like the problem you really have is this:
1) In comes a hobby servo PWM.
2) You want to control another PWM-controlled entity with a PWM that's some function of 1) but not a clone.

That could be done in an hour using an ATTiny85, which is a 8-pin AVR microcontroller for about a buck. Yes, it's the same size as a single 555 circuit, but it's a lot more powerful! It doesn't even need any clocks; it can run at 1 MHz or 8 MHz on a built-in resonator. I recommend using the 8 MHz clock.

Get a $20 AVR programmer, get yourself setup with avr-gcc and avr-libc, and write a small program for it; it would be a lot easier than trying to do this in discrete electronics. The program would do something like:

- poll for the incoming PWM to go high
- measure the duration of the incoming PWM pulse (use a high-frequency high-resolution timer -- I think there's a 16-bit timer in the tiny85)
- run whatever function you want on the PWM pulse width -- stretch it, invert it, scale it, whatever
- generate the output pulse you need by setting output pin high, waiting for the appropriate amount of time (timer again) and setting the output pin low
- go back to beginning

The delay between input and output would be the width of the incoming pulse plus a few microseconds for whatever math you're doing. The code could run entirely in polled mode; no interrupts or anything fancy needed.