Solar panel
Loading...
Searching...
No Matches
measure.c File Reference
#include <xc.h>
#include "measure.h"
#include "mcc_generated_files/mcc.h"

Go to the source code of this file.

Macros

#define VOLTAGE_CHANNEL   0x5
 
#define CURRENT_CHANNEL   0x6
 
#define ADC_RESOLUTION   (1024 - 1)
 
#define ADC_REFH   3300
 
#define GAIN   66
 
#define RESISTOR   3
 
#define AVERAGE_SAMPLES   8
 

Functions

void adc_init (void)
 
uint16_t measure_voltage ()
 
uint16_t measure_current (uint16_t offset)
 

Macro Definition Documentation

◆ ADC_REFH

#define ADC_REFH   3300

Definition at line 9 of file measure.c.

◆ ADC_RESOLUTION

#define ADC_RESOLUTION   (1024 - 1)

Definition at line 8 of file measure.c.

◆ AVERAGE_SAMPLES

#define AVERAGE_SAMPLES   8

Definition at line 14 of file measure.c.

◆ CURRENT_CHANNEL

#define CURRENT_CHANNEL   0x6

Definition at line 7 of file measure.c.

◆ GAIN

#define GAIN   66

Definition at line 10 of file measure.c.

◆ RESISTOR

#define RESISTOR   3

Definition at line 11 of file measure.c.

◆ VOLTAGE_CHANNEL

#define VOLTAGE_CHANNEL   0x5

Definition at line 6 of file measure.c.

Function Documentation

◆ adc_init()

void adc_init ( void  )

Initialize ADC and pins for measuring current and voltage

Definition at line 16 of file measure.c.

◆ measure_current()

uint16_t measure_current ( uint16_t  offset)

Measure the current on the solar panel. This function is expected to do some filtering

Parameters
offset: the offset as measured by measure_current_offset
Returns
the current in microamperes

Definition at line 49 of file measure.c.

◆ measure_voltage()

uint16_t measure_voltage ( void  )

Measure the voltage on the channel for the current. This function is expected to do some filtering.

Returns
The offset

Definition at line 37 of file measure.c.