Square wave signal data

Hello,
I want to make a simple project but don't know. Perhaps somebody
here would like to help.

I need to make a simple tool to check a signal condition.
Actually it's 12-56 VDC square wave signal, I want to
know the Vmax and Vmin value as shown in the attached
picture from an oscilloscope.

After I (arduino) knew the values, then I can judge whether
it's good or not. How to do that?

Thank's before.

Signal.PNG

Max voltage for an input into the Arduino is 5V. You'll need to use a voltage divider to drop the voltages down to <5V.

Once you do that, you can use the analog in to read the voltage divider's output.

Also, if you don't know the frequency you'll have to take lot of samples and assume the largest and smallest are indeed the max/min.


Rob

Hello, thank's for the response.

Lets assume that I can handle the voltage divider.

Graynomad:
Also, if you don't know the frequency you'll have to take lot of samples and assume the largest and smallest are indeed the max/min.

But, about the frequency, I have no idea about that.
Do the maximum voltage and minimum voltage
have relationship with the frequency?
Since the tool will be use to check about 1500 different
part a day, the frequency may vary on each part.
So, what exactly I need to do?
Hope you'll not bore to explain me the lesson.

Do the maximum voltage and minimum voltage have relationship with the frequency?

No but the rate at which you sample is important.

For example if it's a 1Hz wave and you take a few samples at a fast rate you may get all high (or low) readings, if you were dead lucky you may get some of each because you happened to sample on each side of a transition.

So if you have absolutely no idea of the frequency you may have to take 100/1000s of samples over a period of maybe 10 seconds and vary the sample rate so it doesn't "beat" with the signal you are measuring IE if you have a .999999Hz signal and you sample at 1Hz you could take a 1000 samples and still not get both levels.

Do these signals all have a nominal frequency but there are slight variations, or can they literally be anything?

Is there a threshold at which you can definitely say you have a low? For example do these signals all move around say 30v it's the 12 and the 56 that change. Or are they all supposed to be 12-56 but there are slight variations. Or can one be 12-13 and the next be 45-50?

In other words is this to measure a controlled signal with limited variation or is this a general-purpose meter that has to handle every combination known to man?


Rob

just tossing this out, maybe a pin change interrupt would be useful in keeping sample times in check? In the picture above the scope is set to 5ms per division and each state is at or longer than a division, should be enough time for the arduino to notice a change, measure it and output data

in the scope picture the minimum value = -200mV.
As the Arduino ADC can only read 0..+5V you need extra electronics to adjust the range to allow negative values.
As I am not an EE I don't know how in detail - any EE out there?

The idea from Osgeld of using interrupts is a good one.

Here a minimal pulsemeter based upon IRQ's to get you started (but read the links above first ! )

//
//    FILE: pulseByIRQ.pde
//  AUTHOR: Rob Tillaart
//    DATE:  2012-04-09
//
// PUPROSE: simple pulse width meter
//
volatile int state = LOW;
volatile unsigned long start=0;
volatile unsigned long stop=0;

void setup()
{
  Serial.begin(115200);
  attachInterrupt(0, detect, CHANGE);
}

void loop()
{
  if (start > 0 && stop > 0)
  {
    Serial.print(stop - start);
    Serial.println(" uSec");
    stop = start = 0;
  }
}

void detect()
{
  if (digitalRead(2) == LOW) stop = micros();
  else start = micros();
}

pin change interrupt would be useful in keeping sample times in check?

Good thinking 99, just wait for a rising edge and sample, then wait for a falling edge and sample, as long as the voltage is always high enough to trigger a logic level.

We need a little more info about this signal from chooriang.


Rob

Hello,
thank's for follow up.
How to say...

This signal is fan motor sensor signal.
It determines the state of the revolution
of the fan. The faster the fan rotates,
frequency of the signal is getting higher.

More detail, that is a collector voltage a transistor
(perhaps NPN type). The collector voltage was paralleled from
the input voltage of the fan with 24 K resistor and a zener diode
are connected in series. If the rating voltage of the fan is 12 VDC,
then the collector voltage will be 12 VDC, and so for 24 VDC fan,
48 VDC fan and 60 VDC fan. The base of the transistor was triggered
by an output signal of a drive IC of the fan.

I can say, in normal condition, the frequency is hundreds of Hz. Since
the speed of the motor is about thousand rpm.
About the minimum voltage value, lets ignore the minus value and assume it
as zero (0). About the threshold, I think it's not available. :slight_smile:

Sometimes, the internal transistor (or the drive IC itself) is broken
and affects the values of the maximum voltage and minimum voltage
of the sensor signal.
That is why I need to check these both values then judge the
condition of the fan motor.

Hope I can explain it well.

the frequency is hundreds of Hz. Since the speed of the motor is about thousand rpm.

That's only about 16Hz but maybe there are more than one pulse per revolution.

No matter, as long as the frequency is always about the same you don't have to worry about when to sample, beat frequencies etc.

So I gather that the pulses are 0-12/24/48/60V depending on the fan. If you use a voltage divider you will get 4 different levels some of which will be too low to trigger an interrupt, so I would run your signal to a resistor (1k) and from there to a zener (4v7) then other end of the zener to GND. At the resistor/zener junction you will have a 4+v signal, run that to an interrupt input.

Meanwhile a voltage divider set to the 60v level is used to feed the ADC, 12v fans won't get as accurate a reading as 60v fans but I don't think that matters here.

Then trigger the interrupt on a rising signal, wait for a poofteenth and take a reading. Then either change the interrupt level to falling and repeat or just wait for half the signal period.

Do that a few times and average the readings.


Rob