Saturday, August 29, 2020

VESC (motor controller)

In a new attempt at Field Oriented Control, a VESC (Vedder Electronic Speed Controller) drove the Firefly's motor wheel for the past 500 3000 or so km.  As before, wiring up the new controller took some effort, but this one is more satisfactory.

Positive:
  • Software and firmware are open source.  It was easy to add automatic "cruise control" that saves thumb strength.  After 7 seconds of holding the right throttle high, it stays high until brake is applied.  The system is experiment-friendly.
  • The right throttle drives forward.  The left throttle brakes and drives backward. [customized code from district9prawn].  Now there is a good balance between left and right thumbs.
  • Custom features can be programmed such as a limp-home mode in case of throttle / brake-sensor failure.  Safety checks (i.e. full engagement of the attachment clamps) can also be requested through the phone app before enabling higher speeds (some programming required).
  • Torque-control is sweet.  No more annoying braking due to minor unintentional throttle movements.
  • FOC is super smooth.
  • No violent synchronization jerk when reengaging the throttle after coasting.  This may stop has stopped self-loosening of the axle nuts.
  • The phone app logs data from the controller, inertial unit, and phone GPS (10 Hz rate).
Notable:
  • Parameter settings and speed display are through Bluetooth and a phone app (screenshot below).  This allows for nice graphics and on-the-fly adjustment, but sunlight readability is low. The controller also runs fine without the phone. 
  • The VESC 6 is spec'd for 60 V max, which doesn't allow for common 48 V (13S) e-bike batteries.
    Update: A 48 V (13S) battery does work.
  • No headlight connection.  I had already been using a Cateye AMPP800 that is brighter than the stock headlight (which I removed).
  • The VESC firmware code is complex and only sparsely documented.
Issues to be addressed:
  • Weatherproofing.  As is, the controller is unlikely to survive a rainstorm and needs a protective enclosure.
  • At above-normal speed (e.g. descending a hill), the motor brake can kick in very hard, possibly blowing the battery fuse and causing other damage.  I can probably avoid this by modifying the firmware.  For now I have to avoid the motor brake when coasting fast downhill.
  • No odometer.  This is important for periodic maintenance.  I keeping a spreadsheet that adds up individual trip distances added this feature to the code.  


The VESC (which has threaded mounting holes) attaches to the battery base via two M5 screws after drilling matching holes in the base's metal bottom plate.  After a bunch of wire splices, the motor connects to the Z910 cable and the Firefly signal harness to a hard-to-find 9-pin JULET connector (JL-F-Z911AT, Thanks Mr. Wen!).  By keeping the original JULET connectors, I can easily swap back the stock controller which sits in a different battery base.  For VESC, the battery connects through yellow anti-spark XT90 connectors (I still got occasional sparks).  On top is the Bluetooth comm unit with dangling gray antenna.

 


October 16, 2020 Update:

A sturdy clear lid with overhang now protects from rain and shows LED status.  The other main ingredients were an L-bracket that clamps to the VESC via the threaded M5 holes (lucky fit), and longer M6 screw for the fork.  Some cable junctions and the Bluetooth module can still get wet, but at least the main controller is shielded.  As they say, the perfect is the enemy of the good.







No comments:

Post a Comment