REDUCING PIN USAGE IN MICROCONTROLLER

DEAR ALL.

I am using(LaunchPad MSP430G2553)

I am having totally 16 pins available I.e GPIO other than gnd/vcc/RST

i have totally 20 pin as out put.

4 for speed selector like 100,200,300,400,600in rpm using potentiometer(http://in.element14.com/multicomp/mcrm4 … dp/1522038)

4 for motion control selector fw,rv,stop using potensiomete(http://in.element14.com/multicomp/mcrm4 … dp/1522038)

2 for motor drive

2 for analog sensor

2 RTC pin(ds1307)

2 for GPS

4 for operation selector-> init ,manual, automatic,use defined.(http://in.element14.com/multicomp/mcrm4 … dp/1522038)

Is there any way to reduce pins for connection. I never want to go with resistor selector network. If any other method, please share me link

is there any way i can reduce my pin configuration using external circuit.

like MUX where i can give multiple input from selector and out put can read in analog format.

Those are not potentiometers, they are hex-encoded rotary switches. As you mentioned, you can use a resistor network (5 resistors per switch, three analog inputs needed rather than 12 digital ones). Other ways of reading the switches with fewer I/O pins include paralleling them with diodes (7 digital pins, think like a keyboard that lets you press multiple buttons at once) or use a parallel-in, serial out shift register (3 or 4 digital pins).

If you can find a GPS that uses I2C for interfacing, you could save two pins there.

/mike

AJITnayak:
4 for speed selector like 100,200,300,400,600in rpm using potentiometer(http://in.element14.com/multicomp/mcrm4 … dp/1522038)

4 for motion control selector fw,rv,stop using potensiomete(http://in.element14.com/multicomp/mcrm4 … dp/1522038)

4 for operation selector-> init ,manual, automatic,use defined.(http://in.element14.com/multicomp/mcrm4 … dp/1522038)

If you like the switches above, you'll find that you don't have to use all 4 of the pins to make the choices you've shown above.

The first set is only 5 choices and needs only 3 pins. The last 2 need only use 2 pins. Look at the truth table in the datasheet.

http://www.farnell.com/datasheets/1520809.pdf

Look at using just the pins labelled 1 and 2. Look what they do for positions 0,1,2 and 3. What you could do is connect the common pin on the switch to ground. Connect pins 1 and 2 to your microcontroller. Use pull-ups on those 2 pins.

(click on to enlarge)

When the switch is in position 0, both pins 1 and 2 will be shorted to common and so produce a logic low on both pins at the microcontroller.

When the switch is in position 1, pin 1 is an open and produces a logic high at the microcontroller. Pin 2 is still a logic low.

At position 2, those outputs are reversed. Pin 1 now makes a low, pin 2 now makes a high.

Lastly in position 3, both pins 1 and 2 are open and so both produce a logic 1. That’s 4 different combinations and so can represent (up to) 4 different choices.

If you use 1 more pin (pin 4) then you have 8 different combinations and that would be more than enough to choose between 100, 200, 300, 400, 600.

So smart use of the switches you’ve already selected means you only need 7 inputs instead of 12. Is that good enough ?

n1ist:
Other ways of reading the switches with fewer I/O pins include paralleling them with diodes (7 digital pins, think like a keyboard that lets you press multiple buttons at once) or …

@ the OP ...

Let’s say you’re not happy with the switches you selected, and to follow up on the above, you could use a common rotary switch and CharliePlex the I/O pins for each set of inputs (speed selector, motion control selector and operation selector) and thus reduce the pins needed, just as with the encoders above. Read the following link re: CharliePlexing. At the top it talks about CharliePlexing the outputs and then at the bottom it talks about CharliePlexing the inputs. It’s probably the clearest explanation I’ve run across.

http://pcbheaven.com/wikipages/Charlieplexing/

To do CharliePlexing you would use a pull-down resistor to ground on each pin and then alternate between making a pin an output and driving it to a HIGH while making other pins inputs. If the input(s) see a HIGH, the signal got through. If the input is a LOW, it didn’t. By doing a series of tests, alternating the inputs and outputs, you can determine what the switch position is. As a further example, perhaps you might choose to use a simple SP"N"T rotary switch. Here’s a common SP4T switch, but you can get them with as many throws as you like.

http://www.newark.com/productimages/nio … 579920.jpg

These are not “encoded” in any way. In each position the wiper makes a closure with 1 (and only 1) of the other pins. By adding diodes and doing the CharliePlexing routine you can determine in which position the wiper is. See the GIF below.

(click on to open and run … I hope)

please let me know simple circuit for doing above thing.i need all 4 combination for future purpose.

How i can do using diodes.

Mee_n_Mac:

AJITnayak:
4 for speed selector like 100,200,300,400,600in rpm using potentiometer(http://in.element14.com/multicomp/mcrm4 … dp/1522038)

4 for motion control selector fw,rv,stop using potensiomete(http://in.element14.com/multicomp/mcrm4 … dp/1522038)

4 for operation selector-> init ,manual, automatic,use defined.(http://in.element14.com/multicomp/mcrm4 … dp/1522038)

If you like the switches above, you'll find that you don't have to use all 4 of the pins to make the choices you've shown above.

The first set is only 5 choices and needs only 3 pins. The last 2 need only use 2 pins. Look at the truth table in the datasheet.

http://www.farnell.com/datasheets/1520809.pdf

Look at using just the pins labelled 1 and 2. Look what they do for positions 0,1,2 and 3. What you could do is connect the common pin on the switch to ground. Connect pins 1 and 2 to your microcontroller. Use pull-ups on those 2 pins.

(click on to enlarge)
[attachment=0]BCDswitch.jpg[/attachment]
When the switch is in position 0, both pins 1 and 2 will be shorted to common and so produce a logic low on both pins at the microcontroller.

When the switch is in position 1, pin 1 is an open and produces a logic high at the microcontroller. Pin 2 is still a logic low.

At position 2, those outputs are reversed. Pin 1 now makes a low, pin 2 now makes a high.

Lastly in position 3, both pins 1 and 2 are open and so both produce a logic 1. That’s 4 different combinations and so can represent (up to) 4 different choices.

If you use 1 more pin (pin 4) then you have 8 different combinations and that would be more than enough to choose between 100, 200, 300, 400, 600.

So smart use of the switches you’ve already selected means you only need 7 inputs instead of 12. Is that good enough ?

can you share me the circuit diagram or link for 2nd option.

n1ist:
Those are not potentiometers, they are hex-encoded rotary switches. As you mentioned, you can use a resistor network (5 resistors per switch, three analog inputs needed rather than 12 digital ones). Other ways of reading the switches with fewer I/O pins include paralleling them with diodes (7 digital pins, think like a keyboard that lets you press multiple buttons at once) or use a parallel-in, serial out shift register (3 or 4 digital pins).

If you can find a GPS that uses I2C for interfacing, you could save two pins there.

/mike

AJITnayak:
please let me know simple circuit for doing above thing.i need all 4 combination for future purpose.

How i can do using diodes.

I think I explained it with sufficient detail that anyone who lists themselves as an electronic engineer can figure out what to do. Stop being so lazy and at least put some minimal effort into it. People here are willing to help but we're not going to do your work for you.

AJITnayak:
can you share me the circuit diagram or link for 2nd option.

]

Oh come on…

Type “keyboard multiple buttons diode” into google gives [this as the second hit. I have given you all you need to solve this problem, using three different schemes. Now you either need to take it from there or, if you want someone to do all the work for you, hire a consultant.

/mike](How a Key Matrix Work)

Hi if you need to reduce your output pins usage , just use shift registers , it will let you use just only one pin to control an infinite number of devices .

Thanks. But the resistor are sensitive to temperature.So this variation cant be accepted.So any other solution you can come across.

himfire:
Hi if you need to reduce your output pins usage , just use shift registers , it will let you use just only one pin to control an infinite number of devices .

AJITnayak:
Thanks. But the resistor are sensitive to temperature.So this variation cant be accepted.So any other solution you can come across.

himfire:
Hi if you need to reduce your output pins usage , just use shift registers , it will let you use just only one pin to control an infinite number of devices .

Where are the resistors in the shift registers?

Surely an E.E. can compensate for temperature drift…

Or can they???

skimask:
Surely an E.E. can compensate for temperature drift…

http://www.youtube.com/watch?v=0A5t5_O8hdA

The question is … Temp drift, WTH ?

Ya temp drift…

Ya know, temporary drift, causes bits to end up somewhere in the shift register.

Surely you can’t be serial? :slight_smile:

There’s definitely some lost “bits” here … but they’re not in any shift register.

0100000101101110011001000010000001

1100110111010001101111011100000010

0000011000110110000101101100011011

0001101001011011100110011100100000

0110110101100101001000000111001101

1001010111001001101001011000010110

1100

:mrgreen:

http://www.bagill.com/text-converter.php