Using Arduino to modify square wave signal

Hello Everybody!

This is my first post here and also my first attempted project with the Arduino. I have been waiting for an excuse to get into Arduino micro controllers and finally something has come up through work that will let me.

I need to take a RPM signal from a machine that is currently a 0-5v square wave (up to 12,000 RPM) divide it by two, and add an factor of between 0 - 100 to the resultant output RPM. if possible it would be great to be able to adjust the factor with an external pot or multi position switch.

I have a bit of experience with electronics, no expert but not stupid. I have no experience in programming however. Does this project sound like something that the Arduino could achieve?

Thanks for any advice/direction

Are you outputting anything after coming up with the 0-6000, -0 to +100 result?

I helped some do similar with 15KHz code recently, let me see if I can find a link.

Here's the thread I was thinking of

Read thru, see if this gives you some ideas.

CrossRoads:
Are you outputting anything after coming up with the 0-6000, -0 to +100 result?

I helped some do similar with 15KHz code recently, let me see if I can find a link.

Sorry,

yes I am wanting to output to a transistor to fire a strobe light unit. The strobe unit I have has an input for external triggering.

I will read over your link as well, thanks for your help!

Strobe light at 6000 RPM? Most units discharge a capacitor to ceate a high voltage for the flash - I didn't think they could charge up fast enough to do 6000 flashes/sec.

Are you confusing RPM and Hz?
12000 RPM is only 200Hz.

Um, yeah, well, ok, guess I wasn't thinking about it that way.

I need to take a RPM signal from a machine that is currently a 0-5v square wave (up to 12,000 RPM) divide it by two, and add an factor of between 0 - 100 to the resultant output RPM.

If this is for a photographic project does the output has to be synchronised to the input or can it free run.

It is easier if it free runs but that might not be right. What you need is basically two systems, one measuring the input rate and feeding the the other variable frequency oscillator. Have you an amount of jitter you can tolerate as this will be large in a software based solution like this. You are probably best doing the whole thing in hardware with a frequency to voltage converter and a voltage controlled oscillator.

So you want to blink a strobe light a little faster than every two revolutions to make the rotating object appear to be rotating backward, at a rate you can adjust with a knob?

This will let you read the input square wave...

void tachcount()
{now = millis();
interval=now-lastcount;  //calculates time between 2 subsequent pulses
lastcount=now;
}

To count the pulses...

pulses=60000/interval; // 60000 ms divided by interval gives RPM
pulses=pulses/2;  //RPM divided by 2
hertz=pulses/60; // frequency of pulses

//Fire strobe code...

freq=hertz+comp;  // Firing frequency
wait=1000/freq;  // Delay for firing strobe
digitalWrite(12, 1);
delay(wait/2);
digitalWrite(12, 0);
delay(wait/2);

For how to get the compensation factor from the knob, go through the Knob example under servo in the Arduino IDE examples.

Hope this helps.

BTW, is this for a timing light for an automobile?

pulses=60000/interval;

Not sure about that constant - may need an "L" on the end.

I dont know about "pulses", but I know "interval" works as I have used it in my own sketch.

Even if the constant isnt allowed, I think he gets the drift. :slight_smile: