PIC driving an LED, and a cable length question?

Started by G. Hoffman, March 03, 2013, 10:06:55 PM

Previous topic - Next topic

G. Hoffman

I'm doing a super simple PIC project (it's on a PIC12F, it is so simple!), and I've got a question. 

I'm using the PIC for the footswitch in an amp, the basic idea being that there are two switches, and I want them each to have an LED, so the pins will drive the LEDs most of the time, and poll the switches from time.  Basic stuff, but it means I can drive two LEDs and check two switches with just a 2+ground cable, which is easy to replace if it fails, which is great. 

I know the PIC can drive a couple of LEDs on the same board, but my question is; can a PIC drive a couple LEDs at the end of a 20 foot cable?  Also, the capacitance of that cable should mess up my switching at all, will it?


Gabriel

cpm

For a passive footswitch its not a trivial situation, you have to combine 4 functions into two wires: reading two switches and lighting two LED indicators
Fender has this arrangement for some of their dual footswitches, by using bipolar singal and a scheme of diodes.

Like you said, alternating the pin function from output to input may have some issues with capacitance
And, if i were designing that situation I would avoid having the PIC directly conected to the outside, unprotected to misplacement of connections, electrostatic, etc

My rough approach would be:
From the main board a transistor driving current for the LED into one of the wires. This includes a limiting reistor in case this wire is shorted to ground. In the footswitch, the switch actually breaks this circuit from the common ground wire, and the LED is then off.
At the main board, some scheme to detect when the current is flowing. This way you dont need pins to drive the LEDs, and use just two inputs on the PIC.







G. Hoffman

That would almost work, damn it.  The only problem is, the overdrive switch has to have a front panel "pull for Overdrive" switch, because this amp is primarily going to be for customers to try their guitars at the shop, so it won't always be used with the footswitch.  I can't see how to have the foot switch LED change with the front panel switch with your idea.  (Which is a great one, by the way, and would absolutely be the way to go if it would work!)  It would work great for the other footswitch function, which will be unavailable without the footswitch.  I'm going to have to see if I can find a way for that to work!!!


Gabriel

cpm

the latching FS needs to rule over the main switch. If you disable the driving to the FS LEds, you could still push the buttons and would be confusing because you dont know in which state it is.

I think a momentary switch for the front board would allow more flexibility, and let the PIC compute the actual state of the module.
This gests tricky, it can be done with some logic inside the PIC and enough pins for I/O. How many pins are available for this?





G. Hoffman

Well, I WANT to use a 12F509, cause I've got a bunch of SOICs laying around already, so that's an 8 pin device, with 5 I/O and one input only (the MCLR pin, which I don't need, but I don't like using the open collector inputs on PICs - you have to think too much about them).

If I had to, I could easily use something bigger, but I'd rather not.  I've got 16F84s, but I really don't want to use those (too expensive), 16F818s, 16F684s, 16F887s (too big for the purpose!), and a few others, but the whole point here was to use a nice simple PIC, and minimal other parts.  

Right now, two pins are the footswitch/LED pins, one is the front panel switch, and two are driving the actual relays for switching, as well as the front panel lights.  Those two are well isolated from the PIC by transistors, so they aren't drawing anything much from the PIC.  So really, all I have left is one I/O pin.  

Of corse the easy way out is to use a 4+1 MIDI cable, but I really don't want to do that!  Though I suppose I could set that up so that, if you used a normal MIDI cable you could still switch, you would just loose the LEDs.   That has a reasonable level of redundancy, though it is not ideal.  


Gabriel

greaser_au

#5
Gabriel,

Have you considered using  an ACcontrol signal,  such as the Fender SS amps use?  See this thread:  http://www.diystompboxes.com/smfforum/index.php?topic=79656.msg713831#msg713831. The schematic link is now dead, but the new link is:  http://support.fender.com/schematics/guitar_amplifiers/Princeton_112_Plus_schematic.pdf

This one:  
- uses a mono cable;
- controls reverb switching;
- controls the drive switching (and controls the front panel LED too);
- and has LEDs on the footswitch.
- downside is the Drive footswitch is overridden by the ON front panel drive switch and no footswitch LED in that case

Sorry if this is redundant- I always meant to run up a service level explananation for the other thread and here it is,  3-1/2 years later!:

Note the action of the footswitches/LEDs,  CR17/U6A  (drive) and CR20/U6B (reverb). U6A & U6B  are opamps wired as comparators.

Basically,  about 28V AC is applied to the  cable 'hot' lead via a resistor (R73) from the power amp rails. With all switches open the AC is allowed to swing both (+) and (-)  of ground. The two polarities of the AC signal can be considered separately. I'm a bit worried about the input voltage exceeding the  rails so there may be incorrect resistor values somewheres.

CR17 rectifies the (+) side of the AC cycle and applies it to the  inverting input of U6A (the pulsating DC after CR17 is lightly  filtered by C45). As the noninverting input is biased to 0.7V-ish by CR18, this drives it's output negative and  turns off the Drive channel (at U7B&C).   If S17 is closed,  the (+) voltage  is pulled down by CR16,  or if the 'Channel Select' footswitch is closed,  pulled down via the associated diode & LED (which lights up), and the inverting input falls to zero (due to R76) which allows the output to swing positive, this turns on the drive channel & the front panel 'Drive' LED.

The reverb switch works in a similar manner except opposite:  CR20 rectifies the (-) side of the AC cycle and applies it to the  inverting input of U6B (the pulsating DC after CR20 is lightly  filtered by C46).  As the noninverting input is biased to -0.7V-ish by CR18) this drives it's output positive and  turns off the reverb signal at U7A.   If the Reverb Select  footswitch is closed, the (-) voltage  is pulled to near zero by  the associated diode/LED (which lights up) - (or the footswitch is unplugged, pulled to near zero by  CR15)- and the inverting input falls to zero (due to R86) which allows the output to swing negative, this turns on the reverb signal at U7A.

hope this helps...
david

EDIT:  Gabriel, I posted before I read your last post... sorry, there's no PIC in this one!

G. Hoffman

More than I can look at right now, but that does look interesting, David.  Thanks for writing it up. 


Gabriel