Can I do this with a uProcessor?

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 instruction?

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?

Thanks

Reply to
tempus fugit
Loading thread data ...

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

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

--
"it's the network..."                          "The Journey is the reward"
speff@interlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com
Reply to
Spehro Pefhany

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

formatting link
as an example of a very different one. There are lots and lots of chips that can do what you want.

Reply to
MooseFET

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

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.

activate a

I

proper

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.

Reply to
tempus fugit

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: http://www.tinaja.com/whtnu.xml   email: don@tinaja.com

Please visit my GURU\'s LAIR web site at http://www.tinaja.com
Reply to
Don Lancaster

"tempus fugit" wrote in news:e9837$46510fed$d1d89b9d$ snipped-for-privacy@PRIMUS.CA:

Could the be muxed, or read with a diode binary convertor?

You might be able to do the ramp in analog.

Simple.

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.

Reply to
Gary Tait

thing

activate a

I

proper

or

of

have

Thanks

Do you mean an actual PIC, or any uProcessor?

at

formatting link

Reply to
tempus fugit

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

Thanks

Reply to
tempus fugit

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.

Thanks

Reply to
tempus fugit

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! Rich

Reply to
Rich Grise

On May 21, 7:52 am, "tempus fugit" wrote: [....]

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

[...]

Look up the following parts and look at the datasheets:

LM340 LT1499 LM324

2N2222 1N4004

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 Vcc/2--------!+/ ! GND

It makes a nice linear ramp up and down.

Reply to
MooseFET

glad

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

Reply to
tempus fugit

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

--
"it\'s the network..."                          "The Journey is the reward"
speff@interlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com
Reply to
Spehro Pefhany

On May 21, 7:38 pm, "tempus fugit" wrote: [....]

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

Reply to
MooseFET

"tempus fugit" wrote in news:c4064$465218e5$d1d89b70$ snipped-for-privacy@PRIMUS.CA:

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.

Reply to
Gary Tait

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.

--
 JosephKK
 Gegen dummheit kampfen die Gotter Selbst, vergebens.  
  --Schiller
Reply to
joseph2k

4

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

Reply to
tempus fugit

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

Reply to
tempus fugit

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.

Reply to
tempus fugit

I'm goning to try a bit of ASCII art:

Column Port 0 1 2 ! ! ! R ! ! ! o 0---+-------------+------------ ! w ! ! ! ! ! ! P 0 SW 0 0 SW 0 0 SW 0 o ! ! ! r 1---+-------------+------------ ! t ! ! ! ! ! ! 0 SW 0 0 SW 0 0 SW 0

A rectangular array of switches connected as shown is how you can connect them to the ports. You then need to drive the Column Port bits up and down and see which Row Port bit follows which Column port bit.

Extending this array, you can do 16 keys with 4+4 = 8 port lines.

Reply to
MooseFET

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.