SunRover part 1: Track motor controller/power system

Track Motor Controller

I chose the Dagu T'REX chassis and motor controller because it provided a solid, stable physical base upon which to build the entire SunRover robot. I wanted a good, controllable motor platform that could be used outdoors. The T'REX motor controller turned out to be a perfect match for the chassis.

Track Chassis and Motors. The Dagu T'REX tracked chassis (Figure 4) is a low-slung, track-based robotics platform with good clearance under the box. It comes with the tracks, a metal box, and the motors and gears to make the base of the robot. I was very impressed with the attention to quality in this design. It's a bit pricey (~$250), but it meets all my needs in this project.

Figure 4: Side view of T'REX tracked chassis.

T'REX Motor Controller. The companion controller for the T'REX chassis is an I2C device called the T'REX controller. It has a number of cool features:

  • Controllable by I2C
  • Programmable with the Arduino IDE
  • Electronic braking and current monitoring for each motor
  • Three-axis accelerometer, which provides angle and impact detection
  • Six servo outputs

These features give me lots of different options for controlling and powering the motors. The integration of this controller into my WatchDog Arduino was a piece of cake. Dagu had excellent examples for the Arduino that took little time to modify.

One thing to be careful of is the T'REX motor controller I2C interface. The I2C interface will hang the I2C bus to which it's connected if the T'REX motor controller is not powered up. I asked the very helpful designer at Dagu what was up with this, and he said, "The T'REX was designed to be powered up when connected to the I2C bus."

Because I am constructing a solar-powered robot, I definitely needed the ability to power down the T'REX controller (which takes about 40mA when not doing anything – too much for a solar-powered project) while using the I2C bus to talk to other instruments. After thinking about this problem a while, I connected the controller to a separate channel on the erstwhile I2C four-channel bus multiplexer and left it as the only device on that I2C segment. This approach works perfectly. When I powered up the T'REX using the Quad Power Management I2C board and waited about 15 seconds, there it was: address 0x07 on segment 2 of the I2C four-channel multiplexer board.

The functions you can easily control on the T'REX board from the I2C bus include:

  • Motor PWM, left and right
  • Motor brakes, left and right
  • Motor speed, left and right
  • Servo 0-6 positions
  • PIF accelerometer

The data you can read from the T'REX controller includes:

  • Battery voltage
  • Left/right motor current
  • Left/right encoder count
  • Accelerometer x, y, z
  • Impact x, y, z

The result is a lot of very interesting data about what is going on with the robot, and I can gather it pretty much in real time.

Power

The Quad Power Management board (QPM) is a new board that SwitchDoc Labs just finished designing and building; I have needed one of these boards for a long time. Back when I was building Project Curacao, I continually needed relays (mostly latching relays) to switch power on and off to computers and devices, to switch from solar to wind, and to accomplish a variety of other chores. What a pain! The QPM board incorporates four I2C-controlled independent solid-state relays, each with LEDs to indicate activity. Each solid-state relay is able to switch 20V and 2.3A. You can switch DC signals and analog signals (with proper conditioning – you need to add a DC offset for analog signals).

This board is really, really useful when I am building power systems. Four additional GPIOs are provided on the board (thanks to the SX1502 as in the above board) that can be used as GPIOs, interrupts, or a programmable logic gate. Moreover, the software drivers for Arduino and Raspberry Pi are already written.

I use the QPM board three places in SunRover: first, in the Motor Controller Battery Stacker/Unstacker; second, in the Solar Power Multiplexer, and third, in the auxiliary sensor subsystem (to turn things on and off appropriately). Note that each board can only have one of two addresses (0x20 or 0x21), and I have six QPM boards. How do I do that? Again, I use the four-channel I2C multiplexer to set up different channels for the boards, and they are all controlled by an I2C bus. No more massive use of GPIO pins for latching relays and other devices. Figure 5 shows the block diagram for the QPM board.

Figure 5: Quad Power Management block diagram.

I2C Connections. SunRover uses a lot of I2C connections – at last count, at least 25 – but the way I was wiring I2C connections before just wouldn't work for something like SunRover. Basically, I used to put the I2C bus to screw terminals or snap-down connectors and then run wires to each device. In doing some research, I ran across Grove connectors [16]. Ignoring all of the modules available (some of which are cool), I found the connectors and their respective cables very useful.

I use three different sets: the Grove I2C Hub (which isn't a hub at all, strictly speaking; it's just a way to connect wires together), the Grove to single pins, and the Grove-to-Grove cables. Figures 6, 7, and 8 show these Grove plugs and connectors, and Figure 9 shows the I2C hubs installed. I found good stocks of these plugs and good service at Robot Mesh [17].

Figure 6: Grove I2C hub.
Figure 7: Grove to single plug cable.
Figure 8: Grove-to-Grove connectors.
Figure 9: SunRover electronics bay with Grove I2C hubs.

Battery Stacker and Unstacker. I need about 12V to drive the motors on the T'REX chassis. To get the ~12V needed to run the SunRover motors, I need to stack 3.7V LiPo rechargeable batteries (Figure 10). It takes three LiPo batteries to get up to about ~12V.

Figure 10: Circuit diagram for the battery stacker/unstacker.

The problem is that the solar-powered charging system is designed to charge 3.7V LiPo batteries. My solution? Use two QPM boards to switch the batteries from a series to parallel connection and then charge the batteries from SunAirPlus. The QPM board even has two inputs per device – one with a protective diode and one without – which is perfect for this application.

This board operates by switching the batteries from a power configuration (giving the SunRover motors 12V through the T'REX controller). Looking at Figure 10, that means I turn off all the switches and then turn on QPM0-IO2, QPM1-IO1, and QPMI-IO3 (the switches between the batteries and to the motor controller). This gives me 12V for the controller and motors. I'll admit it was exciting turning it on the first time (after thorough debugging) and seeing the 12V on the Motor Controller, hearing the controller power up, and seeing the controller appear on the I2C bus.

To charge the batteries, I turn all the switches off and then turn on QPM0-IO0, QPM0-IO1, QPM0-IO3, QPM1-IO0, and QPM1-IO2; then, I can charge the three 3.7V batteries in parallel via a SunAirPlus solar power controller. (See the "Volts and Currents" box for more details.)

Volts and Currents

You are switching lots of volts and current here, so you need to be very careful that your wiring and software are correct. The QPM board has an LED for each switch; make sure that your software is switching all the correct QPM channels and that your wiring is perfect. Check and check again before applying power and then make sure your software is correct. Do all of this before you hook up your stacker/unstacker to a device. Note: If you are switching a motor with the QPM board, make sure you protect against inductive kickback!

This circuit also gives you the ability to turn the power completely off to the T'REX controller, dramatically reducing quiescent power consumption in the SunRover. At publication, I am still fighting some apparent electrical noise issues caused by the motors. Running the motors back and forth under Arduino control eventually hangs the software. More on that in Part 2 of this series.

Figure 11 shows the assembled stacker board. The T'REX tracks and the battery bay are in the top right of the picture, the main electronics bay is at middle right, and QPM0 and QPM1 (the stacker/unstacker boards) with the three QPM boards for the Solar Panel Multiplexer are at bottom middle.

Figure 11: SunRover stacker/unstacker with electronics and battery bays.

Software for Stacking/Unstacking Battery. The Arduino software for stacking and unstacking the motor batteries is pretty simple. Basically, to stack:

  1. Turn all the QPM switches to Off. This isolates each battery.
  2. Turn on the connecting QPM switches that connect the batteries in series (QPM0-IO2, QPM1-IO1, QPM1-IO3).

Now you have an ~12V LiPo battery ready to rock and roll. To unstack:

  1. Turn all the QPM switches to Off. This isolates each battery.
  2. Turn on the grounds to battery 1 and battery 2 (QPM0-IO1, QPM1-IO0).
  3. Turn on the connections to the solar charger (QPM0-IO0, QPM0-IO3, QPM1-IO2).

Now you have three independent 3.7V LiPo batteries ready to be charged. (See Listings 1 and 2; all the SunRover software is available online [18].)

Listing 1

Stacking Software

01 void stackBatteryStack(uint8_t i2cmuxchannel)
02 {
03   // first turn all off
04    resetBatteryStack(i2cmuxchannel);
05
06    // Now turn on all the connecting switches
07    QuadPower0.setPowerChannel(QuadPower_POWER_CHANNEL_IO2, QuadPower_ON);
08    delay(100);
09    QuadPower1.setPowerChannel(QuadPower_POWER_CHANNEL_IO1, QuadPower_ON);
10    delay(100);
11    QuadPower1.setPowerChannel(QuadPower_POWER_CHANNEL_IO3, QuadPower_ON);
12    delay(100);
13 }

Listing 2

Unstacking Software

01 void unstackBatteryStack(uint8_t i2cmuxchannel)
02 {
03    // first turn all off
04    resetBatteryStack(i2cmuxchannel);
05
06    // Turn on grounds first
07    QuadPower0.setPowerChannel(QuadPower_POWER_CHANNEL_IO1, QuadPower_ON);
08    delay(100);
09    QuadPower1.setPowerChannel(QuadPower_POWER_CHANNEL_IO0, QuadPower_ON);
10    delay(100);
11
12    // Now turn on all the connecting switches to SunAirPlus
13    QuadPower0.setPowerChannel(QuadPower_POWER_CHANNEL_IO0, QuadPower_ON);
14    delay(100);
15    QuadPower0.setPowerChannel(QuadPower_POWER_CHANNEL_IO3, QuadPower_ON);
16    delay(100);
17    QuadPower1.setPowerChannel(QuadPower_POWER_CHANNEL_IO2, QuadPower_ON);
18    delay(100);
19 }

Buy this article as PDF

Express-Checkout as PDF

Pages: 8

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content