|
TrikiBoard Tips3. Controlling the Speed of DC motors
1. Running at 6V batterySince there is a 7805 Voltage regulator on the Board, the minimum Operating Voltage is 8V. If you need to run the robot on 6V battery, (and your motors are 6V too), don't mount the 7805 IC, and short Pin No. 1 and 3 Pads of the 7805 mounting holes by a jumper wire. In this case, however, be sure that the Voltage is 6V only. Also remember that the DC motors would get= Vbatt - 2V (approx) from the L298D IC.
2. Driving Stepper Motors by TrikiBoardIn the figure above, by 5or6-wire Stepper, we mean the Unipolar Stepper Motors which have the windings as shown. In the 5 wire type motor, the two common wires are connected inside of the motor, instead of you having to connect them outside. It is evident that the Unipolar Stepper Motors are a better choice as you can drive 2 motors, and fortunately they are more common in the used parts market too (old 5.5inch floppy drives!). However, while buying the shopkeeper may not know the motor type, and that's why I have mentioned the wire-numbers for you to see. Use your basic EE fundaes and a multimeter to find out the connections of the windings inside the Motor. 3. Controlling the Speed of the DC motors attached to Triki-BoardCommon Problem when 2 DC motors are used to drive 2 wheels of a mobile robot is: When you try to run the robot in a simple straight line, by just switching the 2 motors ON; it may not run in a straight line. Then you will realize, that the 2 DC motors have slightly different speeds at same voltages. This difference in the speed is the pain which doesn't allow the robot to go straight. I
can think of 2 solutions to this problem for TrikiBoard-1 shown in Sec 3.1 and
3.2 below. 3.1 Solution 1: Add a small resistor in series(useful in TrikiBoard-1 because it Doesn't have Built-in PWM generation Hardware) This is a very crude solution. Just add a small resistor in series with the motor which is running faster. The value of this resistor will of-course be very small and wont be available in the standard series of resistors made. Hence the best way is to cut a piece of the heating element and use it as a resistor. You can buy this heating element from any electrical shop (household electrical repair). Just experiment with different lengths of the coil of the heating element by sliding the motor wire slowly and running the robot till you get a perfect balance of the speeds. Then cut the remaining heating element. The use of heating element wire (nicrome) also caters to a very important requirement. Since the motor currents are high, this small value of resistor which you just inserted needs to dissipate lots of power (heat). So this heating element is a very good option. 3.2 Solution 2: PWM (Pulse Width Modulation) This is the better, and most commonly used solution for such a problem. And it is a totally software based approach. In short: Just provide different duty cycle PWM to the 2 motors to make them run straight or in any combination of relative speeds. Pros-&-Cons This solution is much better, because once you get the PWM software working, you can even program the robot to take curved turns instead of Zero-radius turns as in the case of Motor ON-OFF technique. Though Zero-radius turns are better for simplicity, the curved turns with PWM are much more precise, and also save a bit of time on the trajectory (important in those neck to neck timings with the opponent). 3.2.1 HOW to generate PWM:First
I would explain in brief what is a PWM; (though you know it, someone
might not), & how it affects a motor's speed. Figure 1 explains the PWM Effect on a motor, whose nominal operating Voltage is 12V (example).
Hence it is evident that, from the MCU the only thing that needs to be controlled is the time Ton and Toff, of an output pulse whose time period remains constant.
Though an idealist might argue that the 100Hz to 500Hz frequency to the motor will make noise (audible range) and it would be better to drive the PWM at higher than 20Khz. But please don't try this with your hobby circuit, because the Switching Losses of the driver transistors (inside the L298D of the Triki-board) may (will surely) overshoot the rated thermal capacity and the chip may burn. Higher switching frequency will eliminate noise, but increase heating of the driver chip. And in case of a hobby robot, its always better to see a robot with little motor whirring noise then a silent moving (dull) robot. :) Though an enthusiastic programmer would not read beyond this and would make his own logic to generate PWM, we discuss the overall flow of the PWM geneation routine (Algo) for a (any) microcontroller. 3.2.1.1 Using the Built-in PWM generation logic of MCU (only in TrikiBoard-2) This logic is not present in 89C51/52 and is common in many PIC microcontrollers (like PIC 16F877). Hence its not possible in TrikiBoard-1. However usually there only 2 PWM generation ports in 8bit MCUs. (maybe more in some MCUs). So this is good if you have only 2 motors to drive. 3.2.1.2 Total Software PWM In the following example, we assume that there is 1 Motor, and we need to control its speed and direction. Example: In case of Triki-Board, the Motor1 is controlled by P1.4 & P1.5 at PWM frquency of about 200Hz as follows.
A Quick Gist of PWM generation:
It is obvious that in this technique, the CPU is interrupted every 0.1ms, which is quite an overhead. And usually with such a trick, the Serial Communication with the CPU is very hard. However, Serial communication is anyway not needed for an autonomous maze solving robot in the micromouse contest.
|