Multiplex switches

Status
Not open for further replies.
Quoted from : http://www.bcae1.com/resistrs.htm
Around the middle of page

so i got to :
I = V/R
then
V = I*R

This would sum out to be 5volts / 4 resistors regardless since all resistor values are equal.

I = 5 / 4000 = 0.00125
then
V1 = 0.00125*1000 = 1.25V
V2 = 0.00125*1000 = 1.25V
V3 = 0.00125*1000 = 1.25V
V4 = 0.00125*1000 = 1.25V

Now if i had
R1 = 1k
R2 = 1.5k
R3 = 2k
R4 = 2.5k

1 + 1.5 + 2 + 2.5 = 7k

I = 5 / 7000 = 5.5555555555555555555555555555556e-4
then
V1 = 5.5555555555555555555555555555556e-4*1000 = 0.55555555555555555555555555555556v
V2 = 5.5555555555555555555555555555556e-4*1500 = 0.83333333333333333333333333333325v
V3 = 5.5555555555555555555555555555556e-4*2000 = 1.111111111111111111111111111111v
V4 = 5.5555555555555555555555555555556e-4*2500 = 1.3888888888888888888888888888888
would this mean i need more power?

how the hell would this work ?

Tried in a ohms law calc and got

0.00071 A over 7K

so
V1 = 0.00071 * 1000 = 0.71
V2 = 0.00071 * 1500 = 1.065
V3 = 0.00071 * 2000 = 1.42
V4 = 0.00071 * 2500 = 1.775
=4.97V

why not 5V ? Will it still work due to the +/-5% thing on resistors?
 
Last edited:
No they can be the same value. In fact, this simplifies the equation since once you know the voltage drop across one, you know the drop across all of them. To determine the voltage applied by each keypress, you simply add up the voltage drops connected to that key.
 
Little current flow into the analog port pin. It contains a capacitor that charges to whatever voltage is on the pin. After that no current flows.

So in the all open case the analog port see 5V.

When you close S1 the 100K is in parallel with the 1st 1K so it becomes 990.1 Ohm
(look up parallel resistance calculator)

Which is close enough for government work to still call it 1K

The point is that by making the 100K resistor a large value it has little effect on the voltage divider.
 
ok cool:

So it
V1:V4 = 1.25

then:
button 1 = 1.25v
button 2 = 2.50v
button 3 = 3.75v
button 4 = 5.00v

right?
wait wait:
3960.4 is the total ohms then?
you guys just confused me lol let me figure it out 1 min
 
Last edited:
Close. Take a close look at your schematic and think about what the voltage with respect to ground is going to be for each key.

I'll be back tomorrow. Goodnight.
 
**broken link removed**

With VCC=VDD=5V

All open will be 5V
S1 closed will be 3.75V
S2 closed will be 2.5V
S3 closed will be 1.25V
S4 closed will be 0V
 
Dam i c it now i think i need a vacation lol. I forgot the resistors add up hence smaller voltage towards end and 4 = 0v because it closes gnd and connects straight right?
 
So now for the software part:

In the data sheet :

Code:
To do an A/D Conversion:
1. Configure the A/D module:
• Configure analog pins, voltage reference and
digital I/O (ADCON1)
• Select A/D input channel (ADCON0)
• Select A/D acquisition time (ADCON2)
• Select A/D conversion clock (ADCON2)
• Turn on A/D module (ADCON0)
2. Configure A/D interrupt (if desired):
• Clear ADIF bit
• Set ADIE bit
• Set GIE bit
3. Wait the required acquisition time (if required).
4. Start conversion:
• Set GO/DONE bit (ADCON0 register)
5. Wait for A/D conversion to complete, by either:
• Polling for the GO/DONE bit to be cleared
OR
• Waiting for the A/D interrupt
6. Read A/D Result registers (ADRESH:ADRESL);
clear bit, ADIF, if required.
7. For the next conversion, go to step 1 or step 2,
as required. The A/D conversion time per bit is
defined as TAD. A minimum wait of 2 TAD is
required before the next acquisition starts.

Its like 12am here so im going to relax now and try this tommorow. I should have my junebug by like thursday and hope to have something to make by then and thanks to you all so far so good. So i want to thank you all and wish you a good night (morning for some)
 
i cant wait. Oh yeah i made my first 555 timer(blinker) today. would be my 3rd project so far. Im going to post it and put it in my sig. (its a video (youtube))
 
Last edited:
Code:
ADCON0: A/D CONTROL REGISTER 0

bit 7-6 VCFG<1:0>: Voltage Reference Configuration bits
   00 AVDD AVSS
   01 External VREF+ AVSS
   10 AVDD External VREF-
   11 External VREF+ External VREF

bit 5 Unimplemented: Read as ‘0’

bit 4-2 CHS2:CHS0: Analog Channel Select bits
   000 = Channel 0 (AN0)
   001 = Channel 1 (AN1)
   010 = Channel 2 (AN2)
   011 = Channel 3 (AN3)
   100 = Channel 4 (AN4)
   101 = Channel 5 (AN5)
   110 = Channel 6 (AN6)
   111 = Unimplemented(1)

bit 1 GO/DONE: A/D Conversion Status bit
   When ADON = 1:
   1 = A/D conversion in progress
   0 = A/D Idle
bit 0 ADON: A/D On bit
   1 = A/D converter module is enabled
   0 = A/D converter module is disabled

Now to configue module:
So would 'ADCON0 = 00000001' look around right to you ?
 
should i have it off then ? Or is it good to be on but idle ? RA0 is in the schem i made as the input port. and i am using VDD and VSS so it this ok ? Or is it external refrence?

The analog reference voltage is software selectable to
either the device’s positive and negative supply voltage
(AVDD and AVSS), or the voltage level on the
RA3/AN3/VREF+ and RA2/AN2/VREF- pins.

Im not using RA3/AN3 and RA2/AN2 so i assumed AVDD & AVSS
 
Last edited:
Using VDD & VSS as references are common, and since your voltage divider uses VDD & VSS the analog solution is relative and can be thought of as a simple percentage.
 
ok so im assuming everything is ok
Onto ADCON1


Sorry i changed the above a bit to take up less space on page.

ADCON1 = 0000000 = All Analog so i can convert to digital.

If set to 1 then it would require a digitial input and since we
are using analog input we set it to 0 to disable digital input right?

Be back in 10 min have to go buy some breakfast (starving)
 
Maybe you know this.

You are only using 1 pin for analog input, AN0. So you only need to set that pin as an analog input. Set the others according to what you are using them for (analog or digital).
 
ok maybe i should make a simple full schem after i eat to show you what i would like to accomplish. (nothing big infact very very small)
 
I will not be around much longer because I have leave.

There is a good chance Bill or another may provide help. I will try to check the thread if I have time between classes.
 
ADCON1 only is used for setting analog or digital.
I think i would then use TRISA = 10111111 to make Bit 5:0 input 7:6 is for clock right? Thats another issue for later on.

So TRISA = BF or 10111111 binary // set i/o pins to in for A
So TRISB = 00 or 00000000 binary // set i/o pins to out for B

Ok thanks

**broken link removed**
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…