I wanted to explain in a little more detail why I was concerned about motor control using the initial release of the PROS firmware and the possible remedies. First lets quickly recap how an H-Bridge works.
[ATTACH]7592[/ATTACH]
The H-Bridge consists of four switches, they are shown above in pictorial form. The implementation in the cortex uses MOSFETs, two P channel on the high side (shown as A and C here) and two N channel on the low side ( B and D ).
[ATTACH]7593[/ATTACH]
To turn the motor forwards (which way is forwards is subjective and not important here), switches B and C are closed. This creates an electrical circuit through the motor as shown on the diagram above.
To turn the motor backwards, switches A and D are closed. This creates an electrical circuit where the polarity across the motor is now reversed.
Closing either switches A and B or C and D at the same time will connect positive voltage source to ground as shown in the third diagram above. This is something you do not want to do, it has the potential to seriously damage the H-Bridge components.
[ATTACH]7594[/ATTACH]
This shows in more details how the H-Bridge in the cortex is connected. Switches A and C are connected to two control lines I’m calling enables. These will either be on or off depending on the required motor direction. To allow variable speed control of the motor, the other two MOSFETs are connected to control signals that can be pulse width modulated, that is, toggled very fast between on and off. The speed that the pwm signals are toggled is determined by the cortex firmware but is typically about 1000Hz to 1200Hz.
[ATTACH]7595[/ATTACH]
(This explanation is for illustrative purposes and not quite how things work, it’s close enough however).
This is an incredibly over simplified (and not entirely accurate) diagram showing how the pwm pulses are generated. A counter is counting from a pre-determined value down to zero, when it reaches zero the initial values is loaded again from the auto reload register. Another register called the compare register contains a second value that is constantly compared to the counter, if that value is less than the counter value the output digital value is high, if the value is greater than the counter then the output value is low. Lets say the auto reload register has the value 128 and the compare register has the value 64, the pwm output will be high for half the count time and low for the rest.
When a new compare value is needed, the user firmware must load a new value into a holding register called the compare preload register. This new value is only transferred to the compare register when the counter reaches zero. What this means is that when the user firmware wants to change the pwm duration it may not happen for some time as the current pwm cycle has to finish first.
The timer channels in the cortex each have four compare registers, their outputs are connected to separate pins on the cortex. A different compare register is used for the forward motor pwm signal to the backward motor pwm signal.
In the next post I will show what is currently happening with the PROS firmware and a better way of control.