Go Down

### Topic: new and need help with pulse counting (Read 567 times)previous topic - next topic

#### Chris24f22

##### Jul 06, 2013, 07:43 am
okay so what im trying to do is make a sequential shift light for my volkswagen mk1, what im trying to figure out is a way to to take the output from my car which is a pulse that increases in speed as you rev the engine. the pulse is very very fast. so im trying to make a code that will take the input at a logical speed so like a certain amount of pulses per minute or second and then i want to take that number and make it so that when at a certain number of pulses the first led of 5 will light up then when the pulses increase the second lights up and the first also stays lit and so on and at a certain speed after all the leds are lit they all start to blink. i can easily calibrate the code but i need something to start with so if someone could please help me out it would be GREAT!

thanks

#### Riva

#1
##### Jul 06, 2013, 08:41 am
You may need a voltage divider for the sensor output as the arduino can only handle a maximum of 5V.
When you say "the pulse is very very fast" what is the maximum frequency your talking about?
I would probably read the pulses using interrupts and store a running average of the time between them for the main code to pick up and control the LED's with.
Don't PM me for help as I will ignore it.

#### Chris24f22

#2
##### Jul 06, 2013, 05:07 pm

You may need a voltage divider for the sensor output as the arduino can only handle a maximum of 5V.
When you say "the pulse is very very fast" what is the maximum frequency your talking about?
I would probably read the pulses using interrupts and store a running average of the time between them for the main code to pick up and control the LED's with.

well i hooked up an leg to the signal from the car and the ground of the car and it powered it with a resistor, the output is 5v from the car and i dont know what the max frequency is... how do you think i could find that out? and ive been seeing things about useing interrupts but i have no idea how to use them and  how i would set up the code...

#### Riva

#3
##### Jul 07, 2013, 08:18 am

well i hooked up an leg to the signal from the car and the ground of the car and it powered it with a resistor, the output is 5v from the car and i dont know what the max frequency is... how do you think i could find that out? and ive been seeing things about useing interrupts but i have no idea how to use them and  how i would set up the code...

What Arduino are you using? If it's the UNO then it has 2x external interrupt pins (pins 2 & 3) have a look at the reference pages for how it works.
To find out the max frequency you need the datasheet for the sensor.
The interrupt will 'interrupt' the main program when it gets triggered by a pulse and when the interrupt(s) have been serviced the code execution in the main program will continue from where it was.
The two main methods for reading frequency using interrupts is to either count how many happen over a known time period or count the time between each interrupt. The former is probably more accurate but as your only using this to light 5 LED's the second should be fine. The principle of the interrupt routing could be...
subtract from last interrupt time
store the time difference or an extrapolated frequency value.
Don't PM me for help as I will ignore it.

Go Up

Please enter a valid email to subscribe