Help with Pulse Counter that outputs one pulse per n-pulses

Discussion in 'The Projects Forum' started by tuscarora, Dec 29, 2009.

  1. tuscarora

    Thread Starter New Member

    Dec 29, 2009
    8
    0
    Hi, sorry to do a post asking for help for my first.. I've come across this forum lots of times in the past when looking up electronics and you all seem very helpful so I thought I'd give asking you a direct question a shot!

    Basically I'm trying to make a mod for my motorbike. The aim is to have a couple of high output (~1W) UV LEDs buried in the engine that pulse with a speed related to the revs. I want it to be most effective from 2000-1000rpm and was thinking a minium period of 0.2s means one pulse to LEDs per 34 revs of the engine.

    I've tapped the tach lead, ground and 12V from the wiring loom. From what I've found out so far the tach lead outputs a square wave pulse at >10.5V - I have no oscilloscope to test this though :(
    Also I have confirmed that there is a pulse the goes to the coils twice every rev - so I may be able to get a pulse going double the speed of the revs also. Apparently this is where aftermarket rev counters usually attach to.

    Having got my pen and paper out I've identified a few parts for the circuit -


    Signal In (got that, don't know what it's outputting exactly but got it!)

    Pulse Count (I'm thinking I need something that'll send one pulse per 34 in - perhaps double this though if the signal is different. It would be good if I could vary this one way or another)

    Pulse Out (I realise that I'll probably get a square wave out of whatever counter I'm using, so want to change that to, ideally, a quick build, slow fade - could be done with cap that uses different values of charge/discharge resistors maybe? A sine wave or triangle wave would do in a pinch though)

    LEDs (I've found some 1W UV LEDs, want to drive 2-4 of these)

    Any help would be much appreciated! Please ask away with any more info you need.

    I know this post is already very long-winded but here's a little of my background if ye want to read it -

    Been playing around with electronics for a lot of years, but always end up hitting a brick wall of my own stupidity :confused: Comfortable with a soldering iron but circuits quickly go over my head. Did a year of practical electronics as part of a design degree, which brought me on a bit (I can read datasheets)

    Latest time was building my little proof of concept LED pulser (read: following diagrams) and trying to get my head around it. I understand how a op-amp makes a square wave, but can't understand how it makes a ramp voltage or sine wave, argh.

    Played around with lasers for a bit and built a couple of drivers for those (don't wanna fry yer diodes) using a Vreg IC. Recently came back to them, built a current reg, and voltage reg - both work fine on their own. Can't connect them together. I'm sure there's a very simple reason for this but it's one I can't get!

    Anyways, that's more than enough writing.
     
  2. Bernard

    AAC Fanatic!

    Aug 7, 2008
    4,170
    395
    Need rating of LEDs. For counter try a CD4024BC, 7 stage binary counter, decode output, 32 & 2 with 2 input NAND gate like CD4011BC, followed by emitter follower, 2N2222, driving a gated constant current [ or two ] LM317's.
     
  3. tuscarora

    Thread Starter New Member

    Dec 29, 2009
    8
    0
    Thanks for the reply Bernard, unfortunately most of that went over my head, about from

    I understand what the LM317s do but what do you mean by gated?

    I've been researching away all day at these binary counters and it sounds like is gonna be a bit simpler than I'd at first feared! Unfortunately local electronics store does not have the one that I need, though I picked up a few 555s to play around with in the meantime.

    The LEDs I want to drive are specced around:
    Driving voltage: 3.0~4.0V
    Driving current: 350~500mA

    unfortunately I could not find a datasheet for them and these figures are grabbed off a forum attached to the shop.



    I was thinking of getting a 74HC4020 14-Stage Binary Counter - that should give me plenty of range for dividing the frequency right? all the way up to 2^14?

    I think I'm happy enough with that part, it counts input freq and outputs a freq that is divided by factor of 2 to the power of whatever stage you're at, working in square waves at logic voltages the whole time?

    I'm not sure about generating the wave form that I want from the divided output though, and how to get that to the LEDs at a useful voltage range and current level.

    From a bit more research things seem to be shaping up as -

    Square Wave Signal In
    Frequency Divider (Using Binary Counter)
    Square>Sine wave convertor (don't know the proper name for this)
    LED Driver (I guess regulated current and voltage, I've already got a couple of LM317s to limit the current from another project as suggested by Bernard)

    Am I on track at all?

    Promise to put a video of it up if I can get it working :D
     
  4. Bernard

    AAC Fanatic!

    Aug 7, 2008
    4,170
    395
    Use 74HC4040, 12 stage as all outputs are available. Thumbnail is my interp. of what i think you wanted. At 2000 rpm there[ woops-iverter missing at Q2,pin12 ] is an inverted pulse at pin 12, with inverter added now a +pulse to 1N914 at 34th clock & a reset pulse at trailing edge of 34th clock. Cx will fast charge, turning on 317 for 500usec, set for 350 mA, slower turn off via Cx-Rx. for 4 LEDs, add another 317 & other components down to but not including Q6.For more drive for 1N914, parallel more sections of 74HC04 with missing inverter.Resistor at set input is 3.4 Ω,1/2W to give 350 mA. 317 needs heat sink.Ask away.
     
  5. tuscarora

    Thread Starter New Member

    Dec 29, 2009
    8
    0
    Thanks very much for your help Bernard! I'm gonna have a good look at that schematic and digest it, then come back with a barrel load of questions probably.

    One thing I noticed re-reading my original post is a wee typo, and from some reading tonight I think it might be an important one..

    Want the circuit to function at a variable freq (as it's slaved to the rev counter) and most effective in the range of 2000-10000 (not 1000), the bike idles at 1000-1500 and redlines at 13000 (though it rarely sees that).

    From a bit more research on the bike forum, it seems the signal will either by 1 pulse per rev, or 2 pulses per rev.

    I've been having a look at the schematic for a bit and is starting to make sense, once I've wrapped my head around it as much as possible I'll get back to you.

    Thanks again
     
  6. Papabravo

    Expert

    Feb 24, 2006
    10,137
    1,786
    Last edited: Dec 30, 2009
  7. tuscarora

    Thread Starter New Member

    Dec 29, 2009
    8
    0
    Well I had a good look at the schematic and my understanding of how the circuit works is more or less -

    • Input pulse is counted until 34th rising edge when the logic section sends a pulse to the lm317 via a cap, and sends a pulse to reset on the counter on the falling edge.

    • Cx charges quickly causing the LED to light up quickly (still not straight to full voltage though, right?)

    • Cap discharges more slowly (through Rx) causing the voltage to drop gradually, and therefore the LED to dim gradually.

    I'm happy enough with the reasons for the other resistors around, setting voltage for the LEDs, current for the logic etc.

    NB I don't have a clue about why that logic network works, will have to do some remedial reading on logic and figure it out, but working from your description of the circuit there Bernard. Well, I know that a counter can count and I suppose the other parts are setting the number that it counts to, but the hows and whys I'll get my head around later..



    I got a few questions for you though..

    • Using the same chips, if I wire the logic part differently after the counter could I count to different numbers instead of 34? Would this require more different ICs? Just incase the signal is not what I am expecting.

    • You said that the cap turns on the LM317 for 500usec at 2000rpm. What defines the length of time that the LM317 is full on for? And does that change with revs? I should have said before that I want the LEDs to pulse at 5Hz @10000rpm.

    • Regarding the final LED behaviour, do they light up quickly (but don't come straight on, still a gradually increasing voltage) and then dim more slowly? Can I fine tune this behaviour by changing Cx and Rx, or perhaps adding a charge resistor?

    • What happens if the pulse to light the LED comes before the cap is finished discharging - does this work ok?

    • When you say about paralleling more sections of 74HC04 is that for more current to through the diode? Also the missing inverter is just to flip the output from pin 12 on 74HC10?


    Thanks for bearing wth me, I've never done electronics like this before, mostly very simple stuff using minimal logic.


    Hi Papabravo, having looked at the datasheets I'm not sure if a binary rate multiplier is what I want.. Would I be using it to divide frequency in multiples of 2^4?
    Rough gist is get the engine rev signal, divide the speed by around 34 so that the freq is noticeable with naked eye (I think that works out at around 5Hz @10000rpm). Then take that frequency and generate a signal that will pulse 2-4 LEDs at the same speed. Frequency in will vary as I twist the noisy handle on the bike so circuit needs to perform from 1500-13000rpm, signal in could be twice this depending on what the CDI outputs, unfortunately have no way of testing what it is until I plug the circuit in.
    This is new to me, so I wasn't at all sure what way to implement this, never mind the easiest! Haven't worked with any frequency division or anything like this before, much more simple things usually happen on my breadboard!
     
  8. Papabravo

    Expert

    Feb 24, 2006
    10,137
    1,786
    You would need to cascade two of them to go higher.
     
  9. Bernard

    AAC Fanatic!

    Aug 7, 2008
    4,170
    395
    Questions: 1 What is a UV LED- ultra violet?
    2 Did you want a fixed length light pulse, say .2 sec?[ .1 better ]. At 10,000 RPM for an output of 5 pps, division is 2000, not 34.

    If a fixed length pulse, .1 sec, is desired, a 555 one-shot triggered by counter reset would work, & simplify logic.

    Ans.
    1. To count to other numbers, more NAND inputs may be required. Ex. No 31 needs 16,8,4 2 &1, or 5 inputs to decode. For divide by 2000; 2000-1024=976-512=64-64=0, giving 3 inputs. If count is in doubt, start with an 8 in NAND [ or AND]

    2 The LM 317 is on [ or should be] for one input clock period, which changes with RPM, down to 100 μ s @ 10,000 RPM; just a little dim??

    3. LED gets full 350mA. As shown, rise time about 10us,fall 100 us. Using 555 with .1 s, Cx & Rx can be adjusted to suit. Yes, charging resistor can be used to keep Cx to a reasonable value.

    4 No problem as long as 5RPM[ .2 sec.] pulse is not shorter than 555 pulse .2 sec; the reason to go to .1 sec from 555.

    5 Yes. Note big error in LM317 drive;when light is on , base of Q6 should be low, & not as shown. If using 555 that will change.

    My typing finger is tired.
     
  10. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    If you just use a 1:32 ratio you don't need any decode logic.

    All you need is a 8bit binary counter IC, then one of it's outputs will flash every 32 pulses (actually it will toggle after every 16 pulses so it has a nice 50:50 duty cycle).

    So you can drive your output transistor directly from one of the counter IC pins.
     
  11. tuscarora

    Thread Starter New Member

    Dec 29, 2009
    8
    0
    Hope everyone had a nice new year's, I'm just about recovered now!


    Hi Bernard, thank you for the answers to my questions.

    1 UV LED is ultra violet, yes. It outputs a huge amount of visible light as well and I like the effect. I have a torch using just the 1 and it is very bright. However, if I'm not happy with the effect I might wire up some ultra-bright white LEDs instead.

    2. Ideally I'd like a pulse with a 50/50 duty cycle (~5Hz @ 10,000rpm) like THE_RB said (thanks!), however I cannot work out how to make a circuit that'll transform the square wave into sine, at variable frequencies. I do not understand the mechanism that makes square-->sine. Have read that it is a bandpass filter, and that square waves are made from harmonics but do not get this!

    PS I think if one pulse per rev need to divide by ~34 eg. (10,000rpm / 60s) = 167Hz then 167/34 = ~5hz. I think I'd be able to get away with divide by 32 and avoid using decode logic, would make the circuit a lot simpler.

    Sorry I wasn't clearer when I described the circuit the first time round, from the things I've learned during this thread my understanding of the electronics involved has improved, and I can get a better idea of how the effect could be achieved! I hope you did not take too long making that decode circuit for me...

    Anyways, I think if I get a binary counter that'll do freq division /32 and /64 that should keep all my bases covered, incase the signal is twice the rpm.


    Some more new questions for you!

    • Is there an easy way to convert the square output of the counter into a sine of the same frequency, bearing in mind the constantly varying frequency?

    OR

    • Can it be done that a longer pulse lit up and dimmed more slowly than a short pulse, is this practically achievable?

    In an absolutely ideal world, using a 50/50 duty cycle at the high output it would -
    0-10 Lights up to full voltage gradually
    11-30 Full Power
    31-50 Dims gradually
    and obviously just off during the low output.

    However I would be very happy if the speed of lighting and dimming was related the pulse width, and varied with it, although as I said, I do not know if this is possible with wee small ICs.
     
  12. Bernard

    AAC Fanatic!

    Aug 7, 2008
    4,170
    395
    My long post just got wiped out, so will post drawing, verbsge laler.
     
  13. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Why a sine wave? You will get a better visual effect with a square wave into the LEDs especially at the higher flash speeds.
     
  14. Bernard

    AAC Fanatic!

    Aug 7, 2008
    4,170
    395
    RB, @ 2000 RPM , we have a whole 1/2 sec to view the rise and fall of the light pulse, why, still a good question.
    The drawing is my attempt to show how to produce a half pseudo sine wave light pulse. Q1 is just for testing, Q2 &Q4 ,inverters to produce proper edge for clock & reset., Q5, spare. Pin 6 Q3 is lo for 16 pulses, hi for 16, while hi, Q3 allows 8 pulses to clock Q6 to give 8 sequential hi outputs. Resistors 5-12 with R 13 form an adjustable V divider to give base of Q7 , 0-8.5Vs. Selection of LEDs efects r values. Note 4040 is not 74HC4040 because of higher op V used,
     
  15. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Ahh I see. Good circuit solution! It could probably be improved with a small cap from darlington base to ground to smooth the "sine" effect. The engine rev range is probably only 1k-8k RPM or about 1:8 so it could be smoothed a lot at low revs without too much loss of amplitude at max revs (he said the low revs are more important anyway).
     
  16. tuscarora

    Thread Starter New Member

    Dec 29, 2009
    8
    0
    Cheers for the redesign Bernard, you're a gentleman :D

    I was gonna ask for a way to smooth the voltage transition because I didn't want it to look stepped, but the RB has suggested a way to do that as well! Would I be adding that cap between ground and the emitter of the first transistor in the dotted circle?

    Is quite late now, just wanted to post and say thanks.

    I'll post back again tomorrow after I've made a parts list and tried to source them, just double check with you before I go ahead and buy everything.

    I'll keep ye updated with how the build goes and not just disappear into the mist! Thanks again, have saved me many hours of hair pulling frustration. :rolleyes:

    BTW You were both wondering why I wanted a sine rather than square o/p - well a couple of reasons. I've always liked the look of pulsing LEDs and also because (no cringeing) I'm going for more of a heartbeat kind of vibe than strobe light.
     
  17. Bernard

    AAC Fanatic!

    Aug 7, 2008
    4,170
    395
    Q7 is just one compound transistor, yes base to ground, Try .1 to .5 uF. Best of luck.
    PS: I'm a Murray on my mothers side.
     
  18. tuscarora

    Thread Starter New Member

    Dec 29, 2009
    8
    0
    Sorry for my long absence, work has been crazy since started back.. basically been working and sleeping since January and all my wee projects fell by the wayside. However a small lull in the workload (temporary no doubt :rolleyes:) has given me some much appreciated breathing space and I'm back again!

    Finally got round to putting together parts list and sourcing them, wonder if you could check them for me? :D

    Also, while I'm ordering up components, is there anything else you would suggest that would be useful to have in the 'ol parts box? Like to play around and build circuits now and again, but not sure what kind of ICs I should have on hand for a reasonable scope of projects. Every time I want to build a thing I seem to be taking a trip to the shop!

    Anyways, I have attached links to the datasheets and am planning on buying almost everything from Rapid.

    TIP120 NPN Transistor (Q7)
    http://www.rapidonline.com/netalogue/specs/81-0168e.pdf

    4017B Decade Counter/Driver (Q6)
    http://www.rapidonline.com/netalogue/specs/83-0340.pdf

    4020B 14 Stage Binary Counter (Q5)
    http://www.rapidonline.com/netalogue/specs/83-0270e.pdf

    4011B Quad 2 input NAND (for the logic parts Q2,3,4)
    http://www.rapidonline.com/netalogue/specs/83-0264e.pdf

    9V 1.5A Fixed Voltage Regulator

    1W UV LEDs (probably drive 3 or 4 of these)
    - UV wave length: 395 ~ 410 nm
    - Driving voltage: 3.0~4.0V
    - Driving current: 350~500mA

    I was given a big bag of resistors and caps by a dude I used to know when the electronics shop he worked at closed down, so should be set for those.

    I'll keep you updated with how things are going, after I get these parts ordered up it'll be time to start breadboarding and then my tradition of at first wondering why it doesn't work then a slow slide down to the heavy drinking and slurred curses :p And finally, hours later.. SUCCESS

    Was a bit nerve wracking taking the splices from the bike's CDI box but it hasn't broken yet so I think it worked out ok :rolleyes:
     
  19. tuscarora

    Thread Starter New Member

    Dec 29, 2009
    8
    0
    I apologise in advance for bumping the thread but I do not have the ability to do PMs. If someone could give Bernard a wee shout and ask him to cast his eye over the part list I would be very grateful. :D
     
Loading...