PWM output distance

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My question is, for the megaAVR family or microcontrollers, how far can you reliably send a PWM signal? I mean over physical distance. I have a use case where I need to connect a microcontroller to a servo that might be more than 3+ meters away. Would this work? Would I need to use some type of signal relay along the way if the signal is not strong enough?

This topic has a solution.
Last Edited: Tue. May 4, 2021 - 06:23 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I actually just found this post:

https://www.avrfreaks.net/forum/...

 

Sorry for the repeat question!

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Depends almost entirely (at edge speeds slow enough that transmission line effects are not important) on the PWM repetition frequency, the pin output drive capability, and the line capacitance.

 

Suppose that T is the smaller of the minimum PWM on time and PWM off time.

 

Then you need to charge and discharge the cable capacitance in a time that is shorter than T. Just for discussion, lets assume this is T/4.

 

For standard AVRs. pin outputs appear to have around 80-100 Ohm source resistance. Newer XMega devices may be a little different. 

 

For a simple RC circuit, which is the model I am suggesting here, the rise time is 2.2 * R * C. 

 

So, lets suppose that the smallest on or off time is 100us. Then we need a rise time that is no slower than 100us/4 = 25us. If we take the port output resistance as 100 ohms, then the highest cable capacitance is 25us/(2.2*R) = 25us/220Ohms = 0.113uF = 113nF.

 

That is a LOT of capacitance. Few cables will have more than a few hundred pF per meter.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

in #2, testdrone wrote:
I actually just found this post

and did that answer your question?

 

If so, mark #2 as the solution ...

 

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your response. 

 

It seems that in this situation the best solution is to transmit the pwm signal digitally, and reassemble it on the other side

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If your goal is analog at the far end, then RC filter it at the source and send the analog down the cable. Then, you will have almost no cable limitation so long as the load resistance is large compared to the copper resistance of the cable. In fact, cable capacitance will just add a little to the filter capacitance you need, anyway. Then, the fact that it is a PWM source is not even relevant.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

Last Edited: Tue. May 4, 2021 - 07:40 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How many meters?  How much edge deviation can you tolerate (how much servo wiggle is acceptable)?  1us?   10ns?  10us? 

 

You can prob use something like a mosfet gate driver (or just a totem pole dual transistor), to give it some "punch"

https://www.ti.com/lit/ds/symlin...

 

It seems that in this situation the best solution is to transmit the pwm signal digitally, and reassemble it on the other side

what does that mean, if anything?...you are sending it digitally 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So my thought would be to convert the PWM signal to a numeric value, send it over some connection, such UART or even wifi, and convert it back to PWM output on the other side.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Forgive me, I have limited knowledge of EE, but what you are saying is to convert the signal to a flat voltage, then send that voltage down over the cable, then on the other side use ADC to read it in and convert it back to a PWM value to output it?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your comments in

 

testdrone wrote:
transmit the pwm signal digitally, and reassemble it on the other side

 

led me to think that the goal was NOT to deliver PWM to the far end, because PWM >>IS<< digital!

 

Serial data is probably a loosing proposition. If you need PWM at the far end, then send PWM and be done with it. If you need analog (e.g. "DC"), send analog. 

 

For the likely PWM clock rates, a normal AVR output port pin and normal cable will be just fine at 3 meters. Just don't use a higher clock frequency on the PWM than you really need to.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why not forget PWM & try some serial servo:

 

https://hackaday.com/2018/07/05/...

 

Of course you should be able to add a 15 cent buffer (if even needed) & send your PWM down the wire.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Serial servo is very cool! First I have heard about them, but unfortunately they seem to all come from China, which isnt bad in and of itself, but the method of communicating with them does not seem to be open source and you have to use their proprietary board, at least for the economy level. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

testdrone wrote:
but the method of communicating with them does not seem to be open source
Eh? I picked the first one on the list. Followed the links and arrived at:

 

https://emanual.robotis.com/docs...

 

Surely that fully documents the command packets you need to send to control the thing? How much more "open source" do you want this to be exactly?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

testdrone wrote:

It seems that in this situation the best solution is to transmit the pwm signal digitally, and reassemble it on the other side

 

That's overly complicated. Either use something like a TC4427 driver at the send end (as suggested above) or, as an off-the-wall suggestion, use an RS485 driver/receiver to drive a twisted pair cable.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."