I'm working on an ROV "Submarine" controlled by two Arduinos, an UNO on the surface and a Nano in the ROV communicating via RS485. Power is 12V to both the UNO and, via the umbilical, to the ROV.
The problem I have is that the Nano and the ESCs in the ROV initialise OK and appear to initially work. However, after a short period and usually after running one or other of the motors, two of the ESC/Motors start beeping that they have lost connection to their receiver (the Nano).
I'm stretching the Nano a little as there are 4 ESCs/Brushless motors using PWM pins 3, 5, 6 & 9 plus an H-Bridge with two brushed motors on PWM pins 10 & 11.
It's always the two ESC's on pins 3 & 5 which go offline. Fitting an LED to the PWM pins gives a dim glow when the motor throttle is 0 and glows brighter at 180 but, when pins 3 & 5 go offline the LED is off completely so something is completely disabling the PWM signal.
Details:
The ESC's are all unbranded ones but I believe 3/4 are ICQUANZX 30A devices and have been calibrated as they seem to adhere to the documentation (see attached). The 4th, which has different coloured PWM connection wires, I have not figured how to calibrate although it reacts as if it doesn't need calibrating.
ROV Circuit diagram is also attached below - Everything is powered via the umbilical and powers on at the same time. One of the ESCs BEC powers the Nano. The Nano waits 10s before sending anything to the motors. I can provide the UNO circuit too if needed.
On power on all the motors beep correctly (see attached doc) and only after one or more motors is used do the 2 ESCs go offline.
Even with 2 offline, the other two ESCs and the H-Bridge motors continue to work fine.
Communications works but is not as smooth as I would like. I had to introduce delays to get the ROV to successfully acknowledge "packet" receipt so the Master knows it's online. I tried both delay() and using millis() for those delays to eliminate any issues with timers.
Oddly it's always pins 3 & 5 which stop. These use different timers, 2 & 0 respectively so I can't see it's the timers getting corrupted. Besides which, the other pins continue to work.
I've done loads of PD to try and figure this out. It's not the ESCs as the problem remains on pins 3 & 5 if I swap them. I don't think it's power related as the problem occurs even on a short, test umbilical.
Any suggestions for further PD and/or any code improvements would be much appreciated.
I can only guess but I would start by being sure the grounds are solid and not lifting as you operate. Also be sure the power is stable at the end of the umbilical cord. Have you tried swapping ESCs and see if the problem remains or follows.
Thanks for the response.
I'm pretty sure all the ground connections are good. I remade all the ESC power connections yesterday. I also bypassed the umbilical with a 1m power cable to eliminate voltage drop - about 1V - but still had the same result. Swapping ESC 3 for 1 or 2 still gives the same result, the problem stays with the pins.
It doesn't make sense to me why only PWM pins 3 and 5 stop. If it was a main power issue then 6, 9, 10 & 11 would probably see this too.
I've double checked all my connections but, given that it actually can work for a short period, I think it's either software related or I've gone beyond what the Nano can handle.
I don't see how the code you posted works at all. You're using analogWrite to pin 10 on motorA but the Servo library disables analogWrite on pins 9 and 10.
Talk about not seeing the wood for the trees! I hadn't spotted that although motors A and B on 10/11 definitely still work after PWM on pins 3 and 5 stop. Having said that, it sounds lile it must be related. I will test by commenting out motors A and B and see what happens.
The external PWM driver via I2C is looking more likely as a good solution.
Update: I commented out statements related to pins 10 & 11 (so pinmode and analogWrite) and tried again but the two ESCs on pins 3 & 5 still go offline. To be sure I disconnected the H-Bridge from pins 10 & 11 too.
It's pretty consistent now with 3 & 5 going "offline" exactly as the main loop starts - as if an invalid value is being sent to them but this shouldn't happen. Looking at the Servo code it bound checks values 0-180 too.
Update: I have now implemented the PWM card (PCA9685) and it works perfectly. Took me a while to work out what values to send to it but got there in the end. I could still probably simplify the code a little and the RS485 timing isn't great but it works enough to do what I need for the moment. Updated schematic and code files attached in case anyone is interested.
I never did figure out why pins 3 & 5 went offline. If anyone has any ideas then feel free to post but I'm happy to close this as "problem bypassed"
5volt on the V-in pin of a Nano can't be good.
The V-in pin needs 7-9volt.
Better connect that 5volt of the motor driver directly to the 5volt pin of the Nano.
Leo..
Thanks for the suggestion - I've swapped to the PCA9685 card and supply 7V via a buck converter to the Vin pin now so can't re-test. The new configuration works fine. If that was the problem then strange it consistently affected just the 2 pins and everything else worked ok?