Pages: [1]   Go Down
Author Topic: new and need help with pulse counting  (Read 307 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged

Norfolk UK
Offline Offline
Edison Member
*
Karma: 65
Posts: 2442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

There is no such thing as a stupid question but there are a lot of inquisitive idiots.

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

Norfolk UK
Offline Offline
Edison Member
*
Karma: 65
Posts: 2442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Read processor time
subtract from last interrupt time
store the time difference or an extrapolated frequency value.
Logged

There is no such thing as a stupid question but there are a lot of inquisitive idiots.

Pages: [1]   Go Up
Jump to: