Hi Freaks,
I have a 74HC4051 mux connected to an M328P.
I am trying to measure the diode drop of a DUT as shown in the attached figure. The MUX select lines are connected to the M328P pins.
The pull up sets the current through the DUT pin that will be selected by the MUX.
Here is part of my code where the selection takes place:
ISR(TIMER1_COMPA_vect) { count++; if (count == 17) { ADMUX &= 0xF8; ADMUX |= (new_channel & 0x07); DIDR0 = (1 << ADC4D); ADCSRA |= (1 << ADEN); PORTB = (0xFF) & (0x09); } if (count == 18) { ADMUX &= 0xF8; ADMUX |= (new_channel & 0x07); DIDR0 = (1 << ADC4D); ADCSRA |= (1 << ADEN); PORTB = (0xFF) & (0x11); }
I read the ADC values in main. The MUX selects which DUT pin to measure through the POS.
Problem is when count = 17 I am getting about 2.1V which is about right. (the default value is 5V which is when there is no connection i.e. open)
But when count = 18, I am getting an open. I tried swapping DUT pins and count = 17 always works but count = 18 and onwards do not work ie. they always read open. So I have ruled out the DUT as a problem.
What could be the problem? Is there an alternative way of doing this?
Could this be my PORTB statements? I did measure the voltage on the MUX output pins and the right pin is getting selected at the right time.
Could this be a ground issue? I want to keep the DUT GND and the AVR GND isolated and make a connection only through the MUX. Maybe this is my problem?
Thanks.