Motor Control
There are three motors on the board. They are connects to P1 pins on the MSP430F5510 as shown in Figure 1.
The three fans are the vertical fan (VFAN), left fan (LFAN), and the right fan (RFAN). For each fan there are two wires that need to be set. In our case, we only need three outputs from the fan: forward, reverse, and standby (where nothing is done). This is achieved by setting the input wires for each fan as described in Table 1.
Given this scheme, the speed directly depends on the percentage of time that the input lines are not both high. Therefore, it seems evident that pulse width modulation would be crucial in this step. The following figures show the scheme that was used on both the left and right motors. The shaded region represents the time that the motor is going in the direction specified.
In this way, we don’t use PWM for the pin that remains high (we do this by deselecting that bit in P1SEL and setting the pit in P1OUT). The bit that is changing determines the speed by setting the duty cycle. The relationship following the equation is described below:
Due to the configuration of the chip, we were constrained by the fact that P1.0 and P1.1 could not produce PWM signals via direct hardware control. Therefore we could not use PWM to control the top fan. Instead we used a timer interrupt that incremented a count. Whenever the count was less than or equal to the set vertical speed, it would set the output pins directly to the correct setting to put it in the right direction.If the current count was higher, it would put the motor in standby by putting both inputs to high. This counter is graphically represented by the figure below where the shaded part is where the motor is running.
Once again, we can see how the counter here wraps around when it hits the period and it uses a software scheme to keep the motor on for a certain percentage, as we did for the side motors. Whenever we get a packet telling a certain motor to go at speed X, we determine the direction by taking the sign of X. Then it calls one of three setter methods (one for each fan), that resets the given time or counts and sets the speed or duty cycle for the given motor. This change to speed is done extremely quickly since it is just changing a couple registers. The rest of the speed control is taken care of in the timer interrupts explained above.