Author Topic: multiplexing inputs and outputs - comments?  (Read 4205 times)

0 Members and 1 Guest are viewing this topic.

Offline Clear as mudTopic starter

  • Regular Contributor
  • *
  • Posts: 208
  • Country: us
    • Pax Electronics
multiplexing inputs and outputs - comments?
« on: July 13, 2013, 01:24:10 am »
I'm new here, and having a bit of a problem with the forum.  It timed out.  Also I must not have correctly pressed CTRL-C to copy what I had written.  So, I lost my long description of my exact application and all my comments.  Maybe I'll have time later to describe it again.  For now, just take a look at the attached image, and tell me what you think.

Thank you,
Daniel
 

Offline Skimask

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
Re: multiplexing inputs and outputs - comments?
« Reply #1 on: July 13, 2013, 02:02:56 am »
OK, so let me get this straight, you don't have time to describe it now, but we have time to look, read, try to figure out what you're going to ask, and formulate answers to any number of questions you might have.
Is that about right?
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5093
  • Country: ro
  • .
Re: multiplexing inputs and outputs - comments?
« Reply #2 on: July 13, 2013, 02:14:01 am »
 
Quote
For now, just take a look at the attached image, and tell me what you think.

Honestly, I can't be bother to think what happens there.

Lots of transistors and lots of resistors and diodes take as much space or even more space than what a few shift registers would take. 
A shift register takes 3 pins from a microcontroller and makes 8-16-24 etc (because you can chain shift registers).
Just the same... array of buttons ... parallel to serial shift registers and bob's your uncle, another 3 pins of microcontroller, so in total 6 pins.

led segments ... you can use common cathodes one and at any point have only 1 segment out of 7 in a digit lit up so you only need one resistor at the cathode , then when you're done with a digit you move on to next one and so on.. persistence of vision solves the issue.
use something like uln2003a or uln2803a on the cathodes so you can use other shift registers to select which digits' cathodes are sinked to ground etc...

 

Offline WarSim

  • Frequent Contributor
  • **
  • Posts: 514
multiplexing inputs and outputs - comments?
« Reply #3 on: July 13, 2013, 07:05:07 am »
I did notice the NAND or NOT notation but that is incorrect a NAND will not be the same as NOT wired like that. 
I believe you are trying to use bank selection but there are a few errors.
Too many for me to figure out which method you are going for. 
 

Offline MasterOfNone

  • Regular Contributor
  • *
  • Posts: 123
Re: multiplexing inputs and outputs - comments?
« Reply #4 on: July 13, 2013, 10:05:55 am »
Sorry I give up, I don’t understand how them buttons can ever be read. As per WarSim's post even it you got the NAND gate right (don’t leave the inputs floating tie them together),  the circuit would still only read the inverted K output on the “n I/O” pins. Did you mean to connect the input of the NAND (or Not) to the Cathode of the Diode :-//
 

Offline Clear as mudTopic starter

  • Regular Contributor
  • *
  • Posts: 208
  • Country: us
    • Pax Electronics
Re: multiplexing inputs and outputs - comments?
« Reply #5 on: July 16, 2013, 04:35:32 am »
Sorry for being so frustrated last time.  It's been a while since i used a forum based on this software, and I forgot about the stupid feature that makes it time out after a fixed time regardless of whether the user has clicked anything or not.  I had it set on an hour, so I guess I spent over an hour describing my questions, and then lost it all and I was very tired and frustrated.

My application is a timer for my local chapter of Toastmasters.  It's for timing speeches, and it has three lights, green, yellow, red, to let the speaker know if they've spoken for long enough or too long.  I plan to have some buttons and indicators on the back for the person controlling it, and a time indicator.

Shift registers - I thought of that first, but it seemed like it was getting more and more complicated, with the chained shift registers.  Part of the problem is that I planned to use a 4-digit 7-segment display in my application.  This has everything already multiplexed internally and only brings out the 8 lines for each digit, plus 4 for digit select (actually 5 because one is for the colon in the middle).  So, I couldn't just use chained shift registers, one for each digit.  This plan I drew up seemed to be simpler.  But, I will have to consider that some more and see if shift registers make more sense. Like you said, just use three pins for any amount of button inputs by chaining them together.

NAND - I should have explained that better.  I didn't draw it up correctly on the diagram, because it should have k inputs and one output.  So, the inputs shown disconnected should really be thought of as optional, depending on the value of k.  There will be one input for each microprocessor output line feeding each bank of n buttons (I think normally n would equal 8, or at least it does for my application).  For my timer control, I have only 6 or 5 buttons, so that can fit into a 1 x 8 array with room to spare, and my k=1 and n=8.  Because k=1, I use a 1-input NAND, which is really just a NOT.  The output goes to all eight lines of the I/O port via eight 5k resistors.  So it needs 8mA output drive capability, which I think is higher than normal and that is why I suggested augmenting it with additional gates with inputs in parallel (outputs each driving only some of the 5k resistors).

I'll take another look at the shift register option.  I guess I could use two of them, one for the display and one for the buttons, but the problem is the display I planned to use is internally multiplexed, so I would have to write serial data five times each refresh cycle, and that's a lot of instruction cycles for the microprocessor.  It seemed better to use a few more pins and output parallel data.  So, hooking up the display would use 12 I/O pins, but if my multiplex method works as expected, I only will need one additional pin for the buttons.
 

Offline WarSim

  • Frequent Contributor
  • **
  • Posts: 514
multiplexing inputs and outputs - comments?
« Reply #6 on: July 16, 2013, 05:28:42 am »
A button matrix only needs one wire . How many wires you use entirely depends on your implementation.  This is assuming you are not using a pre-made button matrix. If it a pre-made i did not get enough details to say if your plan will work.
You said you are going to a uC.  For example, a totem matrix is n+1 resistor and 1 AD channel. 
You mentioned you have a pre-made display.  And something about a lot of clock cycles.  I am using a 16Mips PIC to be the display driver for a 320x240 LCD with 7Mips to spare.  Clock cycles to handle everything should not be a problem.  Assuming you are not using a strange 100kips uC. 
 

Offline C

  • Super Contributor
  • ***
  • Posts: 1346
  • Country: us
Re: multiplexing inputs and outputs - comments?
« Reply #7 on: July 16, 2013, 08:40:02 am »
you stated
Quote
multiplexed 7-segment display 4-digit + colon -digit
Display looks like 8-segment display 5-digit
6 or 5 buttons
three lights, green, yellow, red

multiplexed led display come in two versions
(CC or Common Cathode) where all the segments for a digit are Cathode connected to digit line.  Digit line active low.
(CA or Common Anode) where all the segments for a digit are Anode connected to digit line. Digit line active high.

Segment output 
8 output mpu pins to optional current buffer to segment current limit resister to segment pin on display.

Digit output
Digit current = 8x segment current.
Most logic can not sink or source required current for digits. Only one digit active at a time.
5 output mpu pins needed to high current buffer to digit pin on display.

Switches
1 input mpu pin with resistor pull-up | pull-down to level opposite active digit level.
This pin is also connected in common to 5 switches. Each switch connected in series to a diode and then to mpu digit output pin. When switch is pressed, the active digit conducts through the diode, switch and puts active digit level to mpu pin in place of the pull resistor level. The diode allows push-pull driver to be  used for active digit to switch matrix and prevents problems when two switches are pressed at the same time.   

three lights, green, yellow, red: Here in place of three mpu pins, you could treat these as an additional digit for a savings of two pins. The extra digit also allows a 6'th switch.

This far for MPU pins you have
8 outputs for segments
5 outputs for digits or 6 if you treat the green, yellow, red lights as segments of a digit.
1 input for 5 switches or 6 if lights are as above
Using one more input pin would gain digit count switches.

Software for this would be
read switch state for currently active digit.
turn off currently active digit to prevent ghosts
update segment output to new digits data
make new digit line active.

Going to extreme with added chips and more software you could get down to 4 pins.


C


 

Offline Clear as mudTopic starter

  • Regular Contributor
  • *
  • Posts: 208
  • Country: us
    • Pax Electronics
Re: multiplexing inputs and outputs - comments?
« Reply #8 on: July 16, 2013, 02:00:13 pm »
C, I see what you are saying.  Use the drive pin for each digit to also feed a switch, all switches connected in common (through diodes) to an input line.  Then each time one digit is active, read one switch state.
Yes, that is simpler than what I was proposing.  So, instead of a n x h array of LEDs and an n x k array of switches, your scheme would allow for an n x h array of LEDs and a h x k array of switches.  (which is fewer in my case, but also extensible to any number in theory.)  Your method also has the advantages of requiring fewer components, not requiring the n output lines to switch to inputs to read switch states, and avoiding the associated times when no multiplexed LEDs are driven.

WarSim, you are right, I would have enough clock cycles to output everything serially, but I wasn't relishing the increased complexity of software.  But, it is just software.  Easier than increased complexity of hardware.  Given C's suggestion to decrease my hardware complexity, I believe a shift register would increase my hardware complexity at this point.  I do like your suggestion of totem matrix with A/D.  I hadn't thought of doing it that way.  I don't think I need it for this project, but will keep it in mind for future ones.

Thank you,
Daniel
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 7910
  • Country: de
  • A qualified hobbyist ;)
Re: multiplexing inputs and outputs - comments?
« Reply #9 on: July 16, 2013, 02:59:59 pm »
What about a MAX7219 for the LED matrix/7-segments and a MCP23S08/17 for the buttons (both use SPI)? The MCP23S08 can generate an interrupt if a button is pressed.
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5093
  • Country: ro
  • .
Re: multiplexing inputs and outputs - comments?
« Reply #10 on: July 16, 2013, 04:36:16 pm »
You can get a pic16f1508 for a dollar or less : http://www.digikey.com/product-detail/en/PIC16LF720-I%2FSS/PIC16LF720-I%2FSS-ND/2601513

internal oscillator, i2c, spi, 20 mhz.. 17 io pins
Get a bunch of 100 and 1k resistors and use them for both current limiting lcd segments and for a resistive ladder for the buttons (0hm, 50ohm, 100 ohm, 200 ohm, 500 ohm, 1kohm, 2kohm and you have 7 buttons on one pin)   and use 2-3 pins of the pic for doing adc on lots of buttons
then use i2c or spi to pass the state of buttons and receive what to display on leds several times a second.
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 8519
  • Country: us
    • SiliconValleyGarage
Re: multiplexing inputs and outputs - comments?
« Reply #11 on: July 16, 2013, 04:53:44 pm »
82c79

does all the work for you and even has keyboard fifo's and programmable scan rate. costs next to nothing...
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline C

  • Super Contributor
  • ***
  • Posts: 1346
  • Country: us
Re: multiplexing inputs and outputs - comments?
« Reply #12 on: July 16, 2013, 09:40:47 pm »
 
Quote
and avoiding the associated times when no multiplexed LEDs are driven.
Not normally a good idea to skip a digit with all blank segments as this will change the brightness of the remaining displayed digits.

If you want to change the brightness of the display, you could have a second function that happens during the digit time and turns off some segments. Turning off segments at half digit time would give you 50% brightness.

The full all digits output is normally called a frame
A flash is just outputting Q count of frames with segment data followed by R count of all off segment data.

You need to remember that the fast edges and current changes to the LED's creates EMI

You can also use the digit scan rate to help with switch bounce. You count up|down each time you read the switch in the display loop to a max value. A down count a lower limit of 0 could be switch open while a count up at limit of 10 could be one and would only get here by having 10 more on readings then off readings(switch bounce).
You can change the order of the digit lines to make software easer, move the Colon Digit to one end of the numbers for example.

If you really need to save pins you could connect a 3 to 8 or a 4 to 16 decoder, the 3 or 4 to the mpu pins and the output to the digit lines. Your software then just outputs the integer of the digit in place of doing the 3 to 8 or 4 to 16 in software.

Don't forget a startup test of all leds on, great way to verify the displays are working.

C
 

Offline Clear as mudTopic starter

  • Regular Contributor
  • *
  • Posts: 208
  • Country: us
    • Pax Electronics
Re: multiplexing inputs and outputs - comments?
« Reply #13 on: August 29, 2013, 03:54:24 am »
It has been a while.  I apologize for taking so long to reply.  I was working on other projects for a while, but I want to get back to this one and finish it up.  I plan to use the suggestion given by C for the multiplexing of buttons with LED display, reading the status of one button with each frame.  And, I had already thought of a very similar method of debouncing to the one suggested in the last reply, so I am definitely going to do that.  But I am a little bit worried about the EMI. 
You need to remember that the fast edges and current changes to the LED's creates EMI
I had planned to cycle through all frames of the multiplexed display 200 to 500 times per second, and there will be five frames, so each character will stay on for about half a ms.  I'll be running each segment at about 30 mA (with a 1/5 duty cycle), and with up to eight segments on at a time, that could be 150 mA being quickly and repeatedly switched.  Will it reduce EMI if I put a capacitor at the base of the drive transistor for each character, so that the LEDs switch on and off more slowly?  I'll have to make it small enough to charge/discharge at least an order of magnitude faster than 1/2 ms.  I'm not sure this is the best approach.  I think it would lead to ghosting.
The main lights (the ones seen by whoever is giving a speech) will be more powerful, but I don't think I will attempt to multiplex them, so they won't be turning on and off at a fast rate.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf