Output PWM without sending a large current

I'm trying to send a PWM signal from one Nano to another Nano, and am running into the problem of the receiving Nano locking up if it is powered up after the sending Nano, instead of before.

In troubleshooting I found that when the sending Nano is powered up but the receiving Nano isn't, the receiving Nano LED's are lighting up due to the PWM signal coming from the sending Nano. I hooked up a servo tester to the non-powered receiving Nano and its LED's did not light up due to the signal coming from the servo tester. So I am trying to figure out the proper way to send a PWM signal that is not sending a current strong enough to light the non-powered Nano LED's. This situation seems to be what causes the receiving Nano to lock up if not powered up first.

I've tried analogWrite, the Servo library and bit-banging the signal. They all send enough of a current to light up the receiving Nano LED's. I haven't tried using the timers/registers directly and before going down that path I am wondering if that will even solve the issue.

Put a current limiting resistor in series with the output. It will limit the bandwidth, so your PWM can't be really fast. You didn't give any details of that, so I'm giving you a very generic answer, I'm afraid.

If you're wondering the reason why it happens, the powered down unit is receiving power through the input protection diodes inside the chip.

Why on earth are you using PWM to communicate between processors?

That’s helpful, thank you. I’m trying to simulate communicating with a 328p embedded on a PCB with easy connectivity only to a few pins (none of which are serial comm pins). With only one or two pins available I was thinking using PWM would be a solution.

This is called parasitic powering and a great and is a great way of destroying devices.
The best way to connect to a device that might not be powered all the time is to use an optical isolator to join them together.

Another approach than opto-isolation is to use an open-collector output and a pull-up resistor at the receiving end. However its rare to find a microcontroller that can do open-collector PWM in hardware.

A diode can be added in the connection to turn a push-pull output into the equivalent of open-collector:

sending pin ----- cathode, anode----receiving pin (in INPUT_PULLUP mode).

Use software serial!

Perhaps the most important question here is why your project needs, or you think it needs, 2 Arduino. Using more than one Arduino, or believing it is necessary, in a project, is a trap many beginners fall into.

All the proposed solutions (which are good ones), still limit bandwidth, compared with a direct pin connection. I mentioned it but you were silent about that in your reply. So it would be a good idea to explain what data rate you require between the two devices.

Hi, @birdtrick

What is your overall project?

Thanks..Tom.. :grinning: :+1: :coffee: :australia:

The 328p is part of a homemade ESC so it is expecting PWM (I forgot to mention that). Also, the sending nano will eventually control up to 5 of these homemade ESC's so I currently see the need to send out 5 PWM signals. I am clueless on the data rate needed for such a thing :slightly_smiling_face:

So, the PWM signal sent by the "master" Arduino is a servo-style PWM signal (50Hz, 1-2ms pulses). The Arduino acting as an ESC reads that and generates a high-frequency PWM with 0-100% duty cycle to control the motor driver circuit?

This is the kind of thing it would have been helpful to have included in your first post.

Is the "master" Arduino just for testing purposes at this stage, to be replaced by an RC receiver later?

Sorry about that..

Correct on the PWM control. I won’t be using a receiver and need to control up to 5 of the ESC’s from one Nano.

The servo tester did not cause the issue with its PWM signal. Curious as to why.

So this whole thing is an "X-Y" problem.

Please, stop asking about problem Y and tell us about problem X. What are you trying to do?

Hi,

The forum should be part to blame, we should have shot you this link.

Please read the post at the start of any forum , entitled "How to use this Forum".

This will help with advice on how to present your code and problems.

Tom... :grinning: :+1: :coffee: :australia:

The problem seems clear to me but I guess I’m explaining it wrong. Let me try again:

I need to control 5 esc’s with one Nano. The esc’s need PWM signals. If the Nano is powered up before the esc’s, then the esc’s lock up. Testing has shown that the led on the esc board (with 328p processor) lights up when the sending Nano is powered, even though the esc is not powered. I then used a servo tester in place of the Nano, and this problem doesn’t occur.

So I guess my questions should be:

Why doesn’t the servo tester light up the led on the esc board (and lock it up)?

What method of PWM is being sent from the tester that makes it different?

Should I be trying direct timers/registers instead of analogWrite, bit-banging, or servo library methods of sending a PWM signal?

I apologize I didn’t explain all of this in my first post but a lot of it seemed like extra information that wasn’t needed.

Thanks for everyones’ help.

Hi,
Do you have some sample code that you load on the Nano that causes this problem.
We need to see what the Nano output is compared to the Servo tester.

Can you post link to tester or an image of it please.

Thanks.. Tom... :grinning: :+1: :coffee: :australia:
PS, You may need to set the Servo outputs to LOW and after an initialisation time attach() the servo function.

Sure. Here is method #1:

int esc1, esc2, esc3, esc4;

void setup() {

DDRD |= B11111100;   // pins 2,3,4,5,6,7 set as output

}

void loop() {
   
    esc1 = 1230; 
    PORTD |= B00000100;     // pin 2 high                                             
    delayMicroseconds(esc1); 
    PORTD &= B11111011;     // pin 2 low                                        

    esc2 = 1340; 
    PORTD |= B00001000;                                                  
    delayMicroseconds(esc2); 
    PORTD &= B11110111;                                             

    esc3 = 1550; 
    PORTD |= B00010000;                                                  
    delayMicroseconds(esc3); 
    PORTD &= B11101111;                                             

    esc4 = 1830; 
    PORTD |= B00100000;                                                  
    delayMicroseconds(esc4); 
    PORTD &= B11011111;         

}                                    
 

.. and the servo library code I tested:

#include <Servo.h> 

Servo myservo;

void setup() 
{ 
  myservo.attach(9);
  myservo.writeMicroseconds(1500);  // set servo to mid-point
} 

void loop() {} 

This servo tester: https://www.aliexpress.com/item/32994116680.html?spm=a2g0o.productlist.0.0.fd62cc94RNxB98&algo_pvid=0c1f94cd-e31d-4db6-a573-bd58aa648788&algo_exp_id=0c1f94cd-e31d-4db6-a573-bd58aa648788-50&pdp_ext_f={"sku_id"%3A"12000021943687016"}

Hi,
Will there be a case where the Nano is powered up before the ESCs?

If all your project runs off the same powersupply, when you switch ON, do you get lockup?

Try in your Servo library code putting the ;

myservo.writeMicroseconds(1500); 

In the void loop(), so it keeps running.
Also try a delay before the attach statement to give the ESC time to enable/boot.

Just some suggestions.

Try using a current limit resistor as suggested by @anon57585045 in post #2.

Tom... :grinning: :+1: :coffee: :australia:

I just gave that a try with no luck.

The problem is sometimes another esc will be powered up while there are some already operating.

I will try the current limit resister next.

Hi,

Not sure what you mean, don't you power them ALL up at the same time?

Tom... :grinning: :+1: :coffee: :australia:

No, the nature of this thing is that different esc's get swapped in at various times.