Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102667597
escon_drive.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
Sun, Feb 23, 01:32
Size
957 B
Mime Type
text/x-c
Expires
Tue, Feb 25, 01:32 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24389405
Attached To
R2671 HHRI-software
escon_drive.c
View Options
#include "escon_drive.h"
#include "dac.h"
#include "../lib/utils.h"
// Motors parameters for the maxon EC-max 30mm 24V.
#define MOTOR_NOMINAL_CURRENT 2.66f // [A].
#define MOTOR_TORQUE_CONSTANT 0.0243f // [N.m/A].
#define ESCON_CURRENT_FACTOR (9.0f/MOTOR_NOMINAL_CURRENT) // [V/A].
/**
* @brief Intializes the driver.
* Initializes the driver, and set the motor torque to zero.
*/
void esc_Init(void)
{
// Set the motor torque to zero.
dac_SetVoltage1(0.0f);
}
/**
* @brief Sets the motor torque.
* @param torque the torque to set [N.m]. If larger than the nominal torque, it
* will be saturated to the nominal torque.
*/
void esc_SetTorque(float32_t torque)
{
// Compute the motor current.
float32_t motorCurrent = torque / MOTOR_TORQUE_CONSTANT; // [A].
utils_SaturateF(&motorCurrent,
-MOTOR_NOMINAL_CURRENT, MOTOR_NOMINAL_CURRENT);
// Compute the equivalent voltage.
dac_SetVoltage1(motorCurrent * ESCON_CURRENT_FACTOR);
}
Event Timeline
Log In to Comment