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).
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.
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
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?
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.
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...
PS, You may need to set the Servo outputs to LOW and after an initialisation time attach() the servo function.