Multiplexer channel selection


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    hi,

    your answer is "something like that"

    ... but as the PIC will perform the A/D conversion ... a Porta Analog input has some good chance to be in use ... if you do not use another ADC input ( PortE 0,1 or 2 for a 16F877a )


    without any headaches ... it gives

    Code:
    Porta.5 = 0                ' Enable the Mpxer
    
    for I = 0 to 15
    
     Porta =  (Porta & %11000001 ) + (I *2)  ' Keep Porta.5 low, Porta.0,6,7 as is, and Porta1-4 select the input
     Pause 5                               ' to stabilize Mpxer Output voltage
     ADCin Portx.y, value[I]           ' Portx.y is where the Mpxer output is connected ...
                                               'value[I] is the table location corresponding to the cell
    NEXT I
    
    .
    .
    .
    too simple !

    Alain

    PS: May be someone could explain me why writing [] with UPPERCASE I inside the brackets show
    Code:
    [I]
    ...
    Last edited by Acetronics2; - 14th May 2008 at 19:11.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    PS: May be someone could explain me why writing [] with UPPERCASE I inside the brackets show
    Code:
    [I]
    ...
    Italics vs. Italics

    Italics vs. [ I ] Italics [ / I ]

    http://www.phpbb.com/community/faq.php?mode=bbcode
    Last edited by skimask; - 14th May 2008 at 19:16.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by skimask View Post
    Italics vs. Italics

    Italics vs. [ I ] Italics [ / I ]

    Hi, Ski

    Yes ... Ok, But ALSO inside a CODE window ...???

    could we talk about a BUGGGGGGGGG ????

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Yes ... Ok, But ALSO inside a CODE window ...???
    could we talk about a BUGGGGGGGGG ????
    I don't know if it's a bug or not. Maybe bbCode doesn't handle nested tokens, or at least that nested token correctly, maybe it was intended to be that way.

  5. #5
    Join Date
    Apr 2008
    Location
    Berlin, Germany
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    Please stay on topic.

    Here's a summary: I have two pesky devices in my circuit. A multiplexer and a decoder.The multiplexer is connected as:
    Code:
    MUX
    '------------
    'RA5	INH
    'RA1	A
    'RA2	B
    'RA3	C
    'RA4	D
    '------------
    notice how the selection channels are on consecutive pins thus making things easy for selecting the channels:
    Code:
    'mux channel selection
    'low inh_mux
    'for i= 0 to 15
    '       Porta =  (Porta & %11000001 ) + (i *2)	'port masking for cycle purposes
    'next i
    On the other hand the decoder pins are scattered across PORT B and PORTC:
    Code:
    'DCD
    '----------
    'RE2	G1,G2	
    'RB7	A
    'RB6	B
    'RB5	C
    'RC6	D
    here's the code i've devised:

    Code:
    'dcd channel selection
    low g_dcd
    for i=0 to 15
    	portb = (portb & %00011111 ) + (i rev  3)<<5
    	portc = (portc & %10111111 ) + (i<<3)
    next i
    The PORTB pins selection works fine (meaning lines A, B and C of the decoder behave as I expected). But line D (the only one on PORTC) gives me a headache. Am I missing something in the mask ?

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Castor View Post
    Please stay on topic.
    Guess what? Free help! Deal with it.

    Code:
    'dcd channel selection
    low g_dcd
    for i=0 to 15
    	portb = (portb & %00011111 ) | ( ( i rev  3 ) << 5 )
    	portc = (portc & %10111111 ) | ( i << 3 )
    next i
    OR don't ADD

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Guess what? Free help! Deal with it.

    Code:
    'dcd channel selection
    low g_dcd
    
    for i=0 to 15
    	portb = (portb & %00011111 ) | ( ( i rev  3 ) << 5 )
    	portc = (portc & %10111111 ) | ( i << 3 )
    next i
    OR don't ADD
    to get rid of the i lower bits for portC ...

    i would have used

    Code:
    portc = (portc & %10111111 ) | ( i.3 << 6 )
    but, it's me ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  8. #8
    Join Date
    Apr 2008
    Location
    Berlin, Germany
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post

    ... but as the PIC will perform the A/D conversion ... a Porta Analog input has some good chance to be in use ... if you do not use another ADC input ( PortE 0,1 or 2 for a 16F877a )
    Hey, thanks for the great answer.
    It works like a charm. In fact I use a 16 bit external A/D converter so using PORTA pins as digital I/O doesn't pose an issue. What if the selection pins are scattered across two ports ? Can I get around that without selecting each and every output manually ? Or reworking the board ? (I didn't quite think about channel selection when I built it)
    'DCD
    '----------
    'RE2 G1,G2
    'RB7 A
    'RB6 B
    'RB5 C
    'RC6 D

  9. #9
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Castor View Post
    What if the selection pins are scattered across two ports ?
    Why not ...

    you'll have to write two lines for Ports masking instead of one !

    Can I get around that without selecting each and every output manually ? Or reworking the board ?
    if you have a pot or button available and a free Pic input or two ... you can easily make the manual channel selection "by soft" ...


    (I didn't quite think about channel selection when I built it)
    but , may be, you'll have to add a small board on the existing one ( in french : une impériale !!! )

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Best way to shut down HPWM channel?
    By LetTheSmokeOut in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th January 2010, 23:01
  2. Timer + rc5
    By naga in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 19th November 2009, 08:56
  3. Hserin
    By [email protected] in forum Serial
    Replies: 11
    Last Post: - 16th December 2008, 19:49
  4. 18F1320 ADC multiple channel select
    By jmgelba in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th November 2005, 22:40
  5. 16F819 ADCIN Channel Select?
    By modifyit in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 27th April 2005, 19:31

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts