This article is part of a series of articles about building a REAL robot. You can view all of the previous articles here and also watch the entire series on YouTube.
Not much to report for this weeks article, actually took a small break last week so the robot didn’t get as much attention as it usually does. But I did need to update you on a wiring correction from last week’s article, and also show off some of the new cabling that DB1 now has.
In the video, I also show off a few of the sensors we will be using in the project, like the Openmv Camera and RPLidar unit.
For now, we are still working on the base or Navigation layer.
Last week’s installment included the schematic for the motor controller, constructed using two Arduino Nanos. Unfortunately, the wiring diagram had an error.
The above diagram is correct, it shows +5-volts connected to the +5 Pin on each Arduino Nano, pin number 27. The original article had this connected to VIN, pin number 30, which was incorrect.
The VIN pin feeds into a voltage regulator on the hNano, it is meant for 7-12-volts. As we are using a regulated 5-volts we need to use the +5 pin, pin 27.
I’d like to thank the alert readers and viewers who pointed this out. I’ve changed the wiring on the prototype and have corrected the previous article.
Controller Version 2
I actually am now more convinced that I should have built the motor controller using ATmega328 chips instead of Arduino Nanos. So convinced that I am starting to do exactly that.
If you have already built the Nano version don’t worry, all of the code will be identical for both versions. And I’ll be using the Nano’s until I get the other controller built.
Reconstructing the motor controller will also give me an opportunity to add another integrated circuit, a 3-input OR gate that I want to use to expand the Emergency Stop inputs.
One advantage that a version based upon ATmega328 chips will have is power.
Powering the Arduino’s – Carefully!
Both the Arduino Mega and the two Nano’s have the same issue with power.
Both devices also have USB ports, a full-sized type B on the Mega and a mini USB on the Nanos. The USB ports are used for communications with the host computer, and also as a source of power.
You can power both Arduino models through the 5-volt pin, as I had done in the (corrected) wiring on the two Nanos on the controller board.
But this type of power source has a risk associated with it, as it would be directly connected to the computers 5-volt USB power if you were to connect the computer to the Arduino while the robot was powered up.
Connecting the outputs of two power supplies together is usually not advised,
So while the controller still uses Nano’s I have to be careful not to do exactly that. There are a number of options, including removing the 5-volt fuse or just popping the Nano out of its socket when it is being programmed.
Of course, the Arduino Mega that is sitting next to it has the same issue. But in that case, my solution is different.
Before we look a the wiring associated with the motor controller I want to continue our discussion about powering Arduino boards with an external 5-volt supply.
The 5-volt pin on the Arduino is usually used as an output, providing 5-volts from either the Arduino’s internal linear regulator or from an external USB supply. Using it as a voltage input, while feasible, is not always recommended.
Arduino Mega Power
The Mega 2560, like the Uno, has a small pico-fuse that can protect it when used with the USB supply or internal regulator. Using the 5-volt pin as a power input bypass this protection.
I chose to do that with the Nanos, but I didn’t want to do it with the Arduino Mega.
So instead I wired a new USB jack to sit beside the Arduino Mega, and I use a short USB cable to power it from that jack. The power comes from the power distribution board, exactly from where the Mega power was intended to originate.
This arrangement allows me to power the Mega from the main 5-volts while solving the issue of having an external computer powering the board. As both power sources use the same USB jack they can’t ever conflict.
The jack sits beside the Arduino Mega on top of two short M3 standoffs. I threaded two holes in the acrylic to mount them.
Motor Control Connections
I also made cables for the motor controller.
The 3-pin cables go to the Cytron motor driver inputs, they carry the DIR and PWM signals as well as a common ground. Cytron supplies a connector for their board, a nice touch.
I also wired two 4-pin connectors with 2.54mm JST male connectors on each end. They are both wired the same on each end. These cables go to the rotary encoder jacks on the motors.
It takes time to crimp all of the wires but constructing your own cables gives you the opportunity to make them the exact length required.
Of course, if you can find premade cables then, by all means, use them, it would be a lot simpler!
When I build my “new and improved” motor controller I will be keeping the jacks in the same locations so that the cables reach correctly.
I’ll be getting back to the programming, now that the wiring is completed. Next time we meet I hope to have some code samples for you.