Digital signal to PWM integrated circuit?

Thread Starter

hspalm

Joined Feb 17, 2010
201
Hi all,
Have any of you heard of a IC that converts a (in example) 4-bit digital signal to PWM signal? Where 0xFF equals to 100% and 0x00 equals to 0% width?

Preferably I would like something that converts from 4-bit digital to PWM width 1ms to 2ms for RC servo controlling. I am trying to control a robot arm with 6 servos, and my microcontroller lacks several clocks for this operation...

Any alternative suggestions are welcome, of course!
 

beenthere

Joined Apr 20, 2004
15,819
Something like a microprocessor would do that - with appropriate programming.

my microcontroller lacks several clocks for this operation
If the uC clock can't be divided down, there are CMOS and TTL oscillators available for timing.
 

SgtWookie

Joined Jul 17, 2007
22,230
Hi all,
<snip> 4-bit digital signal to PWM signal? Where 0xFF equals to 100% and 0x00 equals to 0% width?
Ahhh, 0xFF is an 8 bit value; 1111 1111.
0xF would be a 4-bit value; 1111.

You'd need to figure out how precise you need to control the PWM.

Preferably I would like something that converts from 4-bit digital to PWM width 1ms to 2ms for RC servo controlling. I am trying to control a robot arm with 6 servos, and my microcontroller lacks several clocks for this operation...

Any alternative suggestions are welcome, of course!
Is the total range from 1mS to 2mS, or what is the base PRT requirement?
(PRT=Pulse Repetition Time = 1/Frequency)
 

rjenkins

Joined Nov 6, 2005
1,013
Do you have a single on-chip PWM or timer that you can use to generate a single servo pulse?

If you do, add a 4017 to 'step' the output and you can control several servos with just a couple of pins for clock and reset.

Each channel output is equal to the time from one positive edge to the next on the clock line, when you have done all channels pulse the reset and start again.

Don't use output zero, as that will be active from reset. Start with 1 and work up.

4017 Datasheet:
http://www.datasheetcatalog.org/datasheets/320/499984_DS.pdf
 

Thread Starter

hspalm

Joined Feb 17, 2010
201
Something like a microprocessor would do that - with appropriate programming.

If the uC clock can't be divided down, there are CMOS and TTL oscillators available for timing.
The uC clock can be divided down, what I meant was it didn't have enough timers. Microprosessors, thats VHDL programming, right? I know just a little bit Xilinx architecture, but not much...

Ahhh, 0xFF is an 8 bit value; 1111 1111.
0xF would be a 4-bit value; 1111.
Whoops.

You'd need to figure out how precise you need to control the PWM.



Is the total range from 1mS to 2mS, or what is the base PRT requirement?
(PRT=Pulse Repetition Time = 1/Frequency)
PRT could be around 20ms, as this is what normal RC receivers work on, but I think I could easily double it as my servo arms won't travel that far in 40ms.

Do you have a single on-chip PWM or timer that you can use to generate a single servo pulse?

If you do, add a 4017 to 'step' the output and you can control several servos with just a couple of pins for clock and reset.

Each channel output is equal to the time from one positive edge to the next on the clock line, when you have done all channels pulse the reset and start again.

Don't use output zero, as that will be active from reset. Start with 1 and work up.

4017 Datasheet:
http://www.datasheetcatalog.org/datasheets/320/499984_DS.pdf
Hmm, I see how this will divide the frequency by 10, and every in between. I don't see how I can use this to control several servos independently, this is what you meant? Am I using one 4017 per each servo?
 

Bernard

Joined Aug 7, 2008
5,784
Does each servo have its own 4 bit register? Is this operation RC or hard wired? Is the attached timing diagram any where close to your needs? If this is to modulate an 8 ch transmitter, you need 8 ckts.
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
Nice idea, Robert! Our OP saves a lot of pins that way.

hspalm,

No, one 4017 could control up to 9 servos.

Q1 to servo 1, Q2 to servo 2, etc.

1) Reset the 4017. Q0, the first output, goes high, all others are low. Leave Q0 disconnected.

2) Clock the 4017. Q0 turns off, Q1 turns on.

3) Delay in a loop for however many instructions it takes to give servo 1 it's high signal.

4) Clock the 4017. Q1 turns off, Q2 turns on.

5) Repeat steps 3 and 4 for however many servos you are controlling.

6) Loop back to step 1.
 

Thread Starter

hspalm

Joined Feb 17, 2010
201
Does each servo have its own 4 bit register? Is this operation RC or hard wired? Is the attached timing diagram any where close to your needs? If this is to modulate an 8 ch transmitter, you need 8 ckts.
The attached timing diagram is exactly what I was thinking, great drawn. What does it mean to modulate an 8 channel transmitter? To make something to replace it? These are "RC" servos, as the ones used in radio controlled cars. They are not standalone radio controlled, and are wired with the standard yellow(signal) red(power) black(ground). My idea was

[I/O interface] -> [uC] -> [Converter (4017?)] -> [Servo motors]

They are not to be radio controlled (they actually are right now, with a standard RC 6ch Tx/Rx, I'll try to post a video later).

Nice idea, Robert! Our OP saves a lot of pins that way.

hspalm,

No, one 4017 could control up to 9 servos.

Q1 to servo 1, Q2 to servo 2, etc.

1) Reset the 4017. Q0, the first output, goes high, all others are low. Leave Q0 disconnected.

2) Clock the 4017. Q0 turns off, Q1 turns on.

3) Delay in a loop for however many instructions it takes to give servo 1 it's high signal.

4) Clock the 4017. Q1 turns off, Q2 turns on.

5) Repeat steps 3 and 4 for however many servos you are controlling.

6) Loop back to step 1.
Ah, great! Thats a brilliant idea, actually. So if I have gotten this right, and I need a PRT=20ms, then I have to clock this this 4017 six times (six servo motors) in under 20ms? This means I can connect 10 servos to one 4017 running at 100% 2ms pulse with and still meet the max 50hz requirements.

loop
{
clock 4017
delay "servo1time"
clock 4017
delay "servo2time"
clock 4017
delay "servo3time"
clock 4017
delay "servo4time"
clock 4017
delay "servo5time"
clock 4017
delay "servo6time"
reset 4017
}

Like this then?
 

SgtWookie

Joined Jul 17, 2007
22,230
OK, one thing I forgot - you will need to keep track of the total time wasted for all of the servos, and make sure that if it's less than 20mS, that you waste the remaining time at the end so you keep everything in sync.

Otherwise, your PRT will be all over the place.
 

SgtWookie

Joined Jul 17, 2007
22,230
No, you can't go to 10 servos; 9 is the limit with one 4017.

You need one unused output (preferably Q0) for the "time waster" output. Otherwise, if any of your servos have less than a 2mS PW out (which will be most of them), you will have to make up that time somewhere to get the 20mS PRT.
Example:
1.2mS for Servo 1
0.8mS for Servo 2
1.0mS for Servo 3
1.9mS for Servo 4
...
0.7mS for Servo 9
-------
7.8mS used (including those not shown)
20mS for PRT
12.2mS more to be wasted to make up the 20mS prt.
 

Thread Starter

hspalm

Joined Feb 17, 2010
201
Okay, I think I get what you're saying. I don't think the PRT is that crucial, really. I don't know if it can be too low for the servo electronics to clearly read it, but as long as it's not to high so the refresh rate is so slow the servo will studder...

Many thanks for all your help guys, I appreciate it.
 

Bernard

Joined Aug 7, 2008
5,784
Back to origional question of converting 4 bit # to PWM other than μC, here is an outline of an option: The 4 bit data is loaded into a register, in this case an UP/ Down parallel load counter. Z1 is the 20ms time base, a 555 or 1/9 of a 4017 output with a 1kpps clock. At the end of each 1ms pulse FF Z4 is set, adding its time to the 1ms P & enabling 555 fast clock, Z6, 16kpps. Counter, Z7 counts down to oooo, giving a borrow,-, output, which then resets FF. Each count adds 62.5 μs to to the PWM output. Z8 is to take care of possibly no count in counter. One ckt per servo.
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
Bernard,
Very nice. I thought of other similarly complicated options.

However, since our OP is using a uC, they can easily fix things via software.

Their main problem is how to address so many servos, with so few pins?

John gave a very slick solution. Just one IC to effectively add more pins to the uC, and a bit of software coding. It doesn't get much better than that.

Hspalm, you wrote:
Okay, I think I get what you're saying. I don't think the PRT is that crucial, really. I don't know if it can be too low for the servo electronics to clearly read it, but as long as it's not to high so the refresh rate is so slow the servo will studder...
Seriously, plan on keeping track of the unused mS beforehand, because if you don't, you will likely wind up with problems.

Interrupts will help you, if you know how to use them.
 

Thread Starter

hspalm

Joined Feb 17, 2010
201
Bernard, that is a good idea, and I really appreciate you making a real effort to help me out with my problem. I cannot see how solutions like this could just pop out of someones head right after being presented with the problem. But as Sgt.Wookie says, i already have a microcontroller that obviously can handle up to 9 servos just by one single i/o line. Both ideas are great, and thank you.

Sgt.Wookie,
Do you mean like connecting Q9 of 4017 to pin-change interrupt line, and delaying for the remaining time when interrupt occurs?
 

SgtWookie

Joined Jul 17, 2007
22,230
Sgt.Wookie,
Do you mean like connecting Q9 of 4017 to pin-change interrupt line, and delaying for the remaining time when interrupt occurs?
Nope. I mean load up a timer with the delay you want, and then enable interrupts. Your program can then go about it's business elsewhere.

When the interrupt occurs, you clock the 4017, and load the next delay time into the timer.

Of course, you still need to keep track of the total of the delays, subtracting that from 20mS - and finish out the 20mS with the 4017 reset (output Q0 high, which is not connected to any servo)
 
Top