User Tools

Site Tools




int getSadc (u8 adcId, int * array)

adcId : The ID of the AD Input Module (0 ~ 9)
array: A pointer to an array of 6 integers to store the values of each channel
returns 0 if successful, -1 if unsuccessful.

Reads the digitally converted values (all 6 channels) from Analog Input module adcId, and stores the values in array. getSadc is for the RS-SADIN6 module. The usage differs slightly getAdc and getHadc, as all channels can be read with one function call.

int sAdcData[6];
aj = getSadc(0,sAdcData);

If reading fails, whether due to a wrong module ID or other factors, -1 is returned. If reading is successful, 0 is returned.

#include "moacon500.h"
void cmain(void)
    int sAdcData[6];
    u16 aj;
    while (1) {
        aj = getSadc(0,sAdcData);
        printf("sadin ch1 = %x \r\n",sAdcData[0]);
        printf("sadin ch2 = %x \r\n",sAdcData[1]);
        printf("sadin ch3 = %x \r\n",sAdcData[2]);
        printf("sadin ch4 = %x \r\n",sAdcData[3]);
        printf("sadin ch5 = %x \r\n",sAdcData[4]);
        printf("sadin ch6 = %x \r\n",sAdcData[5]);

Data is copied to array in increasing order from channel 1 to channel 6. In the example above, channel 1’s value is stored in sAdcData[0] and channel 6’s value is stored in sAdcData[5].

go MOACON home

moacon/getsadc/index.txt · Last modified: 2016/04/14 11:07 (external edit)