Stamp 2 Traffic Light

This is the place for any magazine-related discussions that don't fit in any of the column discussion boards below.
Post Reply
Shing
Posts: 34
Joined: Tue Feb 18, 2003 1:01 am
Location: Dublin, Ireland
Contact:

Stamp 2 Traffic Light

Post by Shing »

Hi,<p> I'm trying to implement three sets of traffic lights using LEDs at a T-Junction for a project using the Stamp 2 Microprocessor. The main problem that I am having is how to actually control so many LEDs with the limited amount of input/output pins on the Stamp. Any ideas would be greatly appreciated.<p>Regards,
Wai Shing
josmith
Posts: 340
Joined: Tue Dec 04, 2001 1:01 am
Contact:

Re: Stamp 2 Traffic Light

Post by josmith »

Assuming you have nine leds you should be able to multiplex them in a 3x3 matrix.
Shing
Posts: 34
Joined: Tue Feb 18, 2003 1:01 am
Location: Dublin, Ireland
Contact:

Re: Stamp 2 Traffic Light

Post by Shing »

Thanks for the response.<p>In my case, there are four LEDs per traffic light.<p>- Red
- Amber
- Green
- Green Arrow Light<p>In addition to that, there needs to be a traffic light to facilitate pedestrians.<p>- Red
- Amber
- Green<p>Ideally, this would be implemented using 7 of the input/output pins.<p>The ultimate problem is having to control specific LEDs depending on the situation.<p>Regards,
Wai Shing
josmith
Posts: 340
Joined: Tue Dec 04, 2001 1:01 am
Contact:

Re: Stamp 2 Traffic Light

Post by josmith »

You will have to use an external decoder to control the seven leds per signal location with three stamp outputs. You can use three more to select each set of seven in the multiplex cycle.
You will have to assign a variable to each signal.The variables will have to be sent to the outputs sequentially. Three bits will be fixed,one for each signal. The three bits that go to the decoder will change according to whatever is making the decisions about which light is going to be on.
If more than one light per signal is going to be on at a time you will need more variables.
dyarker
Posts: 1917
Joined: Fri Aug 22, 2003 1:01 am
Location: Izmir, Turkiye; from Rochester, NY
Contact:

Re: Stamp 2 Traffic Light

Post by dyarker »

Shing,<p>Since you're in Ireland, does that mean you want "drive-on-the-left-side" versus "drive-on-the-right-side"?<p>In either case some savings can be made. The red, ambers and greens for both directions in the cross of the tee can be parallel (straight through). Only one direction on the cross of the tee needs a green arrow (turns are across traffic), the other direction turns are away from traffic in the other lane. The leg of tee doesn't need a green arrow because all traffic must turn and there is no opposing traffic.<p>If pedestrians only go when all cars see red, then the pedestrian LEDs can be parallel with each other. Or the pedestrian LEDs can be parallel with same direction car LEDs if left turning cars (UK, Japan, etc)((right turning cars elsewhere)) must wait for the cross-walk to clear.<p>To use less Stamp pins at the expense of more ICs, use a 2 bit latch for each red-amber-green set. (For example: 0 0 = green, 0 1 = amber, 1 0 = red, 1 1 = red and green arrow, or not used.)<p>Three pins to a decoder chip to address which latch is to be changed. (For up to 8 R-A-G sets.)<p>One pin to pulse the latch iput enable. Six stamp pins used, total. By using the seventh pin as a fourth address, you control two intersections with one stamp. (16 R-A-G sets)<p>Cheers,
Dale Y
i_myself_matthew
Posts: 18
Joined: Tue Jul 29, 2003 1:01 am
Contact:

Re: Stamp 2 Traffic Light

Post by i_myself_matthew »

One more possibility is to use a shift register for serial in/parallel out. I recently ran across a chip designed for driving 35 LEDs by National, a MM5451. However, it appears to be discontinued. Such an interface would require two wires for the data transfer: the data signal and a clock signal. It might require a bit more work on the programming side, but I am not well informed on the serial output capabilities of a Basic Stamp. My thoughts would be to build a large shift register by hooking up several smaller shift registers in series such as TTL 74164 or CMOS 4015. This way, each individual LED is addressable.<p>I am not sure if such devices can be hooked up in serial (common clock, hook the last bit of the output to the input of the next chip). If anyone knows if these shift registers can be linked up to form larger shift registers, I would like to know.
Madness has a toll. Please have exact change ready.
bonesdub
Posts: 4
Joined: Mon Nov 24, 2003 1:01 am
Contact:

Re: Stamp 2 Traffic Light

Post by bonesdub »

STOP GETTING HELP DO IT YOURSELF<p>
WAI
Shing
Posts: 34
Joined: Tue Feb 18, 2003 1:01 am
Location: Dublin, Ireland
Contact:

Re: Stamp 2 Traffic Light

Post by Shing »

Thanks very much for the ideas. As always, they are greatly appreciated.<p>Regards,
Wai Shing
perfectbite
Posts: 255
Joined: Tue Jan 07, 2003 1:01 am
Location: California
Contact:

Re: Stamp 2 Traffic Light

Post by perfectbite »

For the UK if I remember rightly, their traffic lights go in the sequence:
green, amber(to both roads), red, stay red, amber (to both roads), then green.
In the states it is:
green, amber, red, stay red, then green
The UK system may require an extra function.
bodgy
Posts: 1044
Joined: Tue Dec 04, 2001 1:01 am
Location: Australia
Contact:

Re: Stamp 2 Traffic Light

Post by bodgy »

UK system<p>Green to Red<p>green, amber, red.<p>Red to green<p>Red, Red & Amber, green.<p>The easiest way to code this is with a set of look up tabled coded in binary to represent the lights that are on - or off depending on your outlook.<p>Colin
On a clear disk you can seek forever.
rshayes
Posts: 1286
Joined: Tue Mar 04, 2003 1:01 am
Contact:

Re: Stamp 2 Traffic Light

Post by rshayes »

A microcontroller type of part may not be a very good solution, just because of the low number of output pins. There are actually a small number of different states for the system, probably less than eight or sixteen. The state desired can be encoded with only three or four lines. These codes can be decoded into eight or sixteen lines. Each light would be driven by some OR combination of these lines. This type of logic may be better suited to a look up table or a programmable gate array, such as those sold by Altera, Lattice, or Xylinx. Some of the Xylinx parts are available from Digi Key for a few dollars. Unfortunately, these are surface mount parts. The smallest parts seem to be in 44 pin packages, with about 30 of these pins available as I/O pins.<p>Hard wired logic can also be used if the number of chips required is not a problem.<p>EPROMs could be used, but each chip would only supply eight outputs. Most of the address pins would be unused in this case.<p>Multiplexed outputs could be used by organizing the Stamp outputs as an address bus and a data bus, and using external latches. Eight leads could control up to 64 LEDs this way (16 groups of 4), but external address decoding would be needed. Without decoding, 16 LEDs could be controlled (4 groups of 4), and that might be enough.<p>If multiplexing is acceptable, eight output pins could control 16 LEDs in a 4 by 4 array.<p>The drive capability of the Stamp outputs might be too low to drive LEDs directly, so external circuits may be necessary anyway. OR functions can be easily done with discrete transistors, either by paralleling collectors or paralleling emitters.
rshayes
Posts: 1286
Joined: Tue Mar 04, 2003 1:01 am
Contact:

Re: Stamp 2 Traffic Light

Post by rshayes »

You might also consider shift register chips similar to the 74HC595. This is an eight bit shift register with serial input and output. This allows them to be cascaded to any desired length. Each bit is transferred through a latch to 8 parallel outputs. This allows all of the outputs on the cascaded chips to be updated at the same time.<p>This arrangement needs only three signals, a data signal, a shifting clock, and an output clock. These can be three outputs from your Stamp 2.<p>[ December 11, 2003: Message edited by: stephen ]<p>[ December 11, 2003: Message edited by: stephen ]</p>
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 16 guests