setting an input signal as timer

Hi,
Is there any function in arduino through which i can set an input signal (square pulse) to the internal timer of the arduino board so that it counts at a speed equal to the frequency of the signal ? like whenever a rising edge is detected the clock should tick..
Please don't suggest me to use the button push/edge detection program since i have already used it and its running very slow...as my working frequency is 9KHz to 36KHz maximum.
Thanks in advance.

Is there any function in arduino through which i can set an input signal (square pulse) to the internal timer of the arduino board

No.

There are several timers. The speed that they run at is NOT controlled by external events.

Please don't suggest me to use the button push/edge detection program since i have already used it and its running very slow...as my working frequency is 9KHz to 36KHz maximum.

OK. I won't.

Please don't tell us any more about what you are trying to do. Someone might have an ideal of a better way, and clearly you don;t want that.

pranesh:
Is there any function in arduino through which i can set an input signal (square pulse) to the internal timer of the arduino board so that it counts at a speed equal to the frequency of the signal

If you connect the signal to Pin 2 (on an Uno) and use this code

volatile unsigned long pulseCount;

void setup() {

     attachInterrupt(0, pulseCountISR, RISING);
}

void loop() {
   // other stuff
}

void pulseCountISR() {
     pulseCount ++;
}

...R

I am using a mega 2560, is it not going to work with this ?
why specifically pin2 ?

why specifically pin2 ?

Because that is the pin used by interrupt 0 on a Uno and, incidentally on a Mega 2560, so the program should work for you.

See attachInterrupt() - Arduino Reference

Thank you.
I'll get back if needed..

Hi,
Thank you for your help with the topic of discussion. I tried coding the way you told me and it's running successfully, i mean i am able to do what i wanted to. But i need your help for the second part, i am trying to communicate serially to arduino board through labview but i need labview as a front panel where i need to change values of two variables used in my arduino code.
The difficulty i am facing here is that i am not able to understand how can i make the board recognize that the values coming from labview are two values for different variables so that i can do a check in my code which will automatically change the values of those corresponding variables in the code.
I am posting a link here in which they have done serial communication but it is taking only one value.

I don't know you are familiar with labview or not but nevertheless take it like this.., i want the values of two variables to be changed and there values are coming serially from somewhere, i need your help to find out if there is any way we could do it (i mean, recognize two values, coming serially, as different.)

Thanks in advance.

I'm not familiar with Labview but I suspect what you are asking is a very common issue.

Hopefully this data input demo and this demo of PC-Arduino comms will give you some ideas.

Basically the incoming values must be separated by some character. A comma is the one most often used, hence the phrase Comma Separated Values CSV.

I am assuming you are not trying to send binary data from Labview. If you are I have another short demo for that.

If this does not help please give us a sample of the data that is being sent by LabView and post your Arduino code - in code tags (the # button) so it looks like this.

...R

i need your help to find out if there is any way we could do it (i mean, recognize two values, coming serially, as different.)

Of course it is. Labview needs to send something like "<name=value>". Then, the Arduino can read and store data, from the serial port, starting when the '<' arrives, ending when the '>' arrives. When the '>' arrives, the string can be parsed to get the name and value tokens. The value token can be converted to an int or to a float, as required, and stored in a variable based on the name token.

okay. Can you please show me some example code or name of functions to do that in arduino ?

pranesh:
okay. Can you please show me some example code or name of functions to do that in arduino ?

You are falling behind. The examples are in Rply #7

...R

PaulS:

Is there any function in arduino through which i can set an input signal (square pulse) to the internal timer of the arduino board

No.

There are several timers. The speed that they run at is NOT controlled by external events.

Not true, many timers are controllable by external events like timer0 and timer1
on the Uno and timers 0,5 on the Mega. The chips have a hard-wired pin to clock
each timer:

Uno:
timer0 is driven by pin 4
timer1 by pin 5

Mega:
timer0 is driven by 38
timer5 by 47

The Mega's board doesn't bring out the clock pins for timers 3 or 4 to any headers
alas.

To clock a timer from its hardware clock pin you have to set it up appropriately,
usually by setting the clock source bits to 110 (falling edge) or 111 (rising edge)