Saturday, 7 January 2017

Understanding ESC Response

In part 1 (here) - we saw how to arm the ESC. This is an essential part of getting your machine to work; irrespective of whether it is a rover or a quadrotor. The ESCs vary in their response post arming - for instance, a quadrotor ESC will not have forward and reverse motions programmed, and hence would only go from 0 - max_speed. This will correspond (usually) to PWM widths of 700 - 2200 microseconds. The overall frequency of signal pulsing is 50Hz (I have not personally tested this, but this assumption seems to work OK for two no-name ESCs). However, for cars - their neutral position is not the zero stick position (700 uS pulse / 0º pulse in Servo library), but the middle position (91º Servo position for this particular servo), though I suspect it will vary a few angles between different pieces of the same non-standard servo. Arming the servo is something that the code from the previous blog does reproducibly, and now am fairly confident that it works.

As mentioned in the previous blog, I have been having issues with getting the rotor spinning in forward and in reverse directions. It would do either, but not both. Now, a simplistic view of how we expect a Rover (car) ESC to work is given below; without a concept of brakes. The motor turns in one direction (say, forward) if the signal is above the Neutral point - and then in the other direction (reverse) if the signal is below neutral point. Without a brake (bringing it to a stop), we have to allow the forward motion to first stop (roll to a stop) before reversing. For the sake of simplicity, we will call the signal below neutral as negative, and the signal above neutral as positive. A simple state machine describing this behavior is also shown below.





However, sudden reversal in directions - especially in high speed models (these cars can run in excess of 20kmph) can cause severe wear and tear of the gear assembly. So, this simple model of switching between one direction to other with a simple switch in signal, while attractive, is not very practical. To overcome the limitations of the Car ESCs often have this concept of a brake. A brake is usually applied by a sending a brief pulse of the opposite magnitude; and then sending pulses that correspond to the specific direction in which we need the machine to move (figure below), where the ΔFlash Pulse is the pulse given in the opposite direction to activate the brake. 

Once the brake is applied, the machine is essentially at a neutral state and can move in either direction as the state machine below depicts. The colored arrows (green and red) show the relative change of direction of the pulse provided to apply the brake.


So in theory, if the car is running in forward direction, one has to apply the brake (briefly push the throttle in opposite direction) and then choose to move in either direction (again apply the throttle in the desired direction). Sounds very simple - but didn't work very well. For instance, the ESC would completely ignore the signals given in the opposite direction (say reverse, if the brake was applied while moving forward), but heed to signals that correspond to starting state.

In order to make sure this hypothesis about brake is correct, I intercepted the Tx signal and retransmitted through the Rx (circuit image below the plot), and plotted the pulse width as a function of time. (Figure below). In summary, this theory of braking and changing directions worked - but with a caveat (more on that later). To end this post - something interesting happened during the test described above - when I changed the directions too fast, and too many times - the ESC refused to respond - this is the point beyond about 27.5 seconds (275 on the X-axis).


There seems to be an inbuilt mechanism in the ESC to protect itself and the motor (and the car) from crazy driving. Unfortunately, given that this ESC has very little or no documentation, I am left guessing all of this.

Addendum: Circuit for intercepting Rx signal and re-transmitting to ESC

No comments:

Post a Comment