Good day,
Spending my isolation making an RC Boat from almost scratch. 3D printed the hull...good times. I'm 90% done and can't get the servo to behave with the dc motor.
I'm using two NRF2401L Trancievers as the TX and RX to transmit throttle and rudder control. I am able to control the motor independently from the servo and vice versa. I am NOT able to control them both at the same time. When I power on the main switch, the servo begins to act randomly and I have no control. I still have control of the motors through out.
I know that PWM on pins 9 and 10 are disabled by Servo.h, so the motor control signal is off of Pin3. The Servo control is on a digital pin. The ucontroller is a Pro Mini 5v.
Any thoughts and advice is greatly appreciated. I'm of an age where my hair is less likely to grow back when I tear it out. 
Please see attached photo of the overall circuit.
The Receiver code is as follows:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>
Servo rudder;
RF24 radio(7, 8);
const byte address[6] = "00001";
const bool debug = false;
const int motorPin = 3;
const int rudderPin = 9;
struct tx_packet {
volatile int speed_order;
volatile int turn_order;
};
tx_packet packet = {0, 0};
void setup() {
if(debug)
Serial.begin(9600);
rudder.attach(rudderPin);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.startListening();
}
void loop() {
radio.read(&packet, sizeof(packet));
if(debug){
Serial.print("speed order:");
Serial.println(packet.speed_order);
Serial.print("turn:");
Serial.println(packet.turn_order);
}
rudder.write(packet.turn_order);
analogWrite(motorPin, packet.speed_order);
}
Turn debug on.
Get back to us with the output.
Please remember to use code tags when posting code
What type of 9V battery? What servo are you using that is specified to work on 9V?
Steve
9V to a mini servo can't be good for it.
http://www.ee.ic.ac.uk/pcheung/teaching/DE1_EE/stores/sg90_datasheet.pdf
NRF24 units work much happier when you use the power adaptor unit.
Do you have specs for the main motors? Is that the complete circuit diagram with all the components?
Firstly, regarding the Servo and 9v battery. I forgot to add the SP7805 regulator in the drawing. It comes directly off of the 9v battery so the servo gets 5v clean. The 9v battery is a standard rectagular one.
I never thought to look at the debug while the servo is freaking out. I keep thinking it's going to burn something out.
When run thru the FTDI loader, it shows that the proper rudder and throttle orders are making it from TXer to RXer.
The servo is a Tower Pro 9g el cheapo. The motors are Traxxas Stinger 20T.
I do have some NRF regulators. I will put on in the boat.
Ill have to add some code for it to serial print while operational. brb
I ran the debug while it was running and the speed and turn orders are making it through fine:
speed order:31
turn:40
speed order:31
turn:40
A clue I noticed. At first glance, the servo seemed to behaving randomly. However, the output shows that a speed order of 1 creeps in there every 1/4 sec - 1/2 sec. It is during this phantom 1 speed order that the servo jerks.
speed order:0
turn:0
speed order:0
turn:0
speed order:1
turn:0
speed order:0
turn:0
speed order:0
Also, it always jerks to the same direction CW hard over.
One more clue, when I give an actual speed order and the motors spin up, the servo goes hard over CW and is non-responsive.
So, we have some clues here. Thoughts?
UPDATE: I put one of those NRF regulators on the RXer and there was no change. I will include on on the TXer next. Also, I moved the ground of the 9v to the 11.1V -'ve instead of the regulator ground as shown in the schematic. Unfortunately, no change.
I'm going to borrow a friends oscope tomorrow and take a look at a few different signals in realtime. ill report the findings tomorrow.
Smoke alarm type 9v battery will never run a servo.
Hi,
Ops schematic
Why is the capacitor circled, only 6.3V?
It should be at least 16V, 3 x Lipo = 3 * 4.2 = 12.6V
Have you got bypass capacitors on the input and output of the 5V regulator that you haven't put in the diagram/
Can you redraw your circuit with ALL components in it and pin labels on the controller and SPI connections?
Thanks.. Tom.. 
uC output to base of TIP102 require current limit resistors.
Parallel base connections not good either.
Use logic level mosfets like IRL540 or similar in the ground leg of the motors.
Why freewheeling caps and diodes?
Could use a few lessons in correct circuit drawing procedures.
Looks like most of the issues I saw has been addressed.
Please do not use a PNP symbol to draw an NPN darlingtons. Try to keep power on top and ground on bottom when drawing circuit. I appreciate that you did draw one as it helps to diagnose circuit issues.
The Darlington will self limit base current to about 30-35mA but 2x that is too much. I’m surprised you haven’t burnt out the pin.
Darlingtons are too slow for PWM, I would go with bluejets recommendation of using MOSFETs... or
Those 20T can put out some decent power and you might want to control 2 ESCs with your Arduino PWM, the ESCs have all the switching, filtering and other needs designed to work correctly while being able to pass much higher current.
Ok, I tore the wiring out of the boat to start fresh.
-
Took some schematic drawing lessons. See attached (@bluejets)
-
Changed the TIP102's to FQP30N06L MOSFETs (@bluejets)
-
Added a single 20 ohm bias resistor in parallel with the gates of the MOSFETs.(@wolframore) Question regarding this setup. What kind of current do the two FETs draw? 5v/20ohm=250mA x2? Am I drawing 500mA from the ucontroller? If correct, that seems excessive.
-
Increased the cap at the vreg to 10v @ 3300uF. The boat was originally designed for 7.4 volts @ four cells. I noticed that the YwRobot regulator has a min VCC of 6.5v, so I changed it to 11.1v A 3 cells instead.
-
The caps and diodes on the motor to help dissipate back emf from the motors. I might have it setup wrong. I'll admit that I don't fully understand how they help address the back EMF. I read that they are needed. I also read that perhaps a different type of diode should be used. Clarification would be appreciated. (@bluejets)
Before I put things back together, I'd like to make changes now. Any recommendations with the current design?
Lastly, the YwRobot regulator uses two AMS1117 regulators which are each rated for 1A (YwRobot data sheet states 750mA), so I have 2 regulated supplies. The SG90 servo has a stall current of 360mA. Assuming that is the max current it would draw, could I supply the YwRobot regulator with a 9v battery (maybe 2 in parallel)? and supply the arduino and the servo from the YwRobot regulator?
Thanks all.
Thank you for the improved circuit drawing! It's better
darrellrread:
- I have added a single 20 ohm bias resistor in parallel with the gates of the MOSFETs.(@wolframore) Question regarding this setup. What kind of current do the two FETs draw? 5v/20ohm=250mA x2? Am I drawing 500mA from the ucontroller? If correct, that seems excessive.
MOSFETs have an insulated gate, so aside some a tiny current to charge the gate capacitance, NONE.
Here's how it should be done, X2 - notice the diode is now Schottky
@wolframore - Beauty! I see that I was still thinking about the BJT instead of the FET. I will make those changes.
A question about your Capacitor recommendation of using 16-25v. If a cap is rated for 25v and it is given a supply of 12.6, will it ever charge all the way up to 25v? Or will it stop at the supplied voltage?
Also, I researched about inductive spikes caused from the motors. I see why the diode is needed.
Thanks for the info
it's just a safety rating. it just means it won't blow up at 25V... you always over spec that. It can only charge up to what you supply it with.
@wolframore. My inventory is limited. I have some 1N4148 diodes. While they aren't schottky diodes, they are fast switching (as per the datasheet). Would this be an acceptable substitute in this case?
It's hard to tell without knowing your actually PWM speed. I would put an oscilliscope on it and we can see for certain... the issue is that the MOSFET has very limited I think about 40 or 60V max so an inductive spike will take it out. It's up to you. I don't always mind burning out a few components... other times I know better.
The recovery time is pretty good on it. Can’t promise it won’t burn out. It’s good for up to 2A... I would try it. I couldn’t find any data about the current draw on the motor. The diode should be rated for at least the motor current.
Well HALLE-F**IN-LUJAH! It works!!!
Stamp a [SOLVED] tag on this topic fellas!
Thank you so much everyone for your patience and advice.
The smoke hasn't come out of the 1N4148 diodes yet. I upped the cap to a 25v @ 1000uF.
Happy days!
I will post a video of the boat in action.
Glad it's working! Looking forward to the video.
Recommended to change that out to a bigger diode in future... you may just have a situation where it will be just enough to pop that little signal diode.
they don't cost much

lol. I spoke too soon. The smoke came out of the little guy on the starboard side. Ha!
To Amazon Batman!