Multichannel Ohmmeter

Hi,

How can I make a multichannel ohmmeter?

Thanks!

Did you get it working for one yet as in your other thread?

Hi,

Yeah, I did get it to work for one....however, was kind of confused about how to do it for multiple...I have written code for it and even have a setup....but it's values don't change when I try it with a known resistance

shisi192837: Yeah, I did get it to work for one....however, was kind of confused about how to do it for multiple

Just replicate what you already did, but on other analog pins, change any variable names so as not to clash. So if you had (say) a variable called theResistance now you'll have a bunch like theResistance1 and theResistance2 or whatever.

But how would I account for the different ports like the pin modes?

shisi192837: But how would I account for the different ports like the pin modes?

Not sure what you mean.

Post the code you have for your working one channel meter.

Here is the code I have right now for the multi channel resistance meter…I am attaching this code since I really need help on revising this one not the single channel code…thanks!

// number of analog samples to take per reading, per channel
#define NUM_SAMPLES 2
// voltage divider calibration values
#define DIV_1 2
#define DIV_2 3

// ADC reference voltage / calibration value
#define V_REF 4.991

int sum[2] = {0}; // sums of samples taken
unsigned char sample_count = 0; // current sample number
float voltage[2] = {0.0}; // calculated voltages
char l_cnt = 0; // used in ‘for’ loops
float R1 = 1;
float buffer = 0;
float Vout = 0;
int analogPin = 0;
float resistance[2] = {0.0};

void setup()
{
Serial.begin(9600);
}

void loop()
{
// take a number of analog samples and add them up
while (sample_count < NUM_SAMPLES) {
// sample each channel A2 to A5
for (l_cnt = 0; l_cnt <= 1; l_cnt++) {
sum[l_cnt] += analogRead(A0 + l_cnt);
}
sample_count++;
delay(10);
}
// calculate the voltage for each channel
for (l_cnt = 0; l_cnt < 2; l_cnt++) {
voltage[l_cnt] = ((float)sum[l_cnt] / (float)NUM_SAMPLES * V_REF) / 1024.0;
buffer = (V_REF / voltage[l_cnt]) - 1;
resistance[l_cnt] = R1 * buffer;
}
// display voltages on LCD
// each voltage is multiplied by the resistor network
// division factor to calculate the actual voltage
// voltage 1 - A (pin A2)
Serial.print("A Voltage: ");
Serial.println(voltage[0] * DIV_1, 1);
delay(1000);
// voltage 2 - B (pin A3)
Serial.print("B Voltage: ");
Serial.println(voltage[1] * DIV_2, 1);
delay(1000);
Serial.print("A R2: ");
Serial.println(resistance[0]);
delay(1000);
Serial.print("B R2: ");
Serial.println(resistance[1]);

// reset count and sums
sample_count = 0;
for (l_cnt = 0; l_cnt < 2; l_cnt++) {
sum[l_cnt] = 0;
}

delay(1000);
}