main_ubi_sdk v 0.1.3
This is UBI4 documentation
motor_controller_h_bridge.h
Go to the documentation of this file.
1/*
2 * motor_controller_h_bridge.h
3 *
4 * Created on: Mar 5, 2025
5 * Author: Andrey Ovodov
6 */
7
8#ifndef MOTORS_CONTROLLERS_H_BRIDGE_MOTOR_CONTROLLER_H_BRIDGE_H_
9#define MOTORS_CONTROLLERS_H_BRIDGE_MOTOR_CONTROLLER_H_BRIDGE_H_
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#include "../motor_controller.h"
17#include "stdbool.h"
18
19
20#define STARTUP_BURST_LENGHT_MS 2
21#define MAX_MOT_ACTIVE_TIME 3000
22#define ENCODER_POS_MAX 100
23#define ENCODER_ACCURACY_MULTIPLIER 100
24#define ENCODER_PROTECT_DELTA 2
25
26#define ADC_TO_CURRENT_UA_COEF 336 // MotCurrent_uA = (adc_value * adc_max_V* 1000000) / (adc_max_val * op_amp_gain * R_cursens)
27
28
33
34
40
41
42
43
44
51
52typedef struct
53{
54
55 uint32_t calib_steps;
56 uint16_t calib_current; //холостой ход
57 uint8_t calib_status; // 1
58
59 uint32_t current_limit_ua; //
61
63
66
67}__attribute__((__packed__))motor_controller_h_bridge_settings_t;
68
84
107
109
110
111/*
112void DriveInit_HBIE(hbie_drive_init_struct* init_str, hbie_drive_struct** drive_obj);
113
114motor_state_enum GetDriveState_HBIE(hbie_drive_struct* drive);
115
116void DriveUpdateCurrentValue_HBIE(hbie_drive_struct* drive, int32_t newuA);
117void DriveEncodersAddStep_HBIE(hbie_drive_struct* drive);
118void DriveTimerAddStep_HBIE(hbie_drive_struct* drive);
119
120void DriveMoveToPos_HBIE(hbie_drive_struct* drive, uint8_t pos, uint8_t start_delay, uint8_t power, uint8_t speed);
121void MoveFingerStart(hbie_drive_struct* drive);
122void DriveMoveForward_HBIE(hbie_drive_struct* drive, uint32_t speed);
123void DriveMoveRevers_HBIE(hbie_drive_struct* drive, uint32_t speed);
124void DriveStop_HBIE(hbie_drive_struct* drive, mot_stop_reason_enum reason);
125
126void DriveCalibrateStart_HBIE(hbie_drive_struct* drive, void (*finish_callback)(void* drive));
127void DriveCalibrate_HBIE(hbie_drive_struct* drive);
128void DriveExec_HBIE(hbie_drive_struct* drive);
129void FingerExec(hbie_drive_struct* drive);
130void FingerCalibrateStart(hbie_drive_struct *drive,
131 void (*finish_callback)(void *drive));
132void FingerCalibrationFinish(hbie_drive_struct* drive);
133*/
134
135#ifdef __cplusplus
136}
137#endif
138
139#endif /* MOTORS_CONTROLLERS_H_BRIDGE_MOTOR_CONTROLLER_H_BRIDGE_H_ */
void(* MotorSelfFuncWithReason_t)(void *self, uint8_t reason)
Definition motor_controller.h:23
void(* MotorSelfFunc_t)(void *self)
Definition motor_controller.h:19
drive_calibrating_state_enum
Definition motor_controller_h_bridge.h:35
@ FCS_CALIBRATING_OPEN
Definition motor_controller_h_bridge.h:38
@ FCS_FIRST_OPEN
Definition motor_controller_h_bridge.h:36
@ FCS_CALIBRATING_CLOSE
Definition motor_controller_h_bridge.h:37
mot_start_reason_enum
Definition motor_controller_h_bridge.h:29
@ MOT_SERVICE_START
Definition motor_controller_h_bridge.h:31
@ MOT_MANUAL_START
Definition motor_controller_h_bridge.h:30
bool MotorControllerHBridgeInit(motor_controller_h_bridge_t *self, motor_controller_base_init_t *init, motor_driver_h_bridge_pwm_t *driver)
Definition motor_controller_h_bridge.c:431
drive_mode_enum
Definition motor_controller_h_bridge.h:45
@ FME_ERROR
Definition motor_controller_h_bridge.h:48
@ FME_NORMAL
Definition motor_controller_h_bridge.h:46
@ FME_OPTIC_CONTORL
Definition motor_controller_h_bridge.h:49
@ FME_CALIBRATING
Definition motor_controller_h_bridge.h:47
Definition motor_controller.h:57
Definition motor_controller.h:93
Definition motor_controller_h_bridge.h:70
uint16_t small_current_counter
Definition motor_controller_h_bridge.h:72
drive_calibrating_state_enum calib_state
Definition motor_controller_h_bridge.h:71
uint32_t close_encoder_counter
Definition motor_controller_h_bridge.h:75
uint16_t current_buffer_counter
Definition motor_controller_h_bridge.h:78
MotorSelfFunc_t CalibFinishCallback
Definition motor_controller_h_bridge.h:81
int32_t current_buffer[1000]
Definition motor_controller_h_bridge.h:77
uint32_t open_encoder_counter
Definition motor_controller_h_bridge.h:74
uint16_t no_current_counter
Definition motor_controller_h_bridge.h:73
Definition motor_controller_h_bridge.h:53
uint8_t current_limit_percent
Definition motor_controller_h_bridge.h:60
uint16_t calib_current
Definition motor_controller_h_bridge.h:56
uint32_t motor_driver_cycles_1ms
Definition motor_controller_h_bridge.h:65
uint8_t calib_status
Definition motor_controller_h_bridge.h:57
uint32_t calib_steps
Definition motor_controller_h_bridge.h:55
uint16_t overcurrent_counter_max
Definition motor_controller_h_bridge.h:62
uint32_t motor_cycles_1ms
Definition motor_controller_h_bridge.h:64
uint32_t current_limit_ua
Definition motor_controller_h_bridge.h:59
Definition motor_controller_h_bridge.h:86
motor_controller_h_bridge_settings_t * settings
Definition motor_controller_h_bridge.h:89
drive_mode_enum mode
Definition motor_controller_h_bridge.h:88
MotorSelfFuncWithReason_t StopCallback
Definition motor_controller_h_bridge.h:104
uint32_t motor_driver_cycles_1ms
Definition motor_controller_h_bridge.h:95
int brake_temer_instance
Definition motor_controller_h_bridge.h:100
int start_delay_timer_instance
Definition motor_controller_h_bridge.h:101
int startup_timer_instance
Definition motor_controller_h_bridge.h:98
motor_controller_h_bridge_calibrating_struct_t * calibrating_struct
Definition motor_controller_h_bridge.h:91
int timeout_timer_instance
Definition motor_controller_h_bridge.h:99
uint32_t motor_cycles_1ms
Definition motor_controller_h_bridge.h:94
motor_controller_base_t Base
Definition motor_controller_h_bridge.h:87
Definition motor_driver_h_bridge_pwm.h:42