Add 2 motor versions & test stand
This commit is contained in:
parent
dcf22ec341
commit
0120f0f591
263 changed files with 340707 additions and 721971 deletions
|
@ -9,11 +9,11 @@ build_firmware:
|
|||
image: python:3.9
|
||||
rules:
|
||||
- changes:
|
||||
- "firmware/*"
|
||||
- "controller/fw/*"
|
||||
- ".gitlab-ci.yml"
|
||||
when: on_success
|
||||
before_script:
|
||||
- cd firmware/embed
|
||||
- cd controller/fw/embed
|
||||
- pip install -U platformio
|
||||
- pio update
|
||||
script:
|
||||
|
@ -21,8 +21,8 @@ build_firmware:
|
|||
- pio run
|
||||
artifacts:
|
||||
paths:
|
||||
- firmware/embed/.pio/build/robotroller_reborn/firmware.elf
|
||||
- firmware/embed/.pio/build/robotroller_reborn/firmware.bin
|
||||
- controller/fw/embed/.pio/build/robotroller_reborn/firmware.elf
|
||||
- controller/fw/embed/.pio/build/robotroller_reborn/firmware.bin
|
||||
expire_in: 1 week
|
||||
|
||||
lint_firmware:
|
||||
|
@ -30,11 +30,11 @@ lint_firmware:
|
|||
image: python:3.9
|
||||
rules:
|
||||
- changes:
|
||||
- "firmware/*"
|
||||
- "controller/fw/*"
|
||||
- ".gitlab-ci.yml"
|
||||
when: on_success
|
||||
before_script:
|
||||
- cd firmware/embed/
|
||||
- cd controller/fw/embed/
|
||||
- pip install cpplint
|
||||
script:
|
||||
- pwd
|
||||
|
@ -77,6 +77,6 @@ clone:
|
|||
Robotroller-PCB:
|
||||
variables:
|
||||
PACKAGE_NAME: 'Robotroller-PCB'
|
||||
FOLDER: 'brd'
|
||||
FOLDER: 'controller/hw'
|
||||
PROJECT_NAME: 'motor_controller_50mm'
|
||||
extends: .kicad-pipeline
|
||||
|
|
20
README.md
20
README.md
|
@ -21,11 +21,21 @@
|
|||
|
||||
## Описание директорий
|
||||
|
||||
- `brd` - KiCAD проект печатной платы контроллера
|
||||
- `firmware` - исходный код программы для микроконтроллера, инструкция по сборке и загрузке прошивки в `firmware/embed`, тесты для проверки встроенного ПО в `firmware/test`
|
||||
- `ros2_environment` - пакеты для управления мотором из ROS 2 с помощью ros2_control
|
||||
- `src` - 3D-модели вариантов исполнения мотора: 50 мм, 70 мм, металлическая версия двигателя (не интегрирована с контроллером), также присутствуют две модели редукторов
|
||||
- `tools` - вспомогательное оборудование для тестирования, испытаний
|
||||
```[servo]
|
||||
├── controller/ # Плата контроллер
|
||||
│ ├── fw/ # Исходный код прошивки микроконтроллера
|
||||
│ │ ├── embed/ # Инструкция по сборке и загрузке прошивки
|
||||
│ │ └── test/ # Тесты для проверки встроенного ПО
|
||||
│ └── hw/ # Проект печатной платы контроллера в kicad
|
||||
├── img/ # Изображения для README.md
|
||||
├── motor/ # Все файлы сборок и деталей моторов в формате Solidworks
|
||||
├── reducer/ # Проекты редукторов в формате Solidworks
|
||||
├── ros2_environment/ # Пакеты для управления мотором из ROS 2 с помощью ros2_control
|
||||
└── tools/ # Вспомогательное оборудование для тестирования, испытаний
|
||||
├── conductor-for-fasteners-70mm/ # Проект оснастки для вкручивания винтов в пластиковый статор 72мм мотора
|
||||
├── test-reductor-stend/ # Стенд для испытания редуктора
|
||||
└── torque-test-stend/ # Стенд для измерения усилия сервопривода
|
||||
```
|
||||
|
||||
## Краткая инструкция по изготовлению
|
||||
|
||||
|
|
|
@ -1,547 +0,0 @@
|
|||
EESchema-LIBRARY Version 2.4
|
||||
#encoding utf-8
|
||||
#
|
||||
# Amplifier_Current_INA194
|
||||
#
|
||||
DEF Amplifier_Current_INA194 U 0 5 Y Y 1 F N
|
||||
F0 "U" 150 150 50 H V C CNN
|
||||
F1 "Amplifier_Current_INA194" 150 -150 50 H V C CNN
|
||||
F2 "Package_TO_SOT_SMD:SOT-23-5" 0 0 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
ALIAS INA194 INA195
|
||||
$FPLIST
|
||||
SOT?23*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
P 4 0 1 10 200 0 -200 200 -200 -200 200 0 f
|
||||
X ~ 1 300 0 100 L 50 50 1 1 O
|
||||
X GND 2 -100 -300 150 U 50 50 1 1 W
|
||||
X + 3 -300 100 100 R 50 50 1 1 I
|
||||
X - 4 -300 -100 100 R 50 50 1 1 I
|
||||
X V+ 5 -100 300 150 D 50 50 1 1 W
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Connector_Generic_Conn_02x05_Counter_Clockwise
|
||||
#
|
||||
DEF Connector_Generic_Conn_02x05_Counter_Clockwise J 0 40 Y N 1 F N
|
||||
F0 "J" 50 300 50 H V C CNN
|
||||
F1 "Connector_Generic_Conn_02x05_Counter_Clockwise" 50 -300 50 H V C CNN
|
||||
F2 "" 0 0 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
$FPLIST
|
||||
Connector*:*_2x??_*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
S -50 -195 0 -205 1 1 6 N
|
||||
S -50 -95 0 -105 1 1 6 N
|
||||
S -50 5 0 -5 1 1 6 N
|
||||
S -50 105 0 95 1 1 6 N
|
||||
S -50 205 0 195 1 1 6 N
|
||||
S -50 250 150 -250 1 1 10 f
|
||||
S 150 -195 100 -205 1 1 6 N
|
||||
S 150 -95 100 -105 1 1 6 N
|
||||
S 150 5 100 -5 1 1 6 N
|
||||
S 150 105 100 95 1 1 6 N
|
||||
S 150 205 100 195 1 1 6 N
|
||||
X Pin_1 1 -200 200 150 R 50 50 1 1 P
|
||||
X Pin_10 10 300 200 150 L 50 50 1 1 P
|
||||
X Pin_2 2 -200 100 150 R 50 50 1 1 P
|
||||
X Pin_3 3 -200 0 150 R 50 50 1 1 P
|
||||
X Pin_4 4 -200 -100 150 R 50 50 1 1 P
|
||||
X Pin_5 5 -200 -200 150 R 50 50 1 1 P
|
||||
X Pin_6 6 300 -200 150 L 50 50 1 1 P
|
||||
X Pin_7 7 300 -100 150 L 50 50 1 1 P
|
||||
X Pin_8 8 300 0 150 L 50 50 1 1 P
|
||||
X Pin_9 9 300 100 150 L 50 50 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Connector_Generic_Conn_02x08_Odd_Even
|
||||
#
|
||||
DEF Connector_Generic_Conn_02x08_Odd_Even J 0 40 Y N 1 F N
|
||||
F0 "J" 50 400 50 H V C CNN
|
||||
F1 "Connector_Generic_Conn_02x08_Odd_Even" 50 -500 50 H V C CNN
|
||||
F2 "" 0 0 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
$FPLIST
|
||||
Connector*:*_2x??_*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
S -50 -395 0 -405 1 1 6 N
|
||||
S -50 -295 0 -305 1 1 6 N
|
||||
S -50 -195 0 -205 1 1 6 N
|
||||
S -50 -95 0 -105 1 1 6 N
|
||||
S -50 5 0 -5 1 1 6 N
|
||||
S -50 105 0 95 1 1 6 N
|
||||
S -50 205 0 195 1 1 6 N
|
||||
S -50 305 0 295 1 1 6 N
|
||||
S -50 350 150 -450 1 1 10 f
|
||||
S 150 -395 100 -405 1 1 6 N
|
||||
S 150 -295 100 -305 1 1 6 N
|
||||
S 150 -195 100 -205 1 1 6 N
|
||||
S 150 -95 100 -105 1 1 6 N
|
||||
S 150 5 100 -5 1 1 6 N
|
||||
S 150 105 100 95 1 1 6 N
|
||||
S 150 205 100 195 1 1 6 N
|
||||
S 150 305 100 295 1 1 6 N
|
||||
X Pin_1 1 -200 300 150 R 50 50 1 1 P
|
||||
X Pin_10 10 300 -100 150 L 50 50 1 1 P
|
||||
X Pin_11 11 -200 -200 150 R 50 50 1 1 P
|
||||
X Pin_12 12 300 -200 150 L 50 50 1 1 P
|
||||
X Pin_13 13 -200 -300 150 R 50 50 1 1 P
|
||||
X Pin_14 14 300 -300 150 L 50 50 1 1 P
|
||||
X Pin_15 15 -200 -400 150 R 50 50 1 1 P
|
||||
X Pin_16 16 300 -400 150 L 50 50 1 1 P
|
||||
X Pin_2 2 300 300 150 L 50 50 1 1 P
|
||||
X Pin_3 3 -200 200 150 R 50 50 1 1 P
|
||||
X Pin_4 4 300 200 150 L 50 50 1 1 P
|
||||
X Pin_5 5 -200 100 150 R 50 50 1 1 P
|
||||
X Pin_6 6 300 100 150 L 50 50 1 1 P
|
||||
X Pin_7 7 -200 0 150 R 50 50 1 1 P
|
||||
X Pin_8 8 300 0 150 L 50 50 1 1 P
|
||||
X Pin_9 9 -200 -100 150 R 50 50 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Device_C
|
||||
#
|
||||
DEF Device_C C 0 10 N Y 1 F N
|
||||
F0 "C" 25 100 50 H V L CNN
|
||||
F1 "Device_C" 25 -100 50 H V L CNN
|
||||
F2 "" 38 -150 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
$FPLIST
|
||||
C_*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
P 2 0 1 20 -80 -30 80 -30 N
|
||||
P 2 0 1 20 -80 30 80 30 N
|
||||
X ~ 1 0 150 110 D 50 50 1 1 P
|
||||
X ~ 2 0 -150 110 U 50 50 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Device_C_Small
|
||||
#
|
||||
DEF Device_C_Small C 0 10 N N 1 F N
|
||||
F0 "C" 10 70 50 H V L CNN
|
||||
F1 "Device_C_Small" 10 -80 50 H V L CNN
|
||||
F2 "" 0 0 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
$FPLIST
|
||||
C_*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
P 2 0 1 13 -60 -20 60 -20 N
|
||||
P 2 0 1 12 -60 20 60 20 N
|
||||
X ~ 1 0 100 80 D 50 50 1 1 P
|
||||
X ~ 2 0 -100 80 U 50 50 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Device_L
|
||||
#
|
||||
DEF Device_L L 0 40 N N 1 F N
|
||||
F0 "L" -50 0 50 V V C CNN
|
||||
F1 "Device_L" 75 0 50 V V C CNN
|
||||
F2 "" 0 0 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
$FPLIST
|
||||
Choke_*
|
||||
*Coil*
|
||||
Inductor_*
|
||||
L_*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
A 0 -75 25 -899 899 0 1 0 N 0 -100 0 -50
|
||||
A 0 -25 25 -899 899 0 1 0 N 0 -50 0 0
|
||||
A 0 25 25 -899 899 0 1 0 N 0 0 0 50
|
||||
A 0 75 25 -899 899 0 1 0 N 0 50 0 100
|
||||
X 1 1 0 150 50 D 50 50 1 1 P
|
||||
X 2 2 0 -150 50 U 50 50 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Device_LED
|
||||
#
|
||||
DEF Device_LED D 0 40 N N 1 F N
|
||||
F0 "D" 0 100 50 H V C CNN
|
||||
F1 "Device_LED" 0 -100 50 H V C CNN
|
||||
F2 "" 0 0 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
$FPLIST
|
||||
LED*
|
||||
LED_SMD:*
|
||||
LED_THT:*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
P 2 0 1 10 -50 -50 -50 50 N
|
||||
P 2 0 1 0 -50 0 50 0 N
|
||||
P 4 0 1 10 50 -50 50 50 -50 0 50 -50 N
|
||||
P 5 0 1 0 -120 -30 -180 -90 -150 -90 -180 -90 -180 -60 N
|
||||
P 5 0 1 0 -70 -30 -130 -90 -100 -90 -130 -90 -130 -60 N
|
||||
X K 1 -150 0 100 R 50 50 1 1 P
|
||||
X A 2 150 0 100 L 50 50 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Device_R
|
||||
#
|
||||
DEF Device_R R 0 0 N Y 1 F N
|
||||
F0 "R" 80 0 50 V V C CNN
|
||||
F1 "Device_R" 0 0 50 V V C CNN
|
||||
F2 "" -70 0 50 V I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
$FPLIST
|
||||
R_*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
S -40 -100 40 100 0 1 10 N
|
||||
X ~ 1 0 150 50 D 50 50 1 1 P
|
||||
X ~ 2 0 -150 50 U 50 50 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Device_Thermistor_NTC
|
||||
#
|
||||
DEF Device_Thermistor_NTC TH 0 0 N Y 1 F N
|
||||
F0 "TH" -175 0 50 V V C CNN
|
||||
F1 "Device_Thermistor_NTC" 125 0 50 V V C CNN
|
||||
F2 "" 0 50 50 H I C CNN
|
||||
F3 "" 0 50 50 H I C CNN
|
||||
$FPLIST
|
||||
*NTC*
|
||||
*Thermistor*
|
||||
PIN?ARRAY*
|
||||
bornier*
|
||||
*Terminal?Block*
|
||||
R_*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
A -126 88 7 -265 818 0 1 0 N -120 85 -125 95
|
||||
A -110 85 10 1800 -900 0 1 0 N -120 85 -110 75
|
||||
A -110 85 10 -900 0 0 1 0 N -110 75 -100 85
|
||||
A -110 110 10 0 900 0 1 0 N -100 110 -110 120
|
||||
A -110 110 10 900 1800 0 1 0 N -110 120 -120 110
|
||||
A -110 110 10 1800 -900 0 1 0 N -120 110 -110 100
|
||||
A -104 119 20 -1075 -253 0 1 0 N -110 100 -85 110
|
||||
S -40 100 40 -100 0 1 10 N
|
||||
P 2 0 1 0 -100 85 -100 110 N
|
||||
P 4 0 1 0 -70 100 -70 60 70 -60 70 -100 N
|
||||
P 6 0 1 0 -100 -145 -100 -55 -110 -85 -90 -85 -100 -55 -100 -65 F
|
||||
P 6 0 1 0 -70 -55 -70 -145 -80 -115 -60 -115 -70 -145 -70 -135 F
|
||||
X ~ 1 0 150 50 D 50 50 1 1 P
|
||||
X ~ 2 0 -150 50 U 50 50 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Diode_1N5818
|
||||
#
|
||||
DEF Diode_1N5818 D 0 40 N N 1 F N
|
||||
F0 "D" 0 100 50 H V C CNN
|
||||
F1 "Diode_1N5818" 0 -100 50 H V C CNN
|
||||
F2 "Diode_THT:D_DO-41_SOD81_P10.16mm_Horizontal" 0 -175 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
ALIAS SB130 SB140 SB150 SB160 1N5817 1N5818 1N5819
|
||||
$FPLIST
|
||||
D*DO?41*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
P 2 0 1 0 50 0 -50 0 N
|
||||
P 4 0 1 10 50 50 50 -50 -50 0 50 50 N
|
||||
P 6 0 1 10 -75 25 -75 50 -50 50 -50 -50 -25 -50 -25 -25 N
|
||||
X K 1 -150 0 100 R 50 50 1 1 P
|
||||
X A 2 150 0 100 L 50 50 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Driver_Motor_drv8313
|
||||
#
|
||||
DEF Driver_Motor_drv8313 U 0 40 Y Y 1 F N
|
||||
F0 "U" -300 50 50 H V C CNN
|
||||
F1 "Driver_Motor_drv8313" 200 50 50 H V C CNN
|
||||
F2 "" -700 0 50 H I C CNN
|
||||
F3 "" -700 0 50 H I C CNN
|
||||
DRAW
|
||||
S -450 -50 350 -1550 0 1 0 f
|
||||
X cpl 1 -550 -150 100 R 50 50 1 1 I
|
||||
X pgnd3 10 -550 -1050 100 R 50 50 1 1 I
|
||||
X vm 11 -550 -1150 100 R 50 50 1 1 I
|
||||
X compp 12 -550 -1250 100 R 50 50 1 1 I
|
||||
X compn 13 -550 -1350 100 R 50 50 1 1 I
|
||||
X gnd 14 -550 -1450 100 R 50 50 1 1 W
|
||||
X v3p3 15 450 -1450 100 L 50 50 1 1 w
|
||||
X nReset 16 450 -1350 100 L 50 50 1 1 I
|
||||
X nSleep 17 450 -1250 100 L 50 50 1 1 I
|
||||
X nFault 18 450 -1150 100 L 50 50 1 1 O
|
||||
X nCompo 19 450 -1050 100 L 50 50 1 1 I
|
||||
X cph 2 -550 -250 100 R 50 50 1 1 I
|
||||
X gnd 20 450 -950 100 L 50 50 1 1 W
|
||||
X nc 21 450 -850 100 L 50 50 1 1 I
|
||||
X en3 22 450 -750 100 L 50 50 1 1 I
|
||||
X in3 23 450 -650 100 L 50 50 1 1 I
|
||||
X en2 24 450 -550 100 L 50 50 1 1 I
|
||||
X in2 25 450 -450 100 L 50 50 1 1 I
|
||||
X en1 26 450 -350 100 L 50 50 1 1 I
|
||||
X in1 27 450 -250 100 L 50 50 1 1 I
|
||||
X gnd 28 450 -150 100 L 50 50 1 1 W
|
||||
X vcp 3 -550 -350 100 R 50 50 1 1 I
|
||||
X vm 4 -550 -450 100 R 50 50 1 1 I
|
||||
X out1 5 -550 -550 100 R 50 50 1 1 O
|
||||
X pgnd1 6 -550 -650 100 R 50 50 1 1 I
|
||||
X pgnd2 7 -550 -750 100 R 50 50 1 1 I
|
||||
X out2 8 -550 -850 100 R 50 50 1 1 O
|
||||
X out3 9 -550 -950 100 R 50 50 1 1 O
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Interface_CAN_LIN_SN65HVD235
|
||||
#
|
||||
DEF Interface_CAN_LIN_SN65HVD235 U 0 40 Y Y 1 F N
|
||||
F0 "U" -100 400 50 H V R CNN
|
||||
F1 "Interface_CAN_LIN_SN65HVD235" -100 300 50 H V R CNN
|
||||
F2 "Package_SO:SOIC-8_3.9x4.9mm_P1.27mm" 0 -500 50 H I C CNN
|
||||
F3 "" -100 400 50 H I C CNN
|
||||
$FPLIST
|
||||
SOIC*3.9x4.9mm*P1.27mm*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
S -300 200 300 -300 0 1 10 f
|
||||
X D 1 -400 100 100 R 50 50 1 1 I
|
||||
X GND 2 0 -400 100 U 50 50 1 1 W
|
||||
X VCC 3 0 300 100 D 50 50 1 1 W
|
||||
X R 4 -400 0 100 R 50 50 1 1 O
|
||||
X AB 5 -400 -100 100 R 50 50 1 1 I
|
||||
X CANL 6 400 -100 100 L 50 50 1 1 B
|
||||
X CANH 7 400 0 100 L 50 50 1 1 B
|
||||
X Rs 8 -400 -200 100 R 50 50 1 1 I
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# MCU_ST_STM32F4_STM32F446RETx
|
||||
#
|
||||
DEF MCU_ST_STM32F4_STM32F446RETx U 0 20 Y Y 1 F N
|
||||
F0 "U" -600 1650 50 H V L CNN
|
||||
F1 "MCU_ST_STM32F4_STM32F446RETx" 400 1650 50 H V L CNN
|
||||
F2 "Package_QFP:LQFP-64_10x10mm_P0.5mm" -600 -1700 50 H I R CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
ALIAS STM32F446RETx
|
||||
$FPLIST
|
||||
LQFP*10x10mm*P0.5mm*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
S -600 -1700 600 1600 0 1 10 f
|
||||
X VBAT 1 -200 1700 100 D 50 50 1 1 W
|
||||
X PC2 10 -700 -300 100 R 50 50 1 1 B
|
||||
X PC3 11 -700 -400 100 R 50 50 1 1 B
|
||||
X VSSA 12 200 -1800 100 U 50 50 1 1 W
|
||||
X VDDA 13 300 1700 100 D 50 50 1 1 W
|
||||
X PA0 14 700 1500 100 L 50 50 1 1 B
|
||||
X PA1 15 700 1400 100 L 50 50 1 1 B
|
||||
X PA2 16 700 1300 100 L 50 50 1 1 B
|
||||
X PA3 17 700 1200 100 L 50 50 1 1 B
|
||||
X VSS 18 -200 -1800 100 U 50 50 1 1 W
|
||||
X VDD 19 -100 1700 100 D 50 50 1 1 W
|
||||
X PC13 2 -700 -1400 100 R 50 50 1 1 B
|
||||
X PA4 20 700 1100 100 L 50 50 1 1 B
|
||||
X PA5 21 700 1000 100 L 50 50 1 1 B
|
||||
X PA6 22 700 900 100 L 50 50 1 1 B
|
||||
X PA7 23 700 800 100 L 50 50 1 1 B
|
||||
X PC4 24 -700 -500 100 R 50 50 1 1 B
|
||||
X PC5 25 -700 -600 100 R 50 50 1 1 B
|
||||
X PB0 26 700 -200 100 L 50 50 1 1 B
|
||||
X PB1 27 700 -300 100 L 50 50 1 1 B
|
||||
X PB2 28 700 -400 100 L 50 50 1 1 B
|
||||
X PB10 29 700 -1200 100 L 50 50 1 1 B
|
||||
X PC14 3 -700 -1500 100 R 50 50 1 1 B
|
||||
X VCAP_1 30 -700 1100 100 R 50 50 1 1 W
|
||||
X VSS 31 -100 -1800 100 U 50 50 1 1 W
|
||||
X VDD 32 0 1700 100 D 50 50 1 1 W
|
||||
X PB12 33 700 -1300 100 L 50 50 1 1 B
|
||||
X PB13 34 700 -1400 100 L 50 50 1 1 B
|
||||
X PB14 35 700 -1500 100 L 50 50 1 1 B
|
||||
X PB15 36 700 -1600 100 L 50 50 1 1 B
|
||||
X PC6 37 -700 -700 100 R 50 50 1 1 B
|
||||
X PC7 38 -700 -800 100 R 50 50 1 1 B
|
||||
X PC8 39 -700 -900 100 R 50 50 1 1 B
|
||||
X PC15 4 -700 -1600 100 R 50 50 1 1 B
|
||||
X PC9 40 -700 -1000 100 R 50 50 1 1 B
|
||||
X PA8 41 700 700 100 L 50 50 1 1 B
|
||||
X PA9 42 700 600 100 L 50 50 1 1 B
|
||||
X PA10 43 700 500 100 L 50 50 1 1 B
|
||||
X PA11 44 700 400 100 L 50 50 1 1 B
|
||||
X PA12 45 700 300 100 L 50 50 1 1 B
|
||||
X PA13 46 700 200 100 L 50 50 1 1 B
|
||||
X VSS 47 0 -1800 100 U 50 50 1 1 W
|
||||
X VDD 48 100 1700 100 D 50 50 1 1 W
|
||||
X PA14 49 700 100 100 L 50 50 1 1 B
|
||||
X PH0 5 -700 400 100 R 50 50 1 1 I
|
||||
X PA15 50 700 0 100 L 50 50 1 1 B
|
||||
X PC10 51 -700 -1100 100 R 50 50 1 1 B
|
||||
X PC11 52 -700 -1200 100 R 50 50 1 1 B
|
||||
X PC12 53 -700 -1300 100 R 50 50 1 1 B
|
||||
X PD2 54 -700 100 100 R 50 50 1 1 B
|
||||
X PB3 55 700 -500 100 L 50 50 1 1 B
|
||||
X PB4 56 700 -600 100 L 50 50 1 1 B
|
||||
X PB5 57 700 -700 100 L 50 50 1 1 B
|
||||
X PB6 58 700 -800 100 L 50 50 1 1 B
|
||||
X PB7 59 700 -900 100 L 50 50 1 1 B
|
||||
X PH1 6 -700 300 100 R 50 50 1 1 I
|
||||
X BOOT0 60 -700 1300 100 R 50 50 1 1 I
|
||||
X PB8 61 700 -1000 100 L 50 50 1 1 B
|
||||
X PB9 62 700 -1100 100 L 50 50 1 1 B
|
||||
X VSS 63 100 -1800 100 U 50 50 1 1 W
|
||||
X VDD 64 200 1700 100 D 50 50 1 1 W
|
||||
X NRST 7 -700 1500 100 R 50 50 1 1 I
|
||||
X PC0 8 -700 -100 100 R 50 50 1 1 B
|
||||
X PC1 9 -700 -200 100 R 50 50 1 1 B
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Mechanical_MountingHole_Pad
|
||||
#
|
||||
DEF Mechanical_MountingHole_Pad H 0 40 N N 1 F N
|
||||
F0 "H" 0 250 50 H V C CNN
|
||||
F1 "Mechanical_MountingHole_Pad" 0 175 50 H V C CNN
|
||||
F2 "" 0 0 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
$FPLIST
|
||||
MountingHole*Pad*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
C 0 50 50 0 1 50 N
|
||||
X 1 1 0 -100 100 U 50 50 1 1 I
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Regulator_Switching_LM2594HVM-3.3
|
||||
#
|
||||
DEF Regulator_Switching_LM2594HVM-3.3 U 0 20 Y Y 1 F N
|
||||
F0 "U" -300 250 50 H V L CNN
|
||||
F1 "Regulator_Switching_LM2594HVM-3.3" 0 250 50 H V L CNN
|
||||
F2 "Package_SO:SOIC-8_3.9x4.9mm_P1.27mm" 200 -250 50 H I L CIN
|
||||
F3 "" 0 100 50 H I C CNN
|
||||
ALIAS LM2594M-5.0 LM2594M-12 LM2594M-ADJ LM2594HVM-3.3 LM2594HVM-5.0 LM2594HVM-12 LM2594HVM-ADJ
|
||||
$FPLIST
|
||||
SOIC*3.9x4.9mm*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
S -300 200 300 -200 0 1 10 f
|
||||
X NC 1 -200 -300 100 U 50 50 1 1 P
|
||||
X NC 2 -100 -300 100 U 50 50 1 1 P
|
||||
X NC 3 0 -300 100 U 50 50 1 1 P
|
||||
X FB 4 400 100 100 L 50 50 1 1 I
|
||||
X ~ON~/OFF 5 -400 0 100 R 50 50 1 1 I
|
||||
X GND 6 200 -300 100 U 50 50 1 1 W
|
||||
X VIN 7 -400 100 100 R 50 50 1 1 W
|
||||
X OUT 8 400 0 100 L 50 50 1 1 O
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# Sensor_Magnetic_AS5045B
|
||||
#
|
||||
DEF Sensor_Magnetic_AS5045B U 0 20 Y Y 1 F N
|
||||
F0 "U" -400 450 50 H V L CNN
|
||||
F1 "Sensor_Magnetic_AS5045B" 450 450 50 H V R CNN
|
||||
F2 "Package_SO:SSOP-16_5.3x6.2mm_P0.65mm" 150 -450 50 H I L CNN
|
||||
F3 "" -2150 1600 50 H I C CNN
|
||||
$FPLIST
|
||||
SSOP*5.3x6.2mm*P0.65mm*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
A 0 0 110 -1799 -1 0 1 10 N -110 0 110 0
|
||||
C 0 0 80 0 1 10 N
|
||||
S -400 400 400 -400 0 1 10 f
|
||||
P 2 0 1 10 -110 0 -130 -20 N
|
||||
P 2 0 1 10 -110 0 -90 -20 N
|
||||
P 2 0 1 10 110 0 90 -20 N
|
||||
P 2 0 1 10 110 0 130 -20 N
|
||||
P 4 0 1 0 10 10 50 -30 30 -50 -10 -10 N
|
||||
P 7 0 1 0 -30 50 10 10 -10 -10 -50 30 -40 40 -30 50 -25 45 F
|
||||
X MagINCn 1 -500 -200 100 R 50 50 1 1 C
|
||||
X CLK 10 500 100 100 L 50 50 1 1 I
|
||||
X CSn 11 500 0 100 L 50 50 1 1 I
|
||||
X PWM 12 500 -300 100 L 50 50 1 1 O
|
||||
X NC 13 400 -200 100 L 50 50 1 1 N N
|
||||
X NC 14 100 -400 100 U 50 50 1 1 N N
|
||||
X VDD3V3 15 -100 500 100 D 50 50 1 1 W
|
||||
X VDD5V 16 0 500 100 D 50 50 1 1 W
|
||||
X MagDECn 2 -500 -300 100 R 50 50 1 1 C
|
||||
X A 3 -500 300 100 R 50 50 1 1 O
|
||||
X B 4 -500 200 100 R 50 50 1 1 O
|
||||
X NC 5 400 -100 100 L 50 50 1 1 N N
|
||||
X I 6 -500 100 100 R 50 50 1 1 O
|
||||
X VSS 7 0 -500 100 U 50 50 1 1 W
|
||||
X PDIO 8 500 300 100 L 50 50 1 1 I
|
||||
X DO 9 500 200 100 L 50 50 1 1 O
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# kicad_Library_PROGRAMMATOR
|
||||
#
|
||||
DEF kicad_Library_PROGRAMMATOR xp 0 40 Y Y 1 F N
|
||||
F0 "xp" -350 900 50 H V C CNN
|
||||
F1 "kicad_Library_PROGRAMMATOR" -400 200 50 H V C CNN
|
||||
F2 "Connector_IDC:IDC-Header_2x05_P2.54mm_Vertical" -350 900 50 H I C CNN
|
||||
F3 "" -350 900 50 H I C CNN
|
||||
DRAW
|
||||
S -700 800 50 300 0 1 0 f
|
||||
X GND 1 -800 750 100 R 50 50 1 1 P
|
||||
X +5V 10 150 350 100 L 50 50 1 1 w
|
||||
X +3V 2 150 750 100 L 50 50 1 1 w
|
||||
X RESET 3 -800 650 100 R 50 50 1 1 I
|
||||
X BOOT 4 150 650 100 L 50 50 1 1 I
|
||||
X RX 5 -800 550 100 R 50 50 1 1 I
|
||||
X TX 6 150 550 100 L 50 50 1 1 O
|
||||
X SWDCLK 7 -800 450 100 R 50 50 1 1 I
|
||||
X SWDDTA 8 150 450 100 L 50 50 1 1 B
|
||||
X GND 9 -800 350 100 R 50 50 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# power_+24V
|
||||
#
|
||||
DEF power_+24V #PWR 0 0 Y Y 1 F P
|
||||
F0 "#PWR" 0 -150 50 H I C CNN
|
||||
F1 "power_+24V" 0 140 50 H V C CNN
|
||||
F2 "" 0 0 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
DRAW
|
||||
P 2 0 1 0 -30 50 0 100 N
|
||||
P 2 0 1 0 0 0 0 100 N
|
||||
P 2 0 1 0 0 100 30 50 N
|
||||
X +24V 1 0 0 0 U 50 50 1 1 W N
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# power_+3.3V
|
||||
#
|
||||
DEF power_+3.3V #PWR 0 0 Y Y 1 F P
|
||||
F0 "#PWR" 0 -150 50 H I C CNN
|
||||
F1 "power_+3.3V" 0 140 50 H V C CNN
|
||||
F2 "" 0 0 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
ALIAS +3.3V
|
||||
DRAW
|
||||
P 2 0 1 0 -30 50 0 100 N
|
||||
P 2 0 1 0 0 0 0 100 N
|
||||
P 2 0 1 0 0 100 30 50 N
|
||||
X +3V3 1 0 0 0 U 50 50 1 1 W N
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# power_GND
|
||||
#
|
||||
DEF power_GND #PWR 0 0 Y Y 1 F P
|
||||
F0 "#PWR" 0 -250 50 H I C CNN
|
||||
F1 "power_GND" 0 -150 50 H V C CNN
|
||||
F2 "" 0 0 50 H I C CNN
|
||||
F3 "" 0 0 50 H I C CNN
|
||||
DRAW
|
||||
P 6 0 1 0 0 0 0 -50 50 -50 0 -100 -50 -50 0 -50 N
|
||||
X GND 1 0 0 0 D 50 50 1 1 W N
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
#End Library
|
1
controller/fw/embed/.clang-tidy
Normal file
1
controller/fw/embed/.clang-tidy
Normal file
|
@ -0,0 +1 @@
|
|||
Checks: '-*, -misc-definitions-in-headers'
|
18
controller/fw/embed/.clangd
Normal file
18
controller/fw/embed/.clangd
Normal file
|
@ -0,0 +1,18 @@
|
|||
CompileFlags:
|
||||
Add:
|
||||
[
|
||||
# -mlong-calls,
|
||||
-DSSIZE_MAX,
|
||||
-DLWIP_NO_UNISTD_H=1,
|
||||
-Dssize_t=long,
|
||||
-D_SSIZE_T_DECLARED,
|
||||
]
|
||||
Remove:
|
||||
[
|
||||
-fno-tree-switch-conversion,
|
||||
-mtext-section-literals,
|
||||
-mlongcalls,
|
||||
-fstrict-volatile-bitfields,
|
||||
-free,
|
||||
-fipa-pta,
|
||||
]
|
|
@ -3,3 +3,7 @@
|
|||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
.cache/
|
||||
.metadata/
|
||||
cubemx_config/
|
||||
compile_commands.json
|
19
controller/fw/embed/check_gcc_version.py
Normal file
19
controller/fw/embed/check_gcc_version.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
Import("env")
|
||||
|
||||
# Получаем путь к компилятору из окружения PlatformIO
|
||||
gcc_path = env.subst("$CC")
|
||||
|
||||
# Выполняем команду для получения версии компилятора
|
||||
import subprocess
|
||||
|
||||
try:
|
||||
result = subprocess.run([gcc_path, "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
if result.returncode == 0:
|
||||
print(f"GCC version: {result.stdout}")
|
||||
else:
|
||||
print(f"Failed to get GCC version: {result.stderr}")
|
||||
except Exception as e:
|
||||
print(f"Error while getting GCC version: {e}")
|
||||
|
||||
# Дополнительно проверяем путь к компилятору
|
||||
print(f"Compiler path: {gcc_path}")
|
8
controller/fw/embed/gen_compile_commands.py
Normal file
8
controller/fw/embed/gen_compile_commands.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
import os
|
||||
Import("env")
|
||||
|
||||
# include toolchain paths
|
||||
env.Replace(COMPILATIONDB_INCLUDE_TOOLCHAIN=True)
|
||||
|
||||
# override compilation DB path
|
||||
env.Replace(COMPILATIONDB_PATH="compile_commands.json")
|
|
@ -16,12 +16,13 @@ board = genericSTM32F446RE
|
|||
framework = arduino
|
||||
upload_protocol = stlink
|
||||
debug_tool = stlink
|
||||
monitor_speed = 115200
|
||||
monitor_speed = 19200
|
||||
monitor_parity = N
|
||||
build_flags =
|
||||
-DSTM32F446xx
|
||||
-D HAL_CAN_MODULE_ENABLED
|
||||
-D SIMPLEFOC_PWM_LOWSIDE_ACTIVE_HIGH
|
||||
lib_deps =
|
||||
askuric/Simple FOC@^2.3.2
|
||||
pazi88/STM32_CAN@^1.1.0
|
||||
askuric/Simple FOC@^2.3.4
|
||||
pazi88/STM32_CAN@^1.1.2
|
||||
extra_scripts = pre:gen_compile_commands.py
|
|
@ -37,8 +37,8 @@ void setup_foc(MagneticSensorAS5045 *sensor, BLDCMotor *motor, DRV8313Driver *dr
|
|||
sensor->init(&spi);
|
||||
motor->linkSensor(sensor);
|
||||
driver->pwm_frequency = 20000;
|
||||
driver->voltage_power_supply = 20;
|
||||
driver->voltage_limit = 40;
|
||||
driver->voltage_power_supply = 24;
|
||||
driver->voltage_limit = 24;
|
||||
driver->init();
|
||||
motor->linkDriver(driver);
|
||||
current_sense->linkDriver(driver);
|
||||
|
@ -50,6 +50,7 @@ void setup_foc(MagneticSensorAS5045 *sensor, BLDCMotor *motor, DRV8313Driver *dr
|
|||
motor->monitor_start_char = 'M';
|
||||
motor->monitor_end_char = 'M';
|
||||
commander->verbose = VerboseMode::machine_readable;
|
||||
motor->monitor_downsample = 5000;
|
||||
motor->controller = MotionControlType::angle;
|
||||
motor->torque_controller = TorqueControlType::voltage;
|
||||
motor->foc_modulation = FOCModulationType::SinePWM;
|
86
controller/fw/embed/test/README.md
Normal file
86
controller/fw/embed/test/README.md
Normal file
|
@ -0,0 +1,86 @@
|
|||
# CAN Communication Scripts
|
||||
|
||||
This repository contains Python scripts for testing and interacting with a CAN bus system. These scripts enable sending and receiving CAN messages to control a motor, set angles, and adjust velocities.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. **Python 3.7+** installed on your system.
|
||||
2. **`python-can` library** installed. Install it via pip:
|
||||
```bash
|
||||
pip install python-can
|
||||
```
|
||||
3. **SocketCAN interface** properly configured on your Linux system. The default channel is `can0`.
|
||||
|
||||
## Usage
|
||||
|
||||
### 1. Receiving CAN Messages
|
||||
|
||||
The script `python_can.py` listens to the CAN bus and processes incoming messages.
|
||||
|
||||
#### Run:
|
||||
```bash
|
||||
python3 python_can.py
|
||||
```
|
||||
|
||||
#### Features:
|
||||
- Processes messages with data length 5.
|
||||
- Parses the first byte (`flag`) to determine the type:
|
||||
- `'A'`: Angle (float).
|
||||
- `'V'`: Velocity (float).
|
||||
- `'E'`: Enable/disable status (boolean).
|
||||
|
||||
### 2. Enabling or Disabling the Motor
|
||||
|
||||
The script `python_enable_motor.py` sends commands to enable or disable the motor.
|
||||
|
||||
#### Run:
|
||||
```bash
|
||||
python3 python_enable_motor.py <0|1>
|
||||
```
|
||||
|
||||
#### Arguments:
|
||||
- `0`: Disable the motor.
|
||||
- `1`: Enable the motor.
|
||||
|
||||
### 3. Sending Target Angle
|
||||
|
||||
The script `python_send_angle.py` sends a target angle to the CAN bus.
|
||||
|
||||
#### Run:
|
||||
```bash
|
||||
python3 python_send_angle.py
|
||||
```
|
||||
|
||||
#### Behavior:
|
||||
- Sends a message with a predefined target angle every second.
|
||||
- Adjust the target angle in the script (`target_angle` variable).
|
||||
|
||||
### 4. Sending Target Velocity
|
||||
|
||||
The script `python_send_velocity.py` sends a target velocity to the CAN bus.
|
||||
|
||||
#### Run:
|
||||
```bash
|
||||
python3 python_send_velocity.py
|
||||
```
|
||||
|
||||
#### Behavior:
|
||||
- Sends a message with a predefined target velocity every second.
|
||||
- Adjust the target velocity in the script (`target_speed` variable).
|
||||
|
||||
## Configuration
|
||||
|
||||
### CAN Interface
|
||||
The scripts use the following default CAN bus settings:
|
||||
- **Channel**: `can0`
|
||||
- **Bitrate**: `1 Mbps`
|
||||
|
||||
If your configuration differs, update the `Bus()` initialization in the scripts.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
1. **"Error initializing CAN bus"**:
|
||||
- Ensure your CAN interface is correctly configured and active:
|
||||
```bash
|
||||
sudo ip link set can0 up type can bitrate 1000000
|
||||
```
|
47
controller/fw/embed/test/python_can.py
Normal file
47
controller/fw/embed/test/python_can.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
import can
|
||||
import struct
|
||||
import time
|
||||
|
||||
def process_can_message(msg):
|
||||
if msg.dlc == 5: # Check the message length
|
||||
print(f"Received message with ID: {msg.arbitration_id}")
|
||||
print(f"Data: {msg.data}")
|
||||
|
||||
# The first byte determines the data type (flag)
|
||||
flag = chr(msg.data[0])
|
||||
|
||||
if flag == 'A': # Angle
|
||||
angle_bytes = msg.data[1:5]
|
||||
angle = struct.unpack('<f', bytes(angle_bytes))[0]
|
||||
print(f"Angle: {angle} degrees")
|
||||
elif flag == 'V': # Velocity
|
||||
velocity_bytes = msg.data[1:5]
|
||||
velocity = struct.unpack('<f', bytes(velocity_bytes))[0]
|
||||
print(f"Velocity: {velocity} rad/s")
|
||||
elif flag == 'E' and msg.dlc >= 2: # Enable/Disable
|
||||
enabled = msg.data[1] # Expecting 1 byte (0 or 1)
|
||||
print(f"Enabled: {bool(enabled)}")
|
||||
else:
|
||||
print(f"Unknown flag: {flag}")
|
||||
else:
|
||||
print(f"Received message with unexpected length: {msg.dlc}")
|
||||
|
||||
def receive_can_messages():
|
||||
try:
|
||||
# Connect to the CAN bus
|
||||
bus = can.interface.Bus(channel='can0', bustype='socketcan')
|
||||
|
||||
print("Waiting for messages on the CAN bus...")
|
||||
|
||||
while True:
|
||||
msg = bus.recv()
|
||||
if msg:
|
||||
process_can_message(msg)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("\nExiting program...")
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
receive_can_messages()
|
54
controller/fw/embed/test/python_enable_motor.py
Normal file
54
controller/fw/embed/test/python_enable_motor.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
import can
|
||||
import sys
|
||||
|
||||
# Function to send the motor enable/disable command
|
||||
def send_motor_enable(bus, enable):
|
||||
"""
|
||||
Sends a command to enable or disable the motor.
|
||||
|
||||
:param bus: The CAN bus
|
||||
:param enable: 1 to enable the motor, 0 to disable it
|
||||
"""
|
||||
msg = can.Message()
|
||||
msg.arbitration_id = 1 # Message ID
|
||||
msg.is_extended_id = False
|
||||
msg.dlc = 2 # Message length (flag + 1 byte of data)
|
||||
msg.data = [ord('E'), enable] # 'E' for the command, followed by 0 or 1
|
||||
|
||||
try:
|
||||
bus.send(msg)
|
||||
state = "enabled" if enable else "disabled"
|
||||
print(f"Sent message to {state} motor")
|
||||
print(f"Message data: {msg.data}")
|
||||
except can.CanError as e:
|
||||
print(f"Message failed to send: {e}")
|
||||
sys.exit(1) # Exit the program on failure
|
||||
|
||||
def main():
|
||||
# CAN interface setup
|
||||
bus = None # Define outside the try block for proper shutdown
|
||||
try:
|
||||
bus = can.interface.Bus(channel='can0', bustype='socketcan', bitrate=1000000) # Ensure the bitrate matches the microcontroller settings
|
||||
print("CAN bus initialized.")
|
||||
|
||||
# Ensure the state is passed via arguments
|
||||
if len(sys.argv) != 2 or sys.argv[1] not in ['0', '1']:
|
||||
print("Usage: python3 script_name.py <0|1>")
|
||||
print("0 - Disable motor, 1 - Enable motor")
|
||||
sys.exit(1)
|
||||
|
||||
enable = int(sys.argv[1])
|
||||
send_motor_enable(bus, enable)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error initializing CAN bus: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
finally:
|
||||
# Ensure the bus is properly shut down
|
||||
if bus is not None:
|
||||
bus.shutdown()
|
||||
print("CAN bus shut down.")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
37
controller/fw/embed/test/python_send_angle.py
Normal file
37
controller/fw/embed/test/python_send_angle.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
import can
|
||||
import struct
|
||||
import time
|
||||
import argparse
|
||||
|
||||
# Function to send the target angle
|
||||
def send_target_angle(bus, target_angle):
|
||||
msg = can.Message()
|
||||
msg.arbitration_id = 1 # Message ID
|
||||
msg.is_extended_id = False
|
||||
msg.dlc = 5 # Message length
|
||||
msg.data = [ord('A')] + list(struct.pack('<f', target_angle)) # 'A' for the command identifier, followed by the angle in float format
|
||||
|
||||
try:
|
||||
bus.send(msg)
|
||||
print(f"Sent message with target angle: {target_angle} degrees")
|
||||
print(f"Message data: {msg.data}")
|
||||
except can.CanError:
|
||||
print("Message failed to send")
|
||||
|
||||
# Main function
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Send target angles over CAN bus.")
|
||||
parser.add_argument("--angle", type=float, required=True, help="Target angle to send over the CAN bus")
|
||||
args = parser.parse_args()
|
||||
|
||||
target_angle = args.angle
|
||||
|
||||
# CAN interface setup
|
||||
bus = can.interface.Bus(channel='can0', bustype='socketcan', bitrate=1000000) # Ensure the bitrate matches the microcontroller settings
|
||||
print("CAN bus initialized, sending target angles...")
|
||||
|
||||
# Loop to send messages
|
||||
send_target_angle(bus, target_angle)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
76
controller/fw/embed/test/python_send_velocity.py
Normal file
76
controller/fw/embed/test/python_send_velocity.py
Normal file
|
@ -0,0 +1,76 @@
|
|||
import can
|
||||
import struct
|
||||
import time
|
||||
import sys
|
||||
|
||||
# Function to send the target speed
|
||||
def send_target_speed(bus, target_speed):
|
||||
msg = can.Message()
|
||||
msg.arbitration_id = 1 # Message ID
|
||||
msg.is_extended_id = False
|
||||
msg.dlc = 5 # Message length
|
||||
msg.data = bytearray([ord('V')] + list(struct.pack('<f', target_speed))) # 'V' for the command identifier, followed by the speed in float format
|
||||
|
||||
try:
|
||||
bus.send(msg)
|
||||
print(f"Sent message with target speed: {target_speed} rad/s")
|
||||
except can.CanError:
|
||||
print("Message failed to send")
|
||||
|
||||
# Function to send the motor enable/disable command
|
||||
def send_motor_enable(bus, enable):
|
||||
"""
|
||||
Sends a command to enable or disable the motor.
|
||||
|
||||
:param bus: The CAN bus
|
||||
:param enable: 1 to enable the motor, 0 to disable it
|
||||
"""
|
||||
msg = can.Message()
|
||||
msg.arbitration_id = 1 # Message ID
|
||||
msg.is_extended_id = False
|
||||
msg.dlc = 2 # Message length (flag + 1 byte of data)
|
||||
msg.data = bytearray([ord('E'), enable]) # 'E' for the command, followed by 0 or 1
|
||||
|
||||
try:
|
||||
bus.send(msg)
|
||||
state = "enabled" if enable else "disabled"
|
||||
print(f"Sent message to {state} motor")
|
||||
except can.CanError as e:
|
||||
print(f"Message failed to send: {e}")
|
||||
sys.exit(1) # Exit the program on failure
|
||||
|
||||
send_target_speed(bus,0.0)
|
||||
|
||||
def main():
|
||||
# CAN interface setup
|
||||
bus = None # Define outside the try block for proper shutdown
|
||||
try:
|
||||
bus = can.interface.Bus(channel='COM4', bustype='slcan', bitrate=1000000) # Ensure the bitrate matches the microcontroller settings
|
||||
print("CAN bus initialized.")
|
||||
|
||||
while True:
|
||||
user_input = input("Enter target speed: ")
|
||||
if user_input.lower() == 'exit':
|
||||
print("Exiting...")
|
||||
break
|
||||
try:
|
||||
target_speed = float(user_input)
|
||||
send_target_speed(bus, target_speed)
|
||||
except ValueError:
|
||||
print("Invalid input. Please enter a valid number.")
|
||||
|
||||
# Disable motor before exiting
|
||||
send_motor_enable(bus, 0)
|
||||
print("Motor disabled.")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error initializing1 CAN bus: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
finally:
|
||||
if bus is not None:
|
||||
bus.shutdown()
|
||||
print("CAN bus shut down.")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
35
controller/fw/embed/test/send_velocity_impulses.py
Normal file
35
controller/fw/embed/test/send_velocity_impulses.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
import can
|
||||
import struct
|
||||
import time
|
||||
|
||||
# Function to send the target speed
|
||||
def send_target_speed(bus, target_speed):
|
||||
msg = can.Message()
|
||||
msg.arbitration_id = 1 # Message ID
|
||||
msg.is_extended_id = False
|
||||
msg.dlc = 5 # Message length
|
||||
msg.data = [ord('V')] + list(struct.pack('<f', target_speed)) # 'V' for the command identifier, followed by the speed in float format
|
||||
|
||||
try:
|
||||
bus.send(msg)
|
||||
print(f"Sent message with target speed: {target_speed} m/s")
|
||||
print(f"Message data: {msg.data}")
|
||||
except can.CanError:
|
||||
print("Message failed to send")
|
||||
|
||||
# Main function
|
||||
def main():
|
||||
# CAN interface setup
|
||||
bus = can.interface.Bus(channel='can0', bustype='socketcan', bitrate=1000000) # Ensure the bitrate matches the microcontroller settings
|
||||
print("CAN bus initialized, sending target speed impulses...")
|
||||
|
||||
# Send impulses of target speed from -2 to 2 m/s
|
||||
target_speeds = [-1, 1]
|
||||
|
||||
while True:
|
||||
for speed in target_speeds:
|
||||
send_target_speed(bus, speed)
|
||||
time.sleep(1) # 1-second delay between messages
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
0
firmware/test/bring_up_can.sh → controller/fw/test/bring_up_can.sh
Executable file → Normal file
0
firmware/test/bring_up_can.sh → controller/fw/test/bring_up_can.sh
Executable file → Normal file
0
firmware/test/send_can.sh → controller/fw/test/send_can.sh
Executable file → Normal file
0
firmware/test/send_can.sh → controller/fw/test/send_can.sh
Executable file → Normal file
0
firmware/test/test_driver.sh → controller/fw/test/test_driver.sh
Executable file → Normal file
0
firmware/test/test_driver.sh → controller/fw/test/test_driver.sh
Executable file → Normal file
|
@ -67,7 +67,7 @@
|
|||
39,
|
||||
40
|
||||
],
|
||||
"visible_layers": "0003ef3_80000001",
|
||||
"visible_layers": "0001010_80000000",
|
||||
"zone_display_mode": 0
|
||||
},
|
||||
"git": {
|
|
@ -74,6 +74,7 @@
|
|||
"footprint_type_mismatch": "ignore",
|
||||
"hole_clearance": "error",
|
||||
"hole_near_hole": "error",
|
||||
"holes_co_located": "warning",
|
||||
"invalid_outline": "error",
|
||||
"isolated_copper": "warning",
|
||||
"item_on_disabled_layer": "error",
|
||||
|
@ -830,7 +831,7 @@
|
|||
"plot": "",
|
||||
"pos_files": "",
|
||||
"specctra_dsn": "",
|
||||
"step": "",
|
||||
"step": "../../../../motor_controller_50mm_new.step",
|
||||
"svg": "",
|
||||
"vrml": ""
|
||||
},
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
This directory is intended for PlatformIO Test Runner and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PlatformIO Unit Testing:
|
||||
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
19
motor/README.md
Normal file
19
motor/README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
## Описание директорий и файлов
|
||||
|
||||
```[motor]
|
||||
├── parts/ # Детали моторов
|
||||
│ ├── 53mm/ # Детали для 53мм мотора с пластиковым ротором
|
||||
│ ├── 53mm_metal/ # Детали для 53мм мотора с металлическим ротором
|
||||
│ ├── 72mm/ # Детали для 72мм мотора с пластиковым ротором
|
||||
│ ├── 72mm_metal/ # Детали для 72мм мотора с металлическим ротором
|
||||
│ ├── magnetic_parts_dxf/ # Файлы для лазерной резки деталей металлических статоров
|
||||
│ └── сommon_parts/ # Детали общие для разных моторов
|
||||
├── _asm_53mm_metall_motor.SLDASM # Сборка мотора 53мм с металлическим ротором
|
||||
├── _asm_53mm_motor.SLDASM # Сборка мотора 53мм с пластиковым ротором
|
||||
├── _asm_72mm_metall_motor.SLDASM # Сборка мотора 72мм с металлическим ротором
|
||||
└── _asm_72mm_motor.SLDASM # Сборка мотора 72мм с пластиковым ротором
|
||||
```
|
||||
|
||||
Важно, что каждая сборка использует файлы из разных папок.
|
||||
Поэтому, для открытия, необходимо скачать все папки.
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
motor/_asm_72mm_metall_motor.SLDASM
Normal file
BIN
motor/_asm_72mm_metall_motor.SLDASM
Normal file
Binary file not shown.
Binary file not shown.
BIN
motor/parts/53mm/asm_motor_base_53mm.SLDASM
Normal file
BIN
motor/parts/53mm/asm_motor_base_53mm.SLDASM
Normal file
Binary file not shown.
BIN
motor/parts/53mm/asm_plastic_stator_53mm.SLDASM
Normal file
BIN
motor/parts/53mm/asm_plastic_stator_53mm.SLDASM
Normal file
Binary file not shown.
BIN
motor/parts/53mm/asm_rotor_53mm.SLDASM
Normal file
BIN
motor/parts/53mm/asm_rotor_53mm.SLDASM
Normal file
Binary file not shown.
BIN
motor/parts/53mm/motor_base_53mm.SLDPRT
Normal file
BIN
motor/parts/53mm/motor_base_53mm.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/53mm/motor_fixator_23_08_07.SLDPRT
Normal file
BIN
motor/parts/53mm/motor_fixator_23_08_07.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/53mm/plastic_stator_53mm.SLDPRT
Normal file
BIN
motor/parts/53mm/plastic_stator_53mm.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/53mm/rotor_53mm.SLDPRT
Normal file
BIN
motor/parts/53mm/rotor_53mm.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/53mm_metal/12p_stator magnetic plate.SLDPRT
Normal file
BIN
motor/parts/53mm_metal/12p_stator magnetic plate.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/53mm_metal/ToSort/fixer231205.SLDPRT
Normal file
BIN
motor/parts/53mm_metal/ToSort/fixer231205.SLDPRT
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
motor/parts/53mm_metal/asm_metal_stator_53mm.SLDASM
Normal file
BIN
motor/parts/53mm_metal/asm_metal_stator_53mm.SLDASM
Normal file
Binary file not shown.
BIN
motor/parts/53mm_metal/plastic_stator_core_53mm.SLDPRT
Normal file
BIN
motor/parts/53mm_metal/plastic_stator_core_53mm.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/72mm/BOM_18.01.25.xlsx
Normal file
BIN
motor/parts/72mm/BOM_18.01.25.xlsx
Normal file
Binary file not shown.
BIN
motor/parts/72mm/asm_motor_base_72mm.SLDASM
Normal file
BIN
motor/parts/72mm/asm_motor_base_72mm.SLDASM
Normal file
Binary file not shown.
Binary file not shown.
BIN
motor/parts/72mm/asm_plastic_stator_72mm.SLDASM
Normal file
BIN
motor/parts/72mm/asm_plastic_stator_72mm.SLDASM
Normal file
Binary file not shown.
BIN
motor/parts/72mm/asm_rotor_72mm.SLDASM
Normal file
BIN
motor/parts/72mm/asm_rotor_72mm.SLDASM
Normal file
Binary file not shown.
BIN
motor/parts/72mm/holder_var3_221003.SLDPRT
Normal file
BIN
motor/parts/72mm/holder_var3_221003.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/72mm/holder_var3_221003_tmp.SLDPRT
Normal file
BIN
motor/parts/72mm/holder_var3_221003_tmp.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/72mm/main_fixer_230808.SLDPRT
Normal file
BIN
motor/parts/72mm/main_fixer_230808.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/72mm/main_fixer_230808.STL
Normal file
BIN
motor/parts/72mm/main_fixer_230808.STL
Normal file
Binary file not shown.
BIN
motor/parts/72mm/motor_base_72mm.SLDPRT
Normal file
BIN
motor/parts/72mm/motor_base_72mm.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/72mm/motor_base_72mm.STL
Normal file
BIN
motor/parts/72mm/motor_base_72mm.STL
Normal file
Binary file not shown.
BIN
motor/parts/72mm/new_plastic_stator_72mm.SLDPRT
Normal file
BIN
motor/parts/72mm/new_plastic_stator_72mm.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/72mm/new_plastic_stator_72mm.STL
Normal file
BIN
motor/parts/72mm/new_plastic_stator_72mm.STL
Normal file
Binary file not shown.
BIN
motor/parts/72mm/plastic_stator_72mm.SLDPRT
Normal file
BIN
motor/parts/72mm/plastic_stator_72mm.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/72mm/rotor_72mm.SLDPRT
Normal file
BIN
motor/parts/72mm/rotor_72mm.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/72mm/rotor_72mm_plus.SLDPRT
Normal file
BIN
motor/parts/72mm/rotor_72mm_plus.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/72mm/rotor_72mm_plus.STL
Normal file
BIN
motor/parts/72mm/rotor_72mm_plus.STL
Normal file
Binary file not shown.
BIN
motor/parts/72mm/rotor_72mm_plus_old.SLDPRT
Normal file
BIN
motor/parts/72mm/rotor_72mm_plus_old.SLDPRT
Normal file
Binary file not shown.
Binary file not shown.
BIN
motor/parts/72mm_metal/24p_stator magnetic plate.SLDPRT
Normal file
BIN
motor/parts/72mm_metal/24p_stator magnetic plate.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/72mm_metal/asm_metal_stator_72mm.SLDASM
Normal file
BIN
motor/parts/72mm_metal/asm_metal_stator_72mm.SLDASM
Normal file
Binary file not shown.
BIN
motor/parts/72mm_metal/plastic_stator_core_72mm_bottom.SLDPRT
Normal file
BIN
motor/parts/72mm_metal/plastic_stator_core_72mm_bottom.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/72mm_metal/plastic_stator_core_72mm_top.SLDPRT
Normal file
BIN
motor/parts/72mm_metal/plastic_stator_core_72mm_top.SLDPRT
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load diff
Binary file not shown.
BIN
motor/parts/сommon_parts/mag10x6x2_211208.SLDPRT
Normal file
BIN
motor/parts/сommon_parts/mag10x6x2_211208.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/сommon_parts/motor_controller_50mm.SLDASM
Normal file
BIN
motor/parts/сommon_parts/motor_controller_50mm.SLDASM
Normal file
Binary file not shown.
126445
motor/parts/сommon_parts/motor_controller_50mm.step
Normal file
126445
motor/parts/сommon_parts/motor_controller_50mm.step
Normal file
File diff suppressed because it is too large
Load diff
BIN
motor/parts/сommon_parts/round_magnet_6x4.SLDPRT
Normal file
BIN
motor/parts/сommon_parts/round_magnet_6x4.SLDPRT
Normal file
Binary file not shown.
BIN
motor/parts/сommon_parts/screw_m3x10mm.SLDPRT
Normal file
BIN
motor/parts/сommon_parts/screw_m3x10mm.SLDPRT
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue