12F683 too few outputs

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
I have a circuit that uses two ADC inputs, and I need four digital outputs from the 12F683. Three of the outputs are for LED indicators (on/off) and one is for an LCD. The only spare GPIO is GPIO.3, which is input only.

Any suggestions (other than a larger PIC)?

Thanks.
 
Last edited:

JohnInTX

Joined Jun 26, 2012
4,787
Stack 2 LEDs and 2 resistors from V+ as anodeLED1cathode->R1->R2->anodeLED2cathode->GND. Make V+ about 1.5*Vforward of the LEDs (use a zener between V+ and LED1 if you need to). Connect a GPIOutput to the junction between R1 and R2.

Output=1 turns on LED2
Output=0 turns on LED1.
HIz turns both off.

It may be easier to make the voltages work by using 2 zeners, replacing R1 and R2, and have a single resistor between the zeners and the PORT. The idea is that V+ for the series LEDs/zeners is not enough to light them when the PORT is HIz but the port sinking or sourcing will be enough to turn one on.

You also could run 2 LEDs in inverse parallel, one node to the port and the other to a voltage divider, zener supply etc. at 1/2 Vdd.

To be able to turn both on at once you run a 50% duty cycle output to PORTx all the time and use the TRISx bit, sync'ed with the output level to determine whether the LED is off or on on its 1/2 cycle.

I don't know if it buys you anything over Charlieplexing but it may be simpler to code.

BTW any of these schemes will likely require the GPIO port to be shadowed i.e. flip the bits on a byte in RAM then movwf GPIO rather than using bcf, bsf.

(I'd still opt for the larger PIC)
Me too.
 
Last edited:

MMcLaren

Joined Feb 14, 2010
861
Can you tell us about the one pin LCD, please? Is this a serial LCD? If so, does it have some digital outputs that could be used for the LEDs? If not, you might be able to patch into the four LCD data lines and use them to mux' four switches onto a single I/O pin and four LEDs onto a single I/O pin (three pins total for LCD, switches, and LEDs).

Cheerful regards, Mike
 

Attachments

Last edited:

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
Okay, I should have provided more information.

This is a thermostat. The two analog inputs are the sensor and the setpoint voltages. The four outputs are: one to a MOSFET to switch a heater (or fan, or cooler) on/off as required, one to an LED that indicates a "too cold" condition, one to an LED that indicates a "too hot" condition, and one to a serial LCD that will be used only during programming of the micro-controller. The "too cold" and "too cold" LEDs will never be on simultaneously, but can be off simultaneously, which makes me think that one digital output from the μC could be used to control both LEDs, but I can't quite think how to do it. Note that the "too cold" and "too hot" LEDs do not coincide with the on/off operation of the MOSFET drive pin.

Thanks for the feedback.
 

Art

Joined Sep 10, 2007
806
You can use an IO pin's tris register to either source or sink current for an LED,
so you should be able to use two LEDs connected with opposite polarities
to the same IO pin and alternate the pin's tris and state to do all but switch both LEDs on at the same time.
 

THE_RB

Joined Feb 11, 2008
5,438
You can put two LEDs on the two ADC input pins. Use a series resistor from the PIC pin to the LED anode, then the LED cathode goes to ground. The ADC connects through another resistor to the same PIC pin.

To light the LED you turn the pin to an output for about half the time. This is done at >100 Hz so the user won't see the LED flicker. The other half of the time, the pin will work fine as an ADC input (provided the analogue voltage is less than the 1.2v which is the Vf of the LED).

Total cost; 2 extra resistors.
 

t06afre

Joined May 11, 2009
5,934
You could also implement it such as continuous on. Is one kind of status. Slow blinking is a second, and fast blinking is third status. Blinking is good for error condition. As it is easy to spot.
 

ErnieM

Joined Apr 24, 2011
8,377
This is what Art said:



I drew it before I read his post I swear! :D

Since the LCD is only used during programming I would have to ask why this same pin could not do that function also? Share 2 LEDs and one LCD all on the same pin.

It's way more practicable then sharing an analog input with a digital output.
 

Attachments

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
I think I am going to first try the dual LED approach, but with a two color LED. The LED will show one color for "too cold" (blue would be nice) and a different color for "too hot" (red would be nice). I don't suppose there is such an LED, but it won't hurt to look.

Thanks, guys.

In the following diagram, if the pin is set to be an input, won't both LEDs light dimly?

 

Attachments

Last edited:

Art

Joined Sep 10, 2007
806
I think bicolour LEDs will have the wrong terminals connected together internally, you would need access to all four pins of the package :(
 

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
Since the LCD is only used during programming I would have to ask why this same pin could not do that function also? Share 2 LEDs and one LCD all on the same pin.
Because I want to see the LEDs operate while I am looking at data from PIC on the LCD.
 

ErnieM

Joined Apr 24, 2011
8,377
You could get rid of the glow with some more series diodes. How many depends on the supply voltage and the type of LEDs used.

Yes, it's a kludge, but so is not going with a PIC with enough pins. :rolleyes:
 

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
You could get rid of the glow with some more series diodes. How many depends on the supply voltage and the type of LEDs used.

Yes, it's a kludge, but so is not going with a PIC with enough pins. :rolleyes:
I suppose it's my frugal nature to try to squeeze the most of every nickel. What really bugs me is having GPIO.3 doing nothing.
 
Top