int getHadc (u8 adcId, u8 adcCh)
adcId : The ID of the AD Input Module (0 ~ 9) |
adcCh: The channel on the AD Input Module (1 ~ 4) |
returns the digitally converted value read from the ADC |
Gets the digitally converted value from analog-to-digital converter (ADC) on AD Input Module adcId, channel adcCh. getHadc is for the RS-HADIN4 module. The module ID, adcId, is set using the rotary switch on the module's face.
Dipswitch #2 | Return Value | Exceptions |
---|---|---|
ON (0 ~ 10V) | Value between 0 and 10,00 | Open Circuit: 3100 ~ 3200 |
OFF (1 ~ 5V) | Value between 0 and 10,000 | Below 0.8V: 111,111 Above 5.2V: 555,555 Open Circuit: 111,111 |
#include "moacon500.h" void cmain(void) { int voltage; while(1) //Run forever { voltage = getAdc(0, 1); //Read from the ADC (Module 0, Channel 1) printf("%d\r\n", voltage); //Print value to the debug console delay(100); //Wait for 100ms } }