|
||||
Lesson 4 - Dissecting MotorBoardTopMotorBoardTop is the most important application if you plan on changing any of the hardware (designing your own motorboard or using a platform other than the Mini-Z). Below, a graphical view of MotorBoardTop is shown that was generated using Graphviz (click on the image to see the large view).Changing the Communication Channel (I2C v. UART)The preferred communication channel between the Motorboard and Mica mote is through I2C because it is fast and uses it's own clock (the motes do not have to agree on a speed indpendently as for UART). However, because pull-up resistors are not included on the Motorboard or Mica mote, the standard means for communication is UART. If these pull-up resistors are available in the future, it is straightforward to modify MotorBoardTop to use I2C instead of the UART as shown below.Modifying the MotorBoardTop Configuration This is similar to what was learned in Lesson 2. The MotorBoardTop.nc file looks like
configuration MotorBoardTop {
}
implementation {
components Main, MotorBoardTopM, UARTMotorPacket as Packet,
MotorTestC, HPLMotor1, HPLMotor2, MZServo, HPLAccelC,
LedsC;
Main.StdControl -> MotorBoardTopM;
MotorBoardTopM.CommControl -> Packet;
MotorBoardTopM.Receive -> Packet;
MotorBoardTopM.Send -> Packet;
MotorBoardTopM.MotorTest -> MotorTestC;
MotorBoardTopM.Leds -> LedsC;
MotorBoardTopM.Motor1 -> HPLMotor1;
MotorBoardTopM.Motor2 -> HPLMotor2;
MotorBoardTopM.Servo -> MZServo;
MotorBoardTopM.ServoCalibration -> MZServo;
MotorBoardTopM.MotorAccel -> HPLAccelC;
}
To use I2CMotorPacket instead of UARTMotorPacket, it is only necessary to change the component that is included:
configuration MotorBoardTop {
}
implementation {
components Main, MotorBoardTopM, I2CMotorPacket as Packet,
MotorTestC, HPLMotor1, HPLMotor2, MZServo, HPLAccelC,
LedsC;
The top-level picture then looks like this (notice UARTMotorPacket has changed to I2CMotorPacket):
Using a Different PlatformThis section is a little confusing at the moment and probably will remain so until somebody actually does this. Please email if you plan to change hardware platforms. Currently the Robot interface used from the Mica mote allows you to set the speed, turn angle, and direction of the CotsBot. If a tracked vehicle is used however, an interface that allows you to set the forward speed and turning velocity might be preferred. Or instead, you could directly set the speed of each motor.In this case a couple components will need to be modified.
Tweaking the Hardware ComponentsIt is also possible to tweak certain hardware components located in contrib/cotsbots/tos/platform/atmega8. If you'd like the PWM for the motors to run faster, modify HPLMotor(1/2).nc. If you'd like to modify the control loop for the Mini-Z servo, try changing MZServoM.nc. You may also add your own hardware components if using a different platform. Some RC cars use a solenoid instead of proportional steering and you could write an HPLSolenoidC.nc component to operate the solenoid. If you add a speedometer sensor, you might want to modify the motor components so that the speed is controlled appropriately. The sky is the limit here... |
||||