Shop OBEX P1 Docs P2 Docs Learn Events
More I/O Pins BS2P40 — Parallax Forums

More I/O Pins BS2P40

MRayMRay Posts: 4
edited 2007-09-01 06:28 in BASIC Stamp
Sorry if I posted this in the wrong place, I know there is a thread somewhere about this but I can't find it.

I have a project and I currently use three basic stamps, one stamp for each 3 digit Alphanumeric Stick.

I have Alphanumeric Displays each are 3 digits on one stick with 14 pins each stick is common anode. (I prefer anode.)
Anyway each three digit stick takes up 14 pins on any one stamp.

The Problem: Control each of the 14 segments with fewer pins, or find a way to add more pins to the Basic Stamp to accommodate three 3 digit Alphanumeric Displays.


Is it possible to control all 14 segments on one pin?

If not, Is there a way to shrink the amount of pins required?

My approach is to add extra I/O lines to the Basic Stamp, but I don't know how to do that.

Thanks

MRay

Post Edited (MRay) : 9/1/2007 4:21:38 AM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-09-01 04:22
    You can use a 74HC595 shift register (or several of them in series) to provide multiples of 8 output pins. The "chain" of 74HC595s use 3 I/O pins (one for clock, one for serial data, and one to transfer the data to the output pins from the shift register). You use the SHIFTOUT statement to transfer data to the shift register, then a HIGH/LOW pair to produce the output load pulse. Two of these in series will handle 16 outputs. There is always an issue of total current load. Assuming each LED uses at most 10ma, the total current per 74HC595 is only 80ma which is reasonable. If, for some reason, you were driving all 14 segments with the Stamp, your current load would be around 140ma which is a problem. This is better (to offload the high current stuff to several external chips).

    There are some examples of this in the StampWorks manual that you can download here.
  • MRayMRay Posts: 4
    edited 2007-09-01 04:32
    Thanks Mike for the reply it will take a while for me to interpret what you mean. I understand the shift register part, but programming is a bit difficult. Perhaps I will consult some examples of others work. The current is a good thing to bring up, each display is limited by a 220 ohm resistor to ensure that each display doesn't draw too much current. In the code, for example if I needed to turn on segments b and c to make the number 1, if they are connected through the registers, as an example how would I tell it to turn on segment b? The high/low you mentioned I am assuming means a clock pulse for the register. Then another high/low pulse would turn off the segment b? Thanks for your help. I am a college student in my first year of Computer Engineering so I appreciate any help I can get.

    Thanks.

    MRay
  • Mike GreenMike Green Posts: 23,101
    edited 2007-09-01 04:51
    Download the Stampworks manual (www.parallax.com/dl/docs/books/sw/Web-SW-v2.1.pdf). That will show you how to use the 74HC595. Assuming you have two of these connected in series to provide 16 output pins and you use the first 14 for your segments, you'd build a 16 bit value where the lower 14 bits correspond to the segments, one segment per bit. You would use the SHIFTOUT statement to transfer the 16 bits to the shift register. The SHIFTOUT takes care of the two I/O pins involved (see the PBasic manual for a description). You'd transfer LSB (least significant bit) first (you can do it either way ... MSB first or LSB first). After the SHIFTOUT, you'd produce the load pulse which would transfer the 16 bits to the actual output register and output pins. Get a copy of the datasheet for the 74HC595 so you can see how it functions and where the pins go.

    The programming is actually quite simple. If your bitmask (for the segments) is called MASK, you can access individual bits as variables like MASK.BIT1 or MASK.BIT0 for the least significant two bits. Again, read the PBasic manual to see how to get at parts of words or bytes.
  • MRayMRay Posts: 4
    edited 2007-09-01 05:10
    Oh I think I get it. Would it be a nibble or a byte? I am assuming a nibble 8421 loaded into the shift register and the corresponding string of the nibble would indicate which segment of the display is lit. %0001 would be a 1, and &1001 a 9. I have a little experience from my associates degree dealing with registers, but we never really dealt with micro controllers, at least not until I got here to University. 4 bit nibble, 8 bits is a Byte 16 bits a word. I think a nibble will suffice as there are only 14 segments and 8421 will address up to 16 in binary. I think I get what you are saying about the masking part, before I ask anymore I will consult the manual and get back to you with any questions I might have. Thank very much this is a huge push in the right direction. Again thanks Mike Green for your help.

    MRay
  • Mike GreenMike Green Posts: 23,101
    edited 2007-09-01 06:21
    Forget the nibble thing for now. If you wire up the segments so the most distant shift register bit is segment a and the next closest to the Stamp is segment b ... and you send the data out LSB first from the word variable MASK, then the value in MASK represents the following: %00nmlkjihgfedcba. To access what will be the segment d value, use MASK.BIT3. To access what will be the segment n value, use MASK.BIT13 and so on. You could build a font table in EEPROM using the DATA statement and read it using the READ statement (look in the manual!) with each entry occupying a word. That's only 256 bytes for a character set of 128 characters. The address of the word would be the character value times two (two bytes in a word!) Anyway, you'll figure it out once you familiarize yourself with the manuals and datasheets and ...
  • MRayMRay Posts: 4
    edited 2007-09-01 06:28
    Thanks Mike,

    I have to get some sleep I will check out the manuals and get back to you on my progress, thanks for the heads up.

    MRay
Sign In or Register to comment.