aboutsummaryrefslogtreecommitdiff

Regenerative Braking Tester

This repo contains the Arduino code (C) and control software (Python) for a regenerative braking test stand. The Arduino code resides in main/main.ino, and the control software resides in tools/.

The Arduino and control software communicate via a custom protocol over serial.

Arduino Code

The Arduino maintains a state machine, which advances the states of pins 2 and 3 through the following states:

  1. 2 high, 3 low
  2. 2 low, 3 low
  3. 2 low, 3 high
  4. 2 low, 3 low

Attaching MOSFETs or relays to pins 2 and 3 in an H bridge-like circuit will produce acceleration and regenerative braking of an attached motor.

The program will also regularly poll the current detected by an ACS712 Hall effect current probe attached to A1 and output the current (in amperes) via serial.

Control Interface

The primary control software for interfacing with the Arduino is tools/controller.py. To run it, attach the Arduino via USB and run it with root privileges. The software will attempt to connect to the Arduino and will run through the steps of a trial. Data will be output to standard output, from which it can be logged and processed.

Tachometer

Speed sensing is done separately by tools/tachometer.py (requires OpenCV to be installed: pip install opencv). Run this with a webcam attached and pointed at the regions of interest, and it will prompt you to select the two regions of interest in a camera frame. The speed plots will then be displayed and updated in real time.