Kuba Blog 5 - Motor Control

 Blog 5 - Motor Control

Introduction:

This week was concerned with getting the motors on the Swarm bots moving, using PWM signals sent from the PIC to the motor controller. This blog will outline the problems encountered, the connections made to get the motors to work, as well as videos and scope readings of the motors working.


Procedures:

Last week we investigated the PWM outputs from the PIC and verified their correctness. This meant that we know the signals were correct, so getting the motors working was a matter of setting the motor controller into its correct mode, and wiring everything correctly. First we decided to wire everything correctly. There is really only two main things we had to wire, i.e. the two PWM outputs from the PIC to the motor controller. The figure below from the Sabertooth 2x12 motor controller's datasheet shows the wiring of the two inputs. 



The way the bot was given to us this wiring was done incorrectly and left an open circuit, so we wired it up correctly and then connect the two PWM outputs from the PIC to these inputs. We used an oscilloscope to test which pins output the PWM signals. Once this was done we had to figure out the correct settings for the motor controller. The controller uses 6 switches to change certain aspects of its behaviour. Initially we saw an item in the datasheet that implied PWM inputs are used in analog mode, one of the three main operating modes, the others being R/C and Simplified Serial. This later turned out to be an incorrect assumption and somewhat a lack of clarity on the part of the datasheet. We later discovered that while R/C mode is mainly used for being controlled by a radio receiver, it also includes microcontroller mode. The figure from the datasheet below shows that setting switch 1 down and switch 2 up puts the controller into R/C mode.



Once this was done we had to decide how to set switch 3. The figure below shows the behaviour associated with switch 3.


Switch 3 essentially tells the controller what it is getting it's power from. In our case we set it to the up position since we aren't using lithium cells. Switch 4 has the same control regardless of mode. Essentially when it is up one input controls whether the motors are going forward or backward, and the other controls turning. When it is down each motor is controlled independently by the two different inputs, which is what we want so we put it down.

Switch 5 is also universal among modes, and it selects the response of the controller, choosing between a linear and exponential response:


Since we wanted a linear response we decided to set switch 5 to the up position. Finally, in R/C mode switch 6 decides between two modes within R/C mode. If the switch is up then we are in standard R/C mode, but when the switch is down the microcontroller goes to microcontroller mode and expects PWMs as input, as we want so that's what we set it to:


Results:

Finally, after some trial and error, and consulting the sometimes confusing datasheet, the correct switch positions were chosen. We programmed the PIC with the example PWM SM code from Jason, modifying one of the invalid PWM outputs (0.5ms) to a valid one. 

Comments

Popular posts from this blog

Blog 1 - Igor Kapusniak

Blog 5 - Bin Bot Project - Davin Barron