Hello,
my name is Niklas and I just have a problem with the analog measurement of a value. I use a PIC 16F1827 and program in MCC. I would like to perform a current measurement via an ACS712.
My first problem is that I need to measure about 300 mA. Therefore I have to change Vref+ and Vref- of the ADC to get better values. I put Vref- on an external pin that I supply with 2 V.
I supply Vref+ with the Fixed Voltage Reference, so that I don't have to occupy another pin.
I am not sure if my settings are correct.
My second problem is the code of the analog measurement. I have now written this code:
So I can call one of my analog pins at any time. Can anyone tell me if this code is correct?
I attached 2 files.
I would appreciate any help you can give me. Thanks
Moderators note : please use code tags for pices of code
my name is Niklas and I just have a problem with the analog measurement of a value. I use a PIC 16F1827 and program in MCC. I would like to perform a current measurement via an ACS712.
My first problem is that I need to measure about 300 mA. Therefore I have to change Vref+ and Vref- of the ADC to get better values. I put Vref- on an external pin that I supply with 2 V.
I supply Vref+ with the Fixed Voltage Reference, so that I don't have to occupy another pin.
I am not sure if my settings are correct.
My second problem is the code of the analog measurement. I have now written this code:
C:
uint8_t Sensor_Messung(adc_channel_t addr_pin){
ADC_SelectChannel(addr_pin);
ADC_IsConversionDone();
return ADC_GetConversionResult();
}
void main(void)
{
// initialize the device
SYSTEM_Initialize();
while (1)
{
if(Sensor_Messung(ACS3) >= 400)LED1 = HIGH; // Just an example
else LED2 = HIGH;
}
}
I attached 2 files.
I would appreciate any help you can give me. Thanks
Moderators note : please use code tags for pices of code
Attachments
-
10 KB Views: 2
-
6.9 KB Views: 2