• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 923
  • Last Modified:

Timing/Counting Circuit

Hello all,

This may not be the correct forum for this question, but hopefully, if I can't get a specific answer, maybe I can get some pointers on where/how to look for this info.

Here's what I've currently got:  1 manual switch box with 70 switched circuits.  I use this to fire cues in personal fireworks displays.  While this definately works, I'd like to build a timing circuit that allows me to preset times for specific cues to fire.

I have the following timeline: Cue1-0:00, Cue2-0:53, Cue3-1:06, Cue4-1:23, etc.  The best I can figure with my limited knowledge is to use something like a CMOS4206 (or 2 or 3) and have those clocked from a 555 timer.  Then, I could use a sequence of AND gates to logically figure out when my Cue-times happen and trigger a relay to pass the charge along.  Unfortunately, this is very cludgy and would be hideous to redo the logic each time the Cue-times change, especially with a set of 70 cues.

So, what I'm looking for is either what chip(s) might be able to perform this function for me (maybe a programmable chip with a certain number of output triggers)?  Or a site with a simple project that encompasses this that I could use as a template.  They do sell professional items that will do this, but as I'm only a hobbyist, I can't justify shelling out a few grand for one of these boxes.

Thanks for any input!
  • 13
  • 7
  • 3
2 Solutions
 Hi, if you don't want to use a micro processor to do this task a great choice is to use up counters instead of AND gates.. Use a 555 with a series of up counters in line... with a few combinations you'll be able to time on your cue... This is still a clumsy solution...

   The good solution is to use a micro processor to do the timing and  SERIAL in Parallel out to demultiplex your 70 trigger lines.

This is a great chip... http://www.allegromicro.com/sf/6276/    you can drive 16 lines per chip and can mount several those in series so you can drive all 70 switches using only two pins from a micro processor...

 if you have no experience with microchips simply buy a development kit I recommend ATMEL.COM
I mean if you have no experience with "micro processors"
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

cciesligaAuthor Commented:

Thanks for the ideas.  I don't have experience with micro processors at this point.  Sounds like this will be the direction I need to take though to get away from the clumsiness of the other solutions.  Is there a specific developer kit you would/can recommend?
 If you know how to program you know how to program a micro processor.. there is no mistery on it. And to turn pins on and off is Very simple to do on a micro processor.. it is like assigning a value to a variable.

    Since You'll not find  cheap solution for a micro processor with 70 I/O pins..   The solution to drive abunch of serial in/ parallel out  chips is the way to go..  you can go to the Allegro website and request free samples of the 6276 chips. And you'll be in business in no time.  I recommend downloading the datasheet of the 6276 and reading it over and over until you understand how to drive them.

   Choosing a micro processor for you is easy, speed is not an issue since you'll be using a very slow process control and the number of I/O pins is also not an issue since you'll be using only two. Also you don't need any feature like PWM of things of the kind.. I would say that any micro processor will do ;o)
  Then the main thing for you is what language you'll be programming.. If you know basic graba a basic stamp from Parallax (a bit pricy) If you know C I recommend an AN AVR development kit... You could buy the Butterfly Development kit from Atmel and the ICE programmer it will cost you around $40 for everything.

   Since you'll be using only two I/O pins... an interesting cheap choice is the new www.silabs.com/toolstick  you can remove the two LEDs from that demo board and solder two wires from there to your development board. The toolstick comes with two sample programs all written in C it is really easy to program.
I'm sorry I've said AVR ICE it should be the AVR ISP.  

 I do recommend begining with the AVR just because it is the most used 8 bit micro processor in the market.

  To buy the Atmel development kit go to digikey.com and search for "butterfly" it will go streight to it. The AVR Butterfly costs $19.99. You'll also need to buy the ATAVRISP2 (this is the programmer for the chip). It will cost $34

 Another AVR solution is the STK500 that's the full development kit from ATMEL it costs a bit more about $79.99 in the end it is a bout the same thing. The "butterfly" is very compact and you can embed it in your system with no guilty and it has a display and push buttons so you are ready to go.
If I were doing this, I would use a CPLD.  

For example, the Atmel ATF1508 has 128 flip-flops and upto 96 I/O pins.


All you would need is the CPLD, a clock, and whatever driver chip you need to fire the ques.

1.   You would take a 1 MHz clock and divide it by 10,000 to make a 0.01 second time base.
      This would take 20 flipflops.

2.   Then you make a counter/sequencer that counts from 0 to 1000 ==>  0.00 to 10.00 seconds.
      That would take another 10 flipflops.

3.   Then you can program each output channel to fire at a particular count.

4.   You would program the counters and the firing list on a PC, and program the chip over a parallel port.

The chip is around $5.  
The programming cable is about $50.  
The software is free.

You would need a custom PC board.  Probably $100 from ExpressPCB.

The biggest cost would probably be the connectors.
And by the way, this is certainly the correct forum.
   Using a CPLD is another alternative but I've put it asside right the way because of the following reasons.

     - If he is going to program using Verilog it will be extreamlly complex for a beginner
     - The logic of several flip flops in series to measure time could be confusing for a beginner.
     - Handling a massive pin count surface mount component is not practical for prototype.  All chips I've recomended are available in DIP packages. The best solution for him would be a turn-key development kit. How many Custom PCBs do you think he will need before his final design? A CPLD choice will be too expensive in the end.
     - He will have a very limmited room to customize different switching sequences. Every time he decides to switch on a different sequence he would have to re-program the CPLD or re-wire the switches on the field. With a micro processor he could store hundreds of sequences and times and everything could be customized on the field.
     - We don't know his power requirements. Using those serial in/parallel out drivers from Allegro he could choose a much higher current source/sink from their product list. Using a CPLD, If his power requirements are too high he would eventually need drivers CPLD I/O pins.
    Using a micro processor will give him much more room to grow his design. And since this is his first touch with embedded systems what a great excuse to learn how to work with a Micro processor.
 To prototype this you could use the "Grid-Style PC Board with 2200 Holes" part number 276-147 at RadioShack and the connectors could be the 276-1388 PCB terminals that are also available at your local radioshack.
Valid points but:

  - I would recommend WinCUPL not Verilog.  They have sample code for counters.  
    Most of the program is just the firing list.  
    I would estimate 150 lines of code and two hours of work.

  - I agree about surface mount chips.  I use the ATF1508 in the 84-pin PLCC socket exclusively.
    I just checked and it only has 64 I/O pins.  So I would use two of them.

 - I would recommend getting one of the CPLD starter kits before going to a custom PC Board.
   But if you are reasonably careful, I would expect the first prototype to work fine.
   There one clock input, one trigger input, and 70 outputs.

  - If you need to change the firing order, all you have to do reprogram the list.  
    You do need a laptop if you want to make changes in the field.

 - I would certainly recommend line/peripheral drivers on the outputs no matter what the power
   requirements for firing the que are.  

 - I could post a skeleton WinCupl Program and a two CPLD PCB file if anyone is interested.
 I don't want to got to a Ping-Pong kind of answer that I say some thing and you say something ;o) so this is my last point here.... :-)

  The key here is simplicity.. Since he will probably need drivers at the end of each I/O pin from the CPLD he could skip the CPLDs alltogether unsing a micro processor. And with the Serial IN/Parallel Out drivers this device could be scalable to hundreds of pins!  And even better he could begin his prototype with as simple as ONE chip driver and expand as he gests confortable with the design.

  After many years programming FPGAs things seem simple when you think about connecting CPLDs in series but can you imagine for a beginner how impossible that might look like? Any one can program a Basicstamp to spit out serial data. Remember this has to be simple.

 here are a few good points why to use the 6276 Allegro drivers

 - To 90 mA Constant-Current Outputs
 - DIP package available.
 - Free Samples availabe!


another good point regarding the 6276 Allegro driver...

The DIP package A6276EA-T Allegro MicroSystems Costs only $1.80.  That's only $1.80 for 16 outputs!

This item can be found at http://www.arrownac.com
cciesligaAuthor Commented:
Thanks both of you for your inputs.  I'll check this out in more detail when I get off work tonight.

Additional details for what I'm needing at the field:
e-matches are fired with a 12v system at 2-3A.  I don't have an issue deisgning a low voltage system that will in turn fire the higher voltage cues via relay or something like that.  Unless I can pass the voltage current requirements through one of the aforementioned possible solutions.

As to programming, the timing of the cues would all be done "in-house" before the event.  So, once I get to the event, I connect the control box to the cues and press Go when I'm ready to kick it off.

I've got a year to play and learn what I need to learn.  I'll probably end up getting simple starter/learner kits to begin with so I can determine which method will work best for me and my knowledge level.

markps_1 - you've already provided the info I requested for a starter type kit I believe.
d-glitch - you mentioned WinCUPL and a chip/cable to use with that.  I've pulled the manual down and will look over it.

I've got limited programming experience.  But, if there are code samples provided that get me close, I should be able to go with that unless it's just not that simple.
  Hi cciesliga...

   Here is the link for the AVR studio.. You can begin playing with it    http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2725

   After reading your requirements you enforce my feelings regading not using a CPLD. Please, don't use WINCUPL. Don't use a CPLD as D-Glitch mentioned. Since this is a fireworks display. You need security measures to make sure when you power your device up it won't be at a random state or the clock won't be running before you are ready...

    The only safe way to do that is to use a micro controller that at boot time it will clear all the bits. This micro controller could be also attached with a keypad. Then you program a requirement on your software that it will only run the sequence if you punch a passcode on your keypad. This way if you even accidently press the push buttons or the re-set button, your fire works won't fire untill you've pressed the correct code.
cciesligaAuthor Commented:
Thank you both again!  

It looks like with my current knowledge level I'm going to have to start a little smaller and work my way up.  I'm going to go through all the info and simulators and begin playing.  I'm sure I'll be back as additional questions come up.  I've added a few more points and hopefully the split is agreeable.
>> markps_1

After this post yesterday:

      I don't want to got to a Ping-Pong kind of answer that I say some thing and you say something ;o) so this is my last point here.... :-)

I was surprised to find this post today:

     Please, don't use WINCUPL. Don't use a CPLD as D-Glitch mentioned ....
     The only safe way to do that is to use a micro controller ...

PERSONALLY OFFENSIVE.  Although the pleading is a nice touch.

FACTUALLY INCORRECT.  How did they set off fireworks before the micro controller was invented?

UNFAIR to say the least.  Saying "Let's not do this."  Claiming the last word, and then coming back for one last blast.

UNPROFESSIONAL as well.  Why don't you just make your best case and let me make mine?

>> cciesliga

I have a BSEE and 30+ years of hands-on-the-hardware experience with high power DOE projects.
I certainly take safety and reliability very seriously.

Back in the 70's I designed a firing circuit for an exploding fuse:  20 kA interruption, 10 us response, blasting caps, det cord, able to leap over tall buildings, blah blah blah.  I didn't use a CPLD because they hadn't been invented yet.  But there's no inherent safety problem with CPLD's.  I would be perfectly willing to use one in a similar application today.

You can build a safe, reliable fireworks controller with a mechanical clock and a punched tape.  You can use gates and relays.  You can certainly use CPLD's.  And you could even use micro controllers.

Safety isn't in the components, it's in how they are used, the overall system design, and the development and adherence to formal procedures.

For example, the idea of password protection on the control box seems a little silly.  I think you would get more effective protection by putting shorting plugs on the que firing lines, and maybe a key switch on the 12 volt battery.

I have the WinCUPL code for a 36-output Sequencer.  I have to modify it slightly so that it has time resolution of seconds rather than microseconds.  I will test it and post a link before the end of the week.

That will be my final post.  And I really mean it.

Looking forward to your future questions.
Wow, take it easy this is a friendly forrum. I've made my case... life goes on..

I have a 36-Channel CPLD Sequencer up and running on my desk.
It is manually triggered, with a maximum window of 1023 seconds, and a timing resolution of 1.000 second.
It can fire 36 LED's in any arbitrary sequence.  

You can also get an Atmel ATF15xx-DK2 Development Kit from Digi-Key for less than $100.
This kit includes the software (which you can download for free) and the programming cable,
The board has all 60 of the available I/O lines connected to LED's.

My program should run on the DK2.  You would need to check the pin numbers for the START and STOP switches.
No other mods should be necessary.

Here are the relevant links:

You have to change the file name from     FW_TIMER.txt  ==>  FW_TIMER.pld   to use it.

And the uploading seems to have messed up the TAB alignment.

 If the idea of using a CPLD instead of a real Micro Processor is in any way apealing, why not to use Xilinx instead?  Xilinx is the leading brand on CPLDs simply because they have the best prodcuts and the best free development software in the market.

  The XC9572 costs $3 and it has 69 I/O pins on a PLCC package. You can program using the ISE's graphic interface NO programming necessary. Any JTAG interface connect the XC9572 to your comptuer.

here is the device.

and the free developlment software is here.

>>  I don't want to got to a Ping-Pong kind of answer that I say some thing and you say something ;o(
      so this is my last point here.... :-(

>>   cciesliga

       If you ever want my thoughts on "Graphical Programming Interfaces"  just ask.

let it go.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 13
  • 7
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now