Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Privacy
Imprint
Contact
Login methods
Sign in
Toggle navigation
Menu
Open sidebar
Fabian Mink
dcmotor_stm32f767zi_drv8871
Commits
d61a0e8e
Commit
d61a0e8e
authored
Jan 19, 2022
by
Fabian Mink
Browse files
SYRT WS21/22 version (developed during lecture on 2022-01-18)
parent
91e847db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Core/Src/main.c
View file @
d61a0e8e
...
...
@@ -70,6 +70,7 @@ iir1_filter_t voltage_iir1;
float
speed_raw
;
float
speed_filt
;
static
uint16_t
datarec_divcnt
=
0
;
pictrl_t
speed_pi
;
/* USER CODE END PV */
...
...
@@ -680,6 +681,10 @@ void hw_init(void){
filter_iir1_init
(
&
speed_iir1
,
20
.
0
f
,
0
.
0625
f
);
filter_iir1_init
(
&
voltage_iir1
,
10
.
0
f
,
0
.
0625
f
);
control_pictrl_init
(
&
speed_pi
,
0
.
61
,
84
,
62.5e-3
);
speed_pi
.
max
=
20
.
0
f
;
speed_pi
.
min
=
-
20
.
0
f
;
//Encoder
LL_TIM_EnableCounter
(
TIM3
);
...
...
@@ -753,7 +758,7 @@ void control_sm(void){
}
}
//Call by 16kHz (every
2nd
PWM counter update due to repetition counter)
//Call by 16kHz (every
4th
PWM counter update due to repetition counter)
void
main_pwm_ctrl
(
void
){
LL_GPIO_SetOutputPin
(
DebugPin0_GPIO_Port
,
DebugPin0_Pin
);
...
...
@@ -780,7 +785,21 @@ void main_pwm_ctrl(void){
speed_filt
=
filter_iir1
(
&
speed_iir1
,
speed_raw
);
// *** Control ***
uref
=
0
.
0
f
;
//uref = val_para_uref[0];
//if(val_para_mode == 1){
// uref = val_para_uref[1];
//}
float
speed_ref
;
speed_ref
=
val_para_nref
[
0
];
if
(
val_para_mode
==
1
){
speed_ref
=
val_para_nref
[
1
];
}
uref
=
control_pictrl2
(
&
speed_pi
,
speed_ref
,
speed_filt
);
// *** End of Control ***
//*** Voltage output / PWM ***
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment