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. tempus fugit

    tempus fugit Guest

    Hi all;

    I currently have a switching system that uses logic like latches and
    inverters, along with lots of diodes. I'm thinking about changing some
    things in it, and was wondering if I shouldn't just revamp the whole thing
    and go to a PIC. Here's what I would like it to do:

    I have 14 switches - when any one of them was switched to ground
    (momentary), it would cause the PIC to:
    1. clear any previous data in the PIC
    2. latch a signal to the required output that would ramp up the control
    voltage over a few ms.

    I have a 15th switch that when switched causes the each switch to activate a
    different set of devices (sort of like having 2 different banks). Could I
    use a PIC to have the same function, kind of like having it latch that
    switch in one position or another, and telling the PIC to execute the proper

    These switches control 6 different relays to switch in different effects or
    effects combinations for my guitar pedalboard. Would I need many PICs to
    accomplish this, or would it be possible to set things up with just one?

    I suspect these are fairly newb questions, but I don't know what types of
    things are possible with the instruction set available with a PIC. I have
    downloaded a couple data sheets, but at about 200 or more pages each,
    there's a lot to digest, and i don't quite understand it all yet.

    Is it possible to do these things with a PIC?

  2. PIC is a trade name for several ranges of microcontrollers from one
    manufacturer. There are many others.

    A microcontroller is essentially a microprocessor with
    RAM/ROM/periperals on board (though definitions vary somewhat).
    The ramping up is perhaps best done with some analog circuitry. Since
    the switches are manually actuated you could perhaps scan them at,
    say, 500Hz rather than deal with them individually (much like your PC
    Probably just one. The main limit is how fast things have to happen,
    if a few msec here or there is not important, then you can do some
    very complex things with a micro running at a reasonable clock
    frequency. The number of I/O may come into play, but there are ways of
    expanding the I/O (scanning etc.) and there are lots of micros with
    100, 200+ or more 'pins'.
    From what you have said, most likely yes, however you will have a
    learning curve to deal with. Start with something simple like blinking
    an LED at a visible frequency and work from there. Be sure to check
    out the reference manual for the product line you're looking at too.
    It may seem like a lot, but the more detailed information rather than
    the skinned down data sheet will be helpful.

    Best regards,
    Spehro Pefhany
  3. MooseFET

    MooseFET Guest

    I suggest you say "micro" not "PIC" and consider other types. I'll
    explain why as we go through the various requirements.

    You want to have 14 port connections to do this with so we now know
    one specification of the micro.

    You didn't say how quickly it needs to react. Since a human is
    pushing the switch, perhaps 20mS or so should be the required maximum
    responce time.
    This sounds like you want a micro with a built in DAC or an external
    DAC connected to the micro. How smoothly does it need to ramp and how
    linear etc? How many output lines need to be ramped? Does only one
    go high at a time?

    You can use fairly simple analog circuits to make a ramp. You also
    didn't speak about how the signals ever go low again. I assume they
    do this also with a ramp.

    Opps make the 15 port lines.
    This is simple code.

    Ok so now we have a total of 15+6=21 port connections.
    Now I'm going to suggest you reconsider the question of which micro.
    You could look at the ones at as an example of a very
    different one. There are lots and lots of chips that can do what you
  4. Eeyore

    Eeyore Guest

    Very much so.

    I'd code it as a finite state machine actually. The actual processor
    instructions barely matter btw. For ease of programming most ppl would use
    compilers for a high level language. PICBASIC is simple and only costs $99.95

  5. tempus fugit

    tempus fugit Guest

    You didn't say how quickly it needs to react. Since a human is

    It needs to switch a relay quickly enough so that it seems like stomping the
    switch instantly causes the effect to go on. I didn't even know that
    respsonse time was something that needed consideration (told you I was a

    I just want it to take a few ms to ramp up the relay driver before the relay
    switches so that any capacitative clicks are avoided. I don't know if that
    needs to be linear or smooth or what (help?)

    How many output lines need to be ramped? Does only one
    Well this depends on how many micros I need to do the job. All the outs
    would need to be ramped, but if possible, I would like to have 6 outputs -
    one to each relay - an probably a max of 4 on at a time.

    Hopefully yes. They will go low from requirement 1 - clear any previous data
    in the PIC.

    That's what i wanted to hear!

    Thankjs for your help Moose - and i'll check out that other site. I'm glad
    for any other advice as well.
  6. It is UNTHINKABLE to NOT use a PIC for this ap.

    Many thanks,

    Don Lancaster voice phone: (928)428-4073
    Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552
    rss: email:

    Please visit my GURU's LAIR web site at
  7. Gary Tait

    Gary Tait Guest

    I'd use Bacom AVR, which is free for up to 2K code (or at least was last I
    used it), and Atmel micros.

    Or you get a Basic Stamp.
  8. Gary Tait

    Gary Tait Guest

    Could the be muxed, or read with a diode binary convertor?
    You might be able to do the ramp in analog.
    Just one.
    They are pretty dumb. Just I/Os you need to interface with code.
    With the right tools, the code is pretty easy, especially for such a
    simple task as yours.

    I even have the code in my head (at the BASIC version of what it is).

    With extra code, you can have it field programmable, and have a display
    and/or indicators.
  9. Eeyore

    Eeyore Guest

    You could use a Philips LPC ! That would be my choice in fact as I'm familiar with
    the family.

  10. tempus fugit

    tempus fugit Guest

    Do you mean an actual PIC, or any uProcessor?

  11. tempus fugit

    tempus fugit Guest

    I'm not familiar with this. What do you mean by scan them at 500Hz?

  12. Eeyore

    Eeyore Guest

    He's thinking of a way of trying to eliminate the effect of switch bounce I

    Provided your switches only do 'X' when pressed rather than released, there's a
    very simple way of avoiding the issue entirely in software though.

  13. tempus fugit

    tempus fugit Guest

    I get it now.

    Thanks Graham
  14. tempus fugit

    tempus fugit Guest

    From what you have said, most likely yes, however you will have a
    I had planned to do that; however, I would like to experiment with the
    uProcessor I'll actually need to do the job if that's at all possible, thus
    saving time and hopefully money. Is there a model # you'd suggest for this
    task? Should I try to find 1 device with 21 port connections, or use a
    couple and (if it's possible?) interface them somehow? Most of the tutorials
    I've seen on the web are for 20 pin DIPs, which would be easy to experiment
    with. I'm not sure how I'd go about trying to experiment with a surface
    mount package.

  15. Eeyore

    Eeyore Guest

    You're welcome. It's cute isn't it ?

  16. Eeyore

    Eeyore Guest

    I have a file here called "blinkled.p51".

    It's a handy test.

  17. Rich Grise

    Rich Grise Guest

    That means that the uP is running a program that samples all of its inputs,
    one at a time, 500 times per second (for the whole set). This is much
    faster than is needed to give a response that looks immediate to the naked
    eye, and probably fast enough to do debouncing in software (or firmware,
    which is software in FLASH/PROM). 1/500 of a second comes out to 2
    milliseconds per sample, which is time enough to take five samples within
    10 milliseconds, which was the "bounce time" of some switch that I looked
    up, and probably fairly typical.

    Hope This Helps!
  18. MooseFET

    MooseFET Guest

    On May 21, 7:52 am, "tempus fugit"
    Ok, so maybe we can strike the DAC out of the specs. A very simple RC
    low pass filter will likely do what you need. How high is "high" and
    how low is "low"? I'm thinking in terms of using an op-amp if the
    signal needs to be bigger than the natural swing of the port pins.

    If you are using an op-amp, they come 4 to a chip. It makes sense to
    go up to the next multiple of 4 lines. BTW: Unless I missed
    something, we are only talking of one processor to do lets say 24

    Look up the following parts and look at the datasheets:


    I'm almost certain the design will have most of those parts in it. I
    suggest the LT1499 for a reason I'm about to explain so that others
    don't throw too many stones at me.

    The LT1499 is the op-amp I could remember had a rail to rail input and
    output and also has diodes across the inputs. Here's the circuit I'm
    thinking of:

    ASCII art:
    ! !
    ! V+ !
    ! ! !
    PORT PIN -/\/\----+----!-\ !
    ! >---+--- RAMP

    It makes a nice linear ramp up and down.
  19. tempus fugit

    tempus fugit Guest

    As for voltages, I have 12, 9 and 5v available to me at present. Hi would be
    +5 (to control the relay driver), and lo would be ground I think. If I cant
    do it easily in software, I may just go with an RC circuit. The idea is to
    rebuild what I currently have with the minimum of parts. What would be ultra
    slick would be to use a 13 I/O port device and somehow use it for the 6 ins
    and outs, since I only have to control 6 parameters. Some switches, though,
    would turn on more than one thing at a time, and I haven't yet figured out a
    way to connect the switches so that each switch would only switch what i
    wanted it to. For instance, if I have a switch that switches A, and 1 that
    switches B, and 1 that switches A and B, I can't figure out a way to wire
    that to 3 in pins so that they don't all interact.

    Thanks again
  20. Eeyore

    Eeyore Guest

    If you're only looking for a momentary make, you don't even need to debounce.

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.
Electronics Point Logo
Continue to site
Quote of the day