Problem with PIC16F887 and a multiplexer

Post
zrnjan
New Member
2012/12/25 17:48:53
Hi Guys!
 
I am having problem with a PIC16F887 and a multiplexer. I can`t make the MUX to work. I set up the PORTB pins to be output pins and connect them to the 8  input pins of the MUX. I set up the pins on port D to be also output and connect them to the digital control lines of the MUX, i.e. connect three pins of the PORTD to the S0, S1, S2 pins of the mux and I change the values of the PORTD pins in software. So, I want to control which channel of the MUX is active via PORTD pins. When all s0,s1 and s2 are high, I want the PORTB,7 to be routed to the output pins of the MUX. But it doesn`t work. It draws too much current, my power source is getting very warm in a short time. I`ve checked the functionality of the 16F887 and it works fine. 
 
My question is: Am I forgetting something to do? Maybe some pull-ups, some resistors somewhere to be put in the circuit, maybe in series, I don`t know what could be done, I thought that using MUX is pretty straight forward... Although it is very very simple circuit: PORTB pin voltage waits in front of the MUX, the MUX is controlled via the three pins of the PORTD, and I am waiting for the voltage at the common output pin. 
 
Question No:2. Should the two ICs have one common power source? I`ve tried with two different, nothing happened. I put the GND pins of both ICs in one same spot, I put Vcc pins in one same spot. But it doesn`t want to work. I need the MUX to make an ADC conversion of the voltage coming out of 7 sensors, photodiodes. I don`t want to use the built-in 7 different ADC channels, since I get too much cross-talk, i.e. when one sensor is being sampled, the other one shows the behavior of the previous sensor. I`ve tried to solve this issue with different amounts of time delay but it doesn`t work, everytime I change a channel, regardless of the time delay for the A/D, it won`t work. That is why I am hoping that the problem could be solved by using MUX and only one AD channel. But, as you can see, the MUX doesn`t want to work, either. I connect it pretty straight forward - I get one pin, connect it to the pin of the MUX and like that all the way, but something prevents it from functioning.
 
HELP!
 
Cheers! 
mrp
Super Member
Re:Problem with PIC16F887 and a multiplexer 2012/12/25 20:13:07
What is the part number of the multiplexer you are using?
 
I think you should be able to solve the "cross-talk" problem with the built-in ADC.  Is it possible that your acquisition delay was too small, or that maybe you weren't waiting for the aquisition time *after* changing the analog input channel?  Maybe you could show your code that was having "cross-talk" problems?
 
zrnjan
New Member
Re:Problem with PIC16F887 and a multiplexer 2012/12/25 20:46:13
Problem solved. It turned out that the MUX, (which is labeled as 74HC4051), is in packaging that`s mind-confusing: there are two pin 1 indexes. The only difference between them is in that that one of them has small line across. Still, the carved out portion of the package was clearly visible. But I somehow thought that pin 1 is where the pin-1 -index-without-the-line was, and the carved out portion was not near to what I thought that was the pin 1 index. I forgot to check and see where the carved out section is pointing. It turned out that I placed my MUX in the wrong orientation. After I flippedit, the circuit was functioning OK.
 
 
As to time delays, I`ve tried anything. I tried time delays up to 32 ms, both before and after changing the channels, and the cross-talk was still resident. I tried time delays as short as few tens of microseconds, still nothing, the cross-talk was there all the time. If I shaded one sensor, all the outputs of the other AD channels went to zero, also. I believe that the problem is in the input and output impedances. I am trying to build a maze solver robot using IR LEDs as sensors - one IR LED as light source, another IR LED as sensor. Now, the IR lED has output impedance of about 800 MOhm. And the input impedance of my PIC16F887 is 10kOhm max. So, this great difference in impedances (I believe) causes very slow rate of charging of the Chold, or is not helping the process of AD conversion due to other causes. So now, I am planning to use only one AD channel to eliminate the cross talk. I`ll be selecting inputs to that channel with my MUX. I expect this to work since the MUX has very low output impedance of about 80 Ohm. I`ve tried the functioning of the MUX, it doesn`t distort or weaken the voltage coming out of the IR LED. Tomorrow I`ll be writing code for all my seven channels and I`ll be checking whether my idea paid off.  
 
Cheers, thanks!
mrp
Super Member
Re:Problem with PIC16F887 and a multiplexer 2012/12/25 21:14:20
I'm no expert on this, but I wouldn't have thought that adding an analog mux in line would help solve your input impedance problem.  Effectively, won't the mux be the equivalent of additional series resistance?  I think you'll still need some type of buffer or op amp to get your input impedance down below 10k.  When you measured the output of the MUX, did you try loading it with a 10k resistor?