Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Multiplex switches

Status
Not open for further replies.
We know:
# The total voltage
# The individual resistor values

We can calculate the current flow and then the voltage drop across the individual resistors. From the Ohm's law page, we will use the formula:
I = V/R
I = 12/3000 ohms
I = 0.004 amps or 4 milliamps

The current flow through the resistors is 4 milliamps. Since the resistors are in series, we know that the current flow through each resistor is the same.

Then, to find the voltage drop across the 1000 ohm resistor, we can use the formula:
V = I*R
V = .004*1000
V = 4 volts across the 1000 ohm resistor

And to find the voltage drop across the 2000 ohm resistor, we can use the formula:
V = I*R
V = .004*2000
V = 8 volts across the 2000 ohm resistor
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.
 
AtomSoft said:
ok cool. So there is no definite way to calculate the divided voltages right? Like i would have to place resistors and manually check each one to determine drop ?
All i know in ohms law is how to get 1 value from 2 others. I don't know how to subtract like 100k ohms from 5v to determine the drop on the resistor.


yeah the concept is in the head but the head doesn't know how to draw lol

EDIT: Found this
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.
 
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

ADCON1: A/D CONTROL REGISTER 1

BITS 6:0:
1 = Pin configured as a digital port
0 = Pin configured as an analog channel – digital input disabled and

reads ‘0’


bit 7 Unimplemented: Read as ‘0’

bit 6 PCFG6: A/D Port Configuration bit – AN6

bit 5 PCFG5: A/D Port Configuration bit – AN5

bit 4 PCFG4: A/D Port Configuration bit – AN4

bit 3 PCFG3: A/D Port Configuration bit – AN3

bit 2 PCFG2: A/D Port Configuration bit – AN2

bit 1 PCFG1: A/D Port Configuration bit – AN1

bit 0 PCFG0: A/D Port Configuration bit – AN0

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)
 
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)
 
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.

Latest threads

New Articles From Microcontroller Tips

Back
Top