M328P and MUX (again!)

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How do the PORTB constants 0x09 and 0x11 correspond to the schematic? It appears that you're manipulating bits that aren't connected. And what do 1,2,3 mean on the AVR pins? PORTB is not connected to pins 1,2,3 on any package.

Also BTW, you don't need to do e.g.

PORTB = (0xFF) & (0x09);

Just

PORTB = 0x09;

will do the same thing.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, kk6gm.

Sorry for the incomplete info. I need Portb0 always high to select another mux. I also want to select PORTB3 when count = 17 which is why I have 0x09.

0x11 selects PORTB4 and also PORTB0 which I always want high.

I have also tried PORTB = 0x09 and it didn't work. Also measuring voltages at the port outputs matches the statements so that checked out ok That is the reason I have ruled out the PORTS. My main thing is I want to complete the path through GND which I don't want connected to my AVR gnd unless I select the specific port output.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok it worked. I had the wrong physical portB connection on my breadboard.
Thanks.