Page MenuHomec4science

strain_gauge.c
No OneTemporary

File Metadata

Created
Sun, May 19, 05:52

strain_gauge.c

#include "strain_gauge.h"
#include "dac.h"
#include "../lib/basic_filter.h"
AdcChannel sg_channel;
bfilt_BasicFilter sg_filt;
/**
* @brief Initialize the strain gauge driver.
* @param channel: the ADC channel the strain gauge is wired to (0 or 1).
*/
void sg_Init(AdcChannel channel)
{
sg_channel = channel;
dac_SetVoltage2(2.4f);
bfilt_Init(&sg_filt, 0.1f, 0.0f);
}
/**
* @brief Return the measured force on the paddle.
* @retval The force applied to the top of the paddle [N].
* @warning this function is not implemented yet, and returns actually the raw
* voltage from the sensor, instead of the ready-to-use force.
*/
float32_t sg_Get(void)
{
float32_t voltage = adc_GetChannelVoltage(sg_channel, ADC_SCALE_0_033_V);
// TODO: the voltage to angle conversion is not implemented yet.
return bfilt_Step(&sg_filt, voltage);
}

Event Timeline