Welcome to the third post! Today we are going to setup the turnigy 9X mode switch and some mixes so that we can switch between ackerman and differential drive modes. We are also going to be delving into receiver (Rx) output signals and PWM Vs PPM.
Note: Most other transmitters (Tx) also have this functionality but procedure may differ. I’m using the stock Turnigy 9X firmware.
Firstly, make sure your using the “Acro” (aka Plane) model type, not Heli or Glider. Also if you’re right-handed, set the stick set option under system setting to Mode 3, to use the right stick for driving. If you’re left-handed set it to Mode 2 to use the left stick for driving.
Then navigate to menu > Func Setting (page 2) > Prog. Mix. You should see this screen:
We are going to setup 3 mixes to achieve differential drive on the Tx. This means we don’t have to do any channel mixing in code, thus keeping it simpler (relatively speaking). Each mix can be applied to one of the 3 positions of the mode switch (N, 1 or 2 shown as NOR, ID1 and ID2 respectively). Ensure all 3 mixes are set to the same mode, I’m using mode 1 (ID1) for this and leaving mode N (NOR) for ackerman.
Here is Mix 1:
Now we have setup the channel mixing needed for differential drive. There is an optional channel that we can add to give us more features and control over our rover bot, using one of the knobs on the Tx we can control the max speed of the rover (for a bit more refined speed control in tricky parts of the challenges). To set the knob as one of our channels, navigate to menu > Func Setting (page 2) > AUX-CH and set CH5/CH6 to PIT TRIM. This is the knob on the top right of the Tx, just above the left stick.
CH7 and CH8 are the 2 AUX channels we saw in our mix settings. Since we used the first AUX channel, it’s output is on channel 7 / CH7. Therefore, one of our (left side/right side) motor’s output will be on Channel 3 – Throttle channel – and the other will be on channel 7 the AUX output. Since these 2 channels are mixed with the rudder, they will be calculated by the Tx to produce appropriate levels for turning etc in differential drive. Since these mixes are all in ID1, differential drive behavior will only be seen when the switch is set to 1, and when it’s at N (normal) we can use this for ackerman. Hence, we can easily switch between driving modes in the dual steering system and also make our differential drive code simpler.
Pulse Position Modulation (PPM)
This doesn’t mean we can directly connect the channel outputs from the receiver (Rx) to the motor driver though. The output from the Rx channels is in the form of Pulse Position Modulation (PPM) signals, whereas the motor driver uses Pulse Width Modulation (PWM).
PWM signals vary the width of the pulse within a period time frame to effect an average voltage level, whereas in PPM the width of the pulses doesn’t matter. Instead, the data is in the position of the pulses within the period time frame (shown in orange). If a PPM pulse starts at the middle of a period time frame then it represents 50% :
If it starts 80% along the period time frame then it represents 80% :
So for us to use the PPM data from the Rx we need to be able to read and convert it. This would be the job of a microcontroller (like the Arduino/ESP8266), I’m using the ESP32, successor of the ESP8266 due to:
- A much faster clock speed
- Dual core capabilities
- Lot more GPIOs (we’ll need almost all of them) – more ADCs and even 2 DACs
- Integrated BLE – could be used for telemetry
- 512KB of RAM (3.2x more than ESP8266 and 256x more than an Arduino UNO!)
In the next post we’ll code the ESP32 to convert these PPM signals and even get something moving! So be sure to check it out.
P.S: I’ll also put out an arduino version of the code on my GitHub for those who want to use the arduino instead 🙂