Reading ADC

Hi,

I´m trying to read my ADC values. I powered de DK with USB and trying to read sensormeasurements, but I can´t see the right values. 

I´m trying to read with the 12-bit ADC. The sensor gives 4-20mA and I measure over a resistor of 150 ohm. 

So the calculation = m_sample * 3.0 / 4096 = measured volts

Is this the right way?

val0 = m_sample * 3.0 / 4096;
printf("%.2f", m_sample);
sprintf((char*)data0, "%.2f", val0);
memcpy(&data_array[0], &val0, sizeof(val0));

This is a snippet of my program. After this I send the values with ble_nus_send.

Is this right? Can it be that I did something wrong, so blowed up the pin. Because a month ago the measurement were right. 

Parents
  • Hi,

    Which SDK are you using?

    Which analog input are you using, and how is the resistor that you measure over connected? Are you sure that you have configured the pin that the external circuit is connected to? Often the analog input numbers (AIN0-7) are confused with the Arduino analog mapping on the DK (A0-A5). You should follow the Pin assignments documentation.

    The formula for Digital output is given in the SAADC peripheral specifications. This depends on the configuration of the SAADC and channel. What values are you measuring, and what are the expected values?

    Best regards,
    Jørgen

Reply
  • Hi,

    Which SDK are you using?

    Which analog input are you using, and how is the resistor that you measure over connected? Are you sure that you have configured the pin that the external circuit is connected to? Often the analog input numbers (AIN0-7) are confused with the Arduino analog mapping on the DK (A0-A5). You should follow the Pin assignments documentation.

    The formula for Digital output is given in the SAADC peripheral specifications. This depends on the configuration of the SAADC and channel. What values are you measuring, and what are the expected values?

    Best regards,
    Jørgen

Children
Related