generate_Msg.sh
firmware/platformio.ini
- default is stlinkfirmware
folder into VScode workspace and loading Platformio IDE extension. Quick start.cd /firmware
platformio run
firmware/src/BSP/actuator_config.c
set:
rated_current
(single phase) and rated_torque
from motor spec or measurement. Note, this is just a datapoint and will be extrapolated up to 3.3A. Choose motor wisely.motor_gearbox_ratio
- gearbox attached to the motorfinal_drive_ratio
- any additional gearing - separate parameter for conveniencemotor_gearbox_ratio
or final_drive_ratio
to a negative value.BLUE LED (Function):
F1
button indicating button can be releasedF1
button or Enter in Platformio OpenOCD debugger virtual serial console)RED LED (Error):
solid with short interruption every 1s - waiting for power supply voltage to be above 8V (checks voltage every 1s)
motorParams.motorWiring
is determined automatically.F1
button to start calibration. The motor will be calibrated and values stored in Flash. Calibration can be repeated any time by long pressing F1
button until first short blink of the blue LED. firmware/actuator_config.h
. It affectes signal values read from CANbus to internal control. CANbus values are represented in actuator domain (i.e. considering motor gearbox). Change gearbox and final gear ratios in firmware/actuator_config.h
file. Available parameters are rated_current
, rated_torque
, motor_gearbox_ratio
, final_drive_ratio
.readCalibration.py
:(wiki)
Actuator accepts commands via CANbus as defined by dbc
file in Retropilot/Opendbc/ocelot_controls.dbc
CAN Command - expect rate is 10ms
Actuator will report back its status every 10ms:
Reference implementation can be found in my bmw openpilot repo:
opendbc/
- make sure ocelot_controls.dbc is copied hereselfdrive/car/xxx/xxxcan.py
- sending CAN messageselfdrive/car/xxx/carstate.py
- parsing CAN messagepanda/board/safety/safety_xxx.h
- CAN tx filter 558
, some safety, and safety testingUse this StepperServoCANtester.py
GUI program to quickly test the StepperServoCAN motor.
pip install tkinter cantools python-can
git submodule init opendbc
git submodule update opendbc
Connect the StepperServoCAN motor to the computer via CAN interface supported by python-can
.
Run the program:
python StepperServoCANtester.py
Upon startup, the program will automatically attempt to connect to the default CAN interface, which is pcan
. If you are using a different interface, you can select the desired CAN interface from the dropdown menu in the program. Once you have selected the interface, the program will establish a connection and start sending the 0x22E STEERING_COMMAND message with initial values of 0 for torque and angle.
In addition to the CAN interface dropdown menu, the program also provides two input fields where you can enter the desired motor torque and angle values. Note that torque values can be entered as floats.
You can update the injected values to the motor by clicking the "Update Torque/Angle Value" button or by pressing the "Return" key on your keyboard or changing Steer mode.
After selecting either "TorqueControl" and providing a "Steer Torque" value, or selecting "AngleControl" and providing a "Steer Angle" value, the StepperServoCAN motor will start spinning accordingly.
To exit the program, you can click the "Exit" button, press the "ESC" key, or simply close the window.
sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set up vcan0
ip -details -brief link | grep can | grep UP
If SocketCAN interfaces are not found, the program will abort.
misra.json
) for C/C++ Advanced Lint and SonarLint to highlight violations in VScode. Ask priv about the misra_rules_set_cppcheck.txt
for cppcheck.For initial software and hardware: