Connect with us

Can I do this with a uProcessor?

Discussion in 'Electronic Design' started by tempus fugit, May 21, 2007.

Scroll to continue with content
  1. Eeyore

    Eeyore Guest

    Sometimes.

    Graham
     
  2. Eeyore

    Eeyore Guest

    I would so NOT advise key scanning in a sensitive audio product !

    It's a bitch trying to get rid of the noise form the scanning. A few more I/O
    pins is so simple in comparison.

    Graham
     
  3. Suppose you have 14 keys. You have a single 8 bit I/O port. We will
    assume that only one key can be pressed at once, otherwise you'll have
    a bit more complexity.

    So you make half of the pins inputs and the other half outputs.

    You drive one of the four outputs (say) low and float the others
    (essentially make them inputs). Then read the four inputs at once.
    That gives you the states of 4 keys. Repeat 3 more times with a
    different output low and you have all 14 (or 16) key states.



    VCC
    +
    |
    .-.
    | |
    | |
    '-'
    |
    input P0 --+---------------------------------
    | | | |
    VCC \ o \ o \ o \ o
    + \ \ \ \
    | \. \. \. \.
    .-. o o o o
    | | | | | |
    | |
    '-' P4 P5 P6 P7
    |
    input P1 -+---------------------------------
    | | | |
    \ o \ o \ o \ o
    \ \ \ \
    \. \. \. \.
    o o o o
    | | | |

    P4 P5 P6 P7


    etc.

    P0..P3 inputs only
    P4..P7 are low or float

    (For a real design for production we'd probably have some series
    resistors on the port pins and the pullups might be built into the
    chip)

    Debouncing is another issue. It's not that difficult to do for all
    cases in software (and get rid of glitches at the same time), but if
    you only want the keys to start something you may not even need it.



    Best regards,
    Spehro Pefhany
     
  4. MooseFET

    MooseFET Guest

    On May 21, 7:38 pm, "tempus fugit"
    A micro running on the 5V and RC filters on the port outputs may be
    the best way to go. It certainly is one worth considering. You won't
    be able to do much better on the parts count issue.


    [....]
    You have made an error in thinking here. The switch only informs the
    micro that the switch is closed. The micro knows which group of
    things to activate for a given switch. This makes the wiring very
    simple.


    would only switch what i
     
  5. Gary Tait

    Gary Tait Guest

    You don't need 21, just 5 for input (14 switches in binary, plus the
    bank swap, which you could incorporate into the other switches, with
    just 4 input lines. 6 for output. Optionally some sort of indicator
    output.
     
  6. mpm

    mpm Guest

    I'd go with an 8051 before an LPC.
    If an LPC, you have to do a kubookie dance to get 'em programmed.

    I know I probably spelled that wrong, but you get the idea.
    The flash programming documentation on the LPC series is the WORST I
    HAVE EVER SEEN!
    Plus, you have to keep switching pins in and out of the circuit to
    program it. What a hassle!

    TF, take a look at the Atmel 89S8253.
    Cheap, and will do the job. It has (4) 8-bit bidirectional ports (32
    in/out total).
    And, you can program it free with the Atmel download software.
    You will need a $25 adapter for your PC, but you can't get much
    cheaper.

    The 8051's are very well supported, so you will find free compilers
    (Basic, Assembly, "C", etc..)

    The only thing that might be an issue for you is the 8253 port pins
    can only drive about 10mA each, and that won't be enough for most
    relays directly. -mpm
     
  7. Eeyore

    Eeyore Guest

    Yes, you're quite right I was thinking of the LPCs because of newer things I've been
    working on but a flash version of an 8051 would be spot on. I used the 89s53 for this
    kind of thing for example and it's got plenty of port pins on it too.

    Graham
     
  8. "LPC" may not be the best way to refer to the NXP microcontrollers. It
    could refer to an 8051 in an 8-pin package (P89LPC901), an ARM9 in a
    320-pin package (LPC3180FEL320) or quite a range of other parts
    inbetween.


    Best regards,
    Spehro Pefhany
     
  9. joseph2k

    joseph2k Guest

    Not at all. Switch or keyboard scanning means sampling the state of each
    switch at some given rate, 500 times a second in this case. Switch / key
    debounce is a convenient byproduct of the method.
     
  10. joseph2k

    joseph2k Guest

    It is much to your advantage to multiplex the inputs, say use 4 "rows" and 4
    "columns" to sense your switches (up to 16 of them) on 8 pins of i/o. It
    is also to your advantage to drive your outputs individually.
    What i do not understand is the idea of using ramps to drive relays, they
    work much better with on-off control drive. I also have issues with using
    relays at all, electronic switching is faster and quieter.
    As for what turns on when for any given switch configuration, just decide
    what you want it to do and that becomes part of the micro's program. no
    witchy complexities, just a map (list) from inputs to outputs.
     
  11. Eeyore

    Eeyore Guest

    You really don't want switch scanning waveforms in an audio device. I've seen
    the trouble it creates.

    Graham
     
  12. Sounds like a very bad design.


    Best regards,
    Spehro Pefhany
     
  13. Eeyore

    Eeyore Guest

    It was a very nice design actually but like all things in the real world was
    subject to cost constraints so couldn't be on say a 4 layer board.

    Try eliminating electro-statically and electro-magnetically coupled interference
    when the audio noise floor is >=110dB below the 5V typical switching voltage. Note
    that to be sure of not hearing a discrete tone, the pickup into the audio will need
    to be about >=130dB below 5V since single tones are not well masked by wideband
    noise.

    130dB. Don't forget that.

    We used to agonise over the induced click you'd get from a single short trace
    switching maybe just a local control voltage. It's astonishing what makes itself
    known when you actually *listen* to audio, as opposed to relying on long term
    averaged measurements.

    Graham
     
  14. tempus fugit

    tempus fugit Guest

    So is the multiplexing done by the micro itself, or is it done with a
    separate IC?


    It isn't the relays I want to ramp, it's the relay drivers. I may end up
    going to electronic switching in the end (in fact that is what I want to
    experiment with, but my existing design would require quite a bit of
    modification to do that, which is why I'm thinking about building from
    scratch using a micro).
     
  15. tempus fugit

    tempus fugit Guest

    The only thing that might be an issue for you is the 8253 port pins

    No problem there - I'm using relay drivers to drive the relays already, and
    may end up going with CMOS switches anyway.

    Man, there are a lot of different micros....

    Thanks for the tip on the Atmel - it looks promising.
     
  16. tempus fugit

    tempus fugit Guest

    I understand that, but do I then need 1 input pin for each switch, and 1 for
    each output? That would mean 15 ins, plus 6 outs. Since I only have 6
    different parameters to control, I was wondering if there was a way to use
    only 6 input pins and 6 outs, plus the 1 extra for the bank switch.

    The problem lies in the fact that some of the switches will control more
    than 1 parameter at a time. That was what I was trying to describe in the
    previous post:

    a switch that switches A, and 1 that switches B, and 1 that switches A and
    B

    Thanks
     
  17. tempus fugit

    tempus fugit Guest

    So by 8 bits you mean a total of 8 pins to connect to (I'm still a bit
    unsure of all the terminology)?

    have
    a bit more complexity.

    This is the case, although it is possible that more than one key may get
    pressed accidentally...
    By programming them this way in the software?

    Here's where I'm getting lost. How do the ouputs get driven low? I was
    thinking that if no switch was activated, that they would be already low, by
    design. What do you mean read the 4 inputs at once? I was hoping to control
    the micro by momentarily grounding an input with the switch.

    output low and you have all 14 (or 16) key states.

    So are the output pins sometimes outputs and sometimes inputs? Are the
    switches (inputs) then connected to the same pins as the relay drivers
    (outputs)?
    you only want the keys to start something you may not even need it.


    The switches are indeed just to get something started.

    Thanks again.
     
  18. MooseFET

    MooseFET Guest

    [....]
    I'm going to jump in here with a somewhat off subject comment about
    the scanning of keyboards.
    Normally, when you want to scan a keyboard with a micro, you wire the
    row connections to one (8 bit) port and the column connections to
    another.

    You are then going to strobe the column signals one at a time. In the
    8051 case, you have the idle state of the ports as high and you strobe
    one low at a time. If a switch is closed, the row signal will go low
    at the same time.

    If the OP has a slowish (or busy) micro to work with, and doesn't need
    to worry about the user pressing more than one key at a time, he can
    do as follows:

    Assuming 4 bits of each are used:

    PrevKey = NOKEY;
    repeat
    RowPort = 0FH
    ColPort = 0
    KeyNo = NOKEY
    if RowPort < 0FH then begin
    if (RowPort AND 01H)=0 then KeyNo=0
    if (RowPort AND 02H)=0 then KeyNo=1
    if (RowPort AND 04H)=0 then KeyNo=2
    if (RowPort AND 08H)=0 then KeyNo=3

    ColPort = 0AH
    if RowPort <0FH then KeyNo = KeyNo + 4
    ColPort = 0CH
    if RowPort <0FH then KeyNo = KeyNo + 8
    end
    if (KeyNO <> NOKEY) and (KeyNo = PrevKey) then
    report KeyNo
    PreKey = KeyNo
    end


    Because the ColPort lines only change when the key is pressed, there
    is less noise created. You have to check the key twice because the
    test can come up with the wrong answer on a key bounce.
     
  19. Eeyore

    Eeyore Guest

    It's done by writing software to drive the micro's port pins in the required
    manner.

    Since you're new to all this and key scanning will in any case create an audio
    tone that's very likely to break through into your signal, I very strongly
    suggest you don't bother and use 1 input or output per port pin.

    After all an 80C51 variant such as the 89s53
    http://atmel.com/dyn/products/produ...04&family_name=8051+Architecture&part_id=1919

    is inexpensive, easy to use and has 32 general purpose I/O lines anyway.

    Graham
     
  20. Eeyore

    Eeyore Guest

    But what benefit do you expect to get from this ?

    Graham
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.
Loading...
Electronics Point Logo
Continue to site
Quote of the day

-