Shop OBEX P1 Docs P2 Docs Learn Events
Need more outputs — Parallax Forums

Need more outputs

MtnFlyerMtnFlyer Posts: 28
edited 2009-04-19 01:48 in BASIC Stamp
I'll apologize in advance for this one... I'll bet it's been answered a hundred times, but I can't find it using the search engine.

I simply need more outputs. I'm trying to control a tree of LED lights (4 LEDs in each row, see attachment "LED_tree.pdf"), and I've got 20 rows of lights to switch on/off at very particular times depending on an input voltage (see attachment "relay_schedule.pdf"). Is there an "expansion module" that would give me more outputs on a BASIC Stamp?· Or maybe a simpler solution I'm not seeing? My plan is to have each output drive a switching transistor to light the row at the appropriate time.

Thanks, Jim

Comments

  • Mike2545Mike2545 Posts: 433
    edited 2009-04-14 18:39
    You can use the 74HC595 as outlined on page 130 of the Stampworks manual

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike2545

    This message sent to you on 100% recycled electrons.
  • MtnFlyerMtnFlyer Posts: 28
    edited 2009-04-14 19:09
    Thanks, Mike. I especially like this part:

    "Being serial devices, shift registers can be cascaded. By cascading, the BASIC Stamp is able to control dozens of 74x595 outputs with the same three control lines."

    I appreciate your help. --Jim
  • Mike2545Mike2545 Posts: 433
    edited 2009-04-14 19:28
    Great way to "free up" I/O pins on the stamp. Might have to re-write your program.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike2545

    This message sent to you on 100% recycled electrons.
  • MtnFlyerMtnFlyer Posts: 28
    edited 2009-04-14 22:34
    No program yet, so no rewriting! |^)
  • MtnFlyerMtnFlyer Posts: 28
    edited 2009-04-14 23:18
    Mike,

    Would you think the attached configuration would work. Would you make any suggestions?

    Jim
  • Mike2545Mike2545 Posts: 433
    edited 2009-04-15 01:21
    You say 20 output pins from the 74HC595 I assume you mean to use 3 of them.

    You will need to pick the correct resistor for your LEd's for the 12v shown on your diagram but it looks good.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike2545

    This message sent to you on 100% recycled electrons.
  • arthuranderson14arthuranderson14 Posts: 6
    edited 2009-04-15 02:13
    Hi,

    You can take a look at MM5450N (1 Jameco Part# 26171) as well. I just used it to drive 4, 7 segment LED displays. It doesn't do any multiplexing... Two stamp pins will get you 34 pins to control your LED's. You can use shiftout to send the bits to control the pins... The chip is a little on the large side.

    Here is a sample of the code I used...

    '
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    '
    'Define Pins
    '
    'MM5450N #1 Pins - Used for 4 digit display
    CLK1 PIN 0 'clock attached to pin 21
    SDATA1 PIN 1 'serial data to pin 22

    sBIT CON %1 'first bit sent required
    eBIT CON %000 'bits 33, 34 not used + one I need to check on

    '
    ' MM5450N 7 SEGMENT LED BINARY DIGIT MAPPING !!No Decimal pnt. ctrl.
    '
    'Map binary numeric digits to constants
    d0 CON %11111100 '0 - abcdef 1111110
    d1 CON %01100000 '1 - ef 0000110
    d2 CON %11011010 '2 - abdeg 1101101
    d3 CON %11110010 '3 - abcdg 1111001
    d4 CON %01100110 '4 - bcfg 0110011
    d5 CON %10110110 '5 - acdfg 1011011
    d6 CON %00111110 '6 - cdefg 0011111
    d7 CON %11100000 '7 - abc 1110000
    d8 CON %11111110 '8 - abcdefg 1111111
    d9 CON %11110110 '9 - abcfg 1111011
    blank CON %00000000 '0000000

    '
    ' Start Program
    '

    Main:
    GOSUB numericTest 'display 8888
    GOTO Main

    numericTest:
    'Display 8888 on display
    SHIFTOUT SDATA1, CLK1, 1, [noparse][[/noparse]sBIT, d8 , d8 , d8 , d8 ,eBIT]
    RETURN
  • MtnFlyerMtnFlyer Posts: 28
    edited 2009-04-15 03:18
    Mike,

    No, unless I misunderstand. I thought I would use 3 output pins from the BASIC Stamp to control the outputs of the 74HC595s (8 output pins on each). So my intent was to cascade three 74HC595s and use 20 of the 24 output pins to drive LEDs.


    Arthur,

    Thanks for providing another avenue to look at! I will check it out.

    --Jim
  • Mike2545Mike2545 Posts: 433
    edited 2009-04-15 03:28
    Yes that is right, you need 3 74HC595's cascaded to get a total of 24 output pins, of which you will be using 20. This will tie up 3 I/O pins on the Stamp.

    Them being 74HC595

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike2545

    This message sent to you on 100% recycled electrons.
  • MtnFlyerMtnFlyer Posts: 28
    edited 2009-04-15 03:30
    Arthur,

    The MM5450N may work, but I'm not sure how best to do it. From the data sheet, it looks like the pins acts as sinks, taking the LED current to ground. They are limited to 15mA each, but I need to sink 120mA at each pin. Maybe I could use the pin to switch a transistor so that the pin just sees the base current and doesn't have to absorb all the collector current? I'm not very experienced in this area.

    --Jim
  • MtnFlyerMtnFlyer Posts: 28
    edited 2009-04-15 03:56
    Maybe something like the attached would work with the MM5450N (use a PNP instead of NPN transistor). Comments?
  • Mike2545Mike2545 Posts: 433
    edited 2009-04-15 04:03
    Either way would work I am not familiar with the MM5450N, but that has never stopped me from trying new things in the past!

    One of the great things about electronics is there is usually more than one way to make things happen. In the end it comes down to what you are comfortable with and how much support you can get if things go wrong.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike2545

    This message sent to you on 100% recycled electrons.
  • MtnFlyerMtnFlyer Posts: 28
    edited 2009-04-15 05:22
    OK. I don't think my latest diagram for the MM5450 is going to work. The way the 5450 appears to work is that the pins hang out normally at 3V. The hot side of the LEDs are also 3V. So no current flows.

    When a pin goes "active", the votage on that pin drops to 1.8V, so now theres a 1.2V difference and current flows throught the LED.

    In my drawing, I would have to somehow bias the emitter side of the transistor to 3V to keep the PNP transistor from letting current flow to ground. I don't know how to keep the emitter at 3V while keeping my LED source voltage at 12V.
  • arthuranderson14arthuranderson14 Posts: 6
    edited 2009-04-15 14:30
    Hi ,

    Looks like you figured out how the chip works. The chip was designed for common anode 7 segment LED's... So·the anode of your LED(s) would go to·+ and and cathode to the MM5450 PIN.· So far I have only used the chip for 7 segment displays and 5mm led's·as indicator lights for a prototype.·I will likely face the same issue·when I scale·up·my project so·I will think about it. ·I do know if you aren't using all the pins you can increase the current output per pin.· Page 5 of the datasheet· has the calculation: http://www.datasheetcatalog.org/datasheet/Micrel/mXsvtxr.pdf

    "For applications where a lesser number of outputs are used, it is possible to either increase the current per output, or operate the part at higher than 1V VOUT. The following equation can be used for calculations.
    TJ = (VOUT) (ILED) (No. of segments) (124°C/W) + TA
    where:
    TJ = junction temperature + 150°C max
    VOUT = the voltage at the LED driver outputs
    ILED = the LED current
    124°C/W = thermal resistance of the package
    TA = ambient temperature"

    Here is a pretty decent·use of the chip that may help if you decide to use it.

    http://www.ledsales.com.au/pdf/backlight_kit.pdf

    Thanks...
  • arthuranderson14arthuranderson14 Posts: 6
    edited 2009-04-15 14:39
    On an unrealted note, if some one runs into my code example looking to drive a 7 segment LED, I wired it a bit whacky... Here is how the pins are wired for the code example in this thread:

    '
    ' MM5450N wiring
    '
    ' 7 Seg. Common Anode Pin Layout (4 Jameco part #335021)
    ' a· -|······· |-NA
    ' f·· -| ······ |-b
    'ca· -|
    '····· ········· |-g
    '······ ········ |-c
    'NA-|· ····· ·|-dp
    'e·· -|········|-d

    ' MM5450N (1 Jameco Part# 26171) / 4 - 7 SEGMENT LED WIRING
    ' DIGIT 1 = PINS 18 -> 11 (A=18 B=17 C=16 D=15 E=14 F=13 G=12 [noparse][[/noparse]DP]=11)
    ' DIGIT 2 = PINS 10 -> 3 (A=10 B=9 C=8 D=7 E=6 F=5 G=4 [noparse][[/noparse]DP]=3)
    ' DIGIT 3 = PINS 2,40 -> 34 (A=2 B=40 C=39 D=38 E=37 F=36 G=35 [noparse][[/noparse]DP]=34)
    ' DIGIT 4 = PINS 33 -> 26 (A=33 B=32 C=31 D=30 E=29 F=28 G=27 [noparse][[/noparse]DP]=26)
    ' BIT Order (BITS 1 - 32) BITS 33 and 34 not used, defined in eBit
    '·············· DIGIT 1·················· |······· DIGIT 2················· |··············· DIGIT 3··········· |·········· DIGIT 4
    'SEG A·· B·· C··D· E·· F·· G· DP· |·A· B· C·· D·· E·· F· G· DP·· | ·A ·B ·C · D · E · F ·G · DP· |· A ·B · C · D ·E · F · G ·DP
    'BIT· 1·· 2·· 3·· 4··5·· 6·· 7·· 8· |· 9·10 11 12 13 14 15 16·· | 17 18 19 20 21 22 23 24· | 25 26 27 28 29 30 31 32
    'PIN 18 17 16 15 14 13 12 11 | 10· 9· 8·· 7·· 6·· 5·· 4· 3··· | 2· 40 39 38 37 36 35· 34 | 33 32 31 30 29 28 27 26

    Post Edited (arthuranderson14) : 4/15/2009 2:50:04 PM GMT
  • vaclav_salvaclav_sal Posts: 451
    edited 2009-04-15 16:20
    I·use Maxim MAX7219 - Serially interfaced (I2C style )·8 - digit LED display driver chip.
    Basicaly· 8x8 matrix with intensity control.
    Cheers Vaclav
    ·
  • MtnFlyerMtnFlyer Posts: 28
    edited 2009-04-15 17:25
    That looks promising, Vaclav. Each sink can take 500mA---this might work for me.· Thanks!

    Jim
  • arthuranderson14arthuranderson14 Posts: 6
    edited 2009-04-15 17:40
    Hi Vaclav,

    Do you have a· BS2 code snippet for the MAX7219?

    Thanks,
    Eric

    Post Edited (arthuranderson14) : 4/15/2009 5:48:32 PM GMT
  • Mike2545Mike2545 Posts: 433
    edited 2009-04-15 17:47
    I think you have to use shiftout for the Max7219

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike2545

    This message sent to you on 100% recycled electrons.
  • arthuranderson14arthuranderson14 Posts: 6
    edited 2009-04-15 18:28
    Looks like that is correct. I was able to find the following:

    http://www.parallax.com/dl/docs/books/sw/exp/sw29.pdf

    Looks like the Max7219 chip is a better solution since it will reduce the amount of wiring required. If you need to control more that 34 LED's, a single chip can be used instead of two MM5450N's. I guess the down side is Max7219 costs around $13 while the MM5450N is about $4. Still worth it if you need to control more than 34 LED's (segments) and consider the extra wiring.

    MM5450N - 34 LED's / direct conect to pin / Common Anode / Uses 2 stamp pins
    Max7219 - 64 LED's / multiplexing / Common Cathode / looks like 3 stamp pins

    Programing the Max7219 might be a bit more complex...
  • Mike2545Mike2545 Posts: 433
    edited 2009-04-15 20:10
    I have been unsuccessful getting my MAX7219 to work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike2545

    This message sent to you on 100% recycled electrons.
  • Mike2545Mike2545 Posts: 433
    edited 2009-04-17 02:30
    You can use these http://www.nalanda.nitc.ac.in/industry/datasheets/Texas_analog/SLIS032.pdf

    They are like the 74HC595 on steroids. 150 mA per channel

    Or this one with 16 outputs STP16CP05 found here http://www.datasheetdir.com/STP16CP05+LED-Drivers

    Or this one with 35 outputs www.micrel.com/_PDF/mm5450.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike2545

    This message sent to you on 100% recycled electrons.

    Post Edited (Mike2545) : 4/17/2009 2:37:05 AM GMT
  • MtnFlyerMtnFlyer Posts: 28
    edited 2009-04-17 03:36
    Mike,

    Thanks very much for the info. I went ahead and ordered the MAX 7221 http://datasheets.maxim-ic.com/en/ds/MAX7219-MAX7221.pdf

    I'll let you know how it goes!

    Jim
  • arthuranderson14arthuranderson14 Posts: 6
    edited 2009-04-17 03:57
    Hi Jim,

    I think I am going to give the MAX 7221 a try when I scale up my project. If you get the chip to work it would be great if you could post a code example.

    Thanks,
    Eric
  • Mike2545Mike2545 Posts: 433
    edited 2009-04-17 03:58
    Please do, I asked them nicely and they sent me a free sample, I can't get it to work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike2545

    This message sent to you on 100% recycled electrons.
  • MtnFlyerMtnFlyer Posts: 28
    edited 2009-04-17 04:02
    Eric,

    I will do that. -Jim
  • vaclav_salvaclav_sal Posts: 451
    edited 2009-04-17 14:57
    Hi everybody,

    Here is my "work in progress" copy of MAX7219 code.

    On top of "standard" disclaimer (your mileage will vary) I need to tell you that my coding style is

    1. Keep everything until all is working

    2. Use DEBUG

    3. Comment, comment, comment

    So, the code has some redundant lines and lots of comments.

    ·

    The hardest part of using MAX 7219 is its setup (see LOOKUP code), read documentation.

    Do not forget the intensity resistor and make sure it is OK for your application.

    I am currently incorporating part of the code into another application - so I am not taking any comments out, not yet.

    Any questions – ask. Be patient - I may be slow to respond.

    ·

    ·

    ·
  • MtnFlyerMtnFlyer Posts: 28
    edited 2009-04-19 01:23
    I successfully added three 74HC595 shifters to the BS2 today.· What a relief.· I also was able to integrate a transistor switch to operate the LEDs.· I've got 24 output channels now.· I'm a BS novice, so this was a good day.

    --Jim

    Edit:· I had the MAX7221 chip available too, but that proved to be problematic.· I didn't realize I would need something between the chip and my LED tree---namely an display controller.· I should have caught that.
  • vaclav_salvaclav_sal Posts: 451
    edited 2009-04-19 01:48
    Good work Jim. I guess you just proved that there is more than one way to skin a cat!

    Cheers

    Vaclav
Sign In or Register to comment.