Skip to content

Commit

Permalink
[subsystems/electrical] fix conversion of vsupply to decivolts
Browse files Browse the repository at this point in the history
* Should now work correctly with <define name="VoltageOfAdc(adc)" value ="(VOLTAGE_ADC_A * adc + VOLTAGE_ADC_B )"/> with VOLTAGE_ADC_B in Volts
* Also fix VoltageOfAdc to DefaultVoltageOfAdc in board header for tiny_2.0
  • Loading branch information
flixr committed Jan 8, 2013
1 parent 67e9833 commit d266565
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions sw/airborne/boards/tiny_2.0.h
Expand Up @@ -150,9 +150,7 @@
#endif


#ifndef VoltageOfAdc
#define VoltageOfAdc(adc) (0.01787109375*adc)
#endif
#define DefaultVoltageOfAdc(adc) (0.01787109375*adc)

#define SPI_SELECT_SLAVE0_PORT 0
#define SPI_SELECT_SLAVE0_PIN 20
Expand Down
2 changes: 1 addition & 1 deletion sw/airborne/subsystems/electrical.c
Expand Up @@ -52,7 +52,7 @@ void electrical_init(void) {

void electrical_periodic(void) {
#ifndef SITL
electrical.vsupply = VoltageOfAdc((10*(electrical_priv.vsupply_adc_buf.sum/electrical_priv.vsupply_adc_buf.av_nb_sample)));
electrical.vsupply = 10 * VoltageOfAdc(electrical_priv.vsupply_adc_buf.sum/electrical_priv.vsupply_adc_buf.av_nb_sample));
#endif

#ifdef ADC_CHANNEL_CURRENT
Expand Down

0 comments on commit d266565

Please sign in to comment.