Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93363829
mdv_internal.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Nov 28, 05:27
Size
1 KB
Mime Type
text/x-c
Expires
Sat, Nov 30, 05:27 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
22591817
Attached To
R6619 Oncilla Motordriver Firmware
mdv_internal.c
View Options
#include "mdv_internal.h"
#include "mdv_control_modes.h"
mdv_ctrl_fptr
mdv_ctrl
[
MDV_NUMBER_OF_CONTROL_MODE
]
=
{
{
&
mdv_null_process
,
&
mdv_coast_init
},
{
&
mdv_null_process
,
&
mdv_brake_init
},
{
&
mdv_position_process
,
&
mdv_position_init
},
{
&
mdv_velocity_process
,
&
mdv_velocity_init
},
{
&
mdv_smooth_position_process
,
&
mdv_smooth_position_init
},
{
&
mdv_null_process
,
&
mdv_coast_init
},
{
&
mdv_runtime_calibration_process
,
&
mdv_runtime_calibration_init
},
{
&
mdv_sine_generator_process
,
&
mdv_sine_generator_init
}
};
void
mdv_null_process
(
motordriver
*
mdv
){
pwm_set_value
(
mdv
->
pins
.
speed
,
MAX_PWM
/
2
);
pwm_set_value
(
mdv
->
pins
.
torque
,
MAX_PWM
/
2
);
}
void
mdv_cleanup
(
motordriver
*
mdv
)
{
mdv
->
goal_pos
=
mdv
->
pos_cnt
;
mdv
->
moving_pos
=
mdv
->
pos_cnt
;
mdv
->
goal_speed
=
0
;
mdv
->
moving_speed
=
0
;
mdv
->
output_trq
=
0
;
mdv
->
prev_p_error
=
0
;
mdv
->
i_error
=
0
;
mdv_clear_flag
(
mdv
,
MDV_F_MOVING_ENABLE
|
MDV_F_UPDATE_I_ERROR
|
MDV_F_NEW_POSITION_AVAILABLE
|
MDV_F_NEW_SPEED_AVAILABLE
);
}
void
mdv_set_pos_count
(
motordriver
*
mdv
,
long
pos
){
IEC0bits
.
T1IE
=
0
;
mdv
->
previous_cnt
=
pos
;
mdv
->
pos_cnt
=
pos
;
*
(
mdv
->
pos_counter
)
=
pos
;
IEC0bits
.
T1IE
=
1
;
}
void
mdv_set_control_mode_private
(
motordriver
*
mdv
,
mdv_control_mode
c
){
mdv_cleanup
(
mdv
);
mdv
->
sc
.
mode
=
c
;
(
*
(
mdv_ctrl
[
c
].
init
))(
mdv
);
}
Event Timeline
Log In to Comment