How can i get inverse square signal ?

As I am working on ECU for Auto Rickshaw. In that I have to manage RPM signals.I am getting distorted Square waves as output signal from RPM socket of engine. As I have to control that signal or say manage injection time through that signals, I needed time period of false signal from RPM signals. And here is the point where I got stuck. So I need to know some solution about means How can I get inverse Signals?

Use a Not gate.

Normally an unclean signal like that would be cleaned up with a low-pass-filter followed by a schmitt-trigger
gate such as 74HC14 not-gate. The low pass filter helps remove noise and spikes and the schmitt-trigger input
has hysteresis to get clean sharp logic transitions.
Is all this at 5V?

Are you using an Arduino? If so, you don't need to invert the signal to measure the time period, width or low interval. Also, having a distorted signal, could use Arduino's built-in comparator to trigger an interrupt at the desired voltage level. If you need an inverted signal for feedback control, then the interrupt routine could create one for you.

MarkT:
Normally an unclean signal like that would be cleaned up with a low-pass-filter followed by a schmitt-trigger
gate such as 74HC14 not-gate. The low pass filter helps remove noise and spikes and the schmitt-trigger input
has hysteresis to get clean sharp logic transitions.
Is all this at 5V?

I already tried out this one but i don't get what i want.
No, not 5V. Around 12V.

dlloyd:
Are you using an Arduino? If so, you don't need to invert the signal to measure the time period, width or low interval. Also, having a distorted signal, could use Arduino's built-in comparator to trigger an interrupt at the desired voltage level. If you need an inverted signal for feedback control, then the interrupt routine could create one for you.

Yes, i'm using an Arduino for this project. Ok, as I'm new to Arduino I have no idea about built-in comparator to trigger an interrupt at desired voltage. Can you explain it ?

Any picture of the waveform?

MarkT:
Any picture of the waveform?

Yes...I attached image here. Upper one is waveform after using LOW PASS FILTER and SCHMITT TRIGGER... And Below one is waveform of raw output means direct waveform from RPM socket.

What part of the yellow trace do you need to measure the timing - the low interval (0V?), the high peak interval (21V?), or the high interval (13.5V?).

I don't see why filtering is needed. Could use a voltage divider then connect to an interrupt pin.

dlloyd:
What part of the yellow trace do you need to measure the timing - the low interval (0V?), the high peak interval (21V?), or the high interval (13.5V?).

I don't see why filtering is needed. Could use a voltage divider then connect to an interrupt pin.

Measuring the timing of the low interval. Filtering for just removing noise that's why i used LOW PASS FILTER. And for pure square wave, i used SCHMITT TRIGGER. If this things working perfectly then i get SQUARE WAVE. I attached image, so you can understand what i mean. In image, you can see UPPER Signal(which i draw for understanding purpose) means PURE SQUARE WAVE which i also want. And after that using pulseIn() function, i can easily find timing of that pulse.

dlloyd:
What part of the yellow trace do you need to measure the timing - the low interval (0V?), the high peak interval (21V?), or the high interval (13.5V?).

I don't see why filtering is needed. Could use a voltage divider then connect to an interrupt pin.

A current limiting resistor into a capacitor (remove high frequency noise), then a schmitt-trigger. The
current limiting resistor allows the schmitt-trigger input protection diodes to clamp the waveform to the
logic supply range nicely.

Try 22k, 1nF and a 74HC14 hex-schmitt-trigger inverter chip.

You don't want to put a signal with contact bounce or noise direct onto an interrupt pin as the
myriad multiple transitions will swamp the processor and give lots of grief.

Try 22k, 1nF and a 74HC14 hex-schmitt-trigger inverter chip.

A great solution.

The ringing seems to span about 2ms, the spikes could be 0.2ms (should be measured using a lower timebase on scope). May need to increase the cap a bit to keep the ringing/spikes within hysteresis trigger levels.

My initial thoughts were a more elaborate interrupt routine to deal with the noise.

MarkT:
A current limiting resistor into a capacitor (remove high frequency noise), then a schmitt-trigger. The
current limiting resistor allows the schmitt-trigger input protection diodes to clamp the waveform to the
logic supply range nicely.

Try 22k, 1nF and a 74HC14 hex-schmitt-trigger inverter chip.

You don't want to put a signal with contact bounce or noise direct onto an interrupt pin as the
myriad multiple transitions will swamp the processor and give lots of grief.

Ok...thanks mate... I will make circuit based on your suggestion...

MarkT:
Try 22k, 1nF and a 74HC14 hex-schmitt-trigger inverter chip.

Thanks mate. As per your suggestion, i made circuit and it's working properly. I get exact waveform which i want. I attached image of output waveform. Now, as my main purpose is find the length of waveform, i used pulseIn() function. But in serial monitor only 0 is displayed. No variation found. I don't know why. Please give me some suggestion.

Post your code if you want help with it...

Yes, will need to see your code.


Some comments...

To measure the LOW duration of the input, you'll need to use pulseIn(HIGH) due to the schmitt-trigger inverter.

Note that there's a spike about 4ms after the pulse. PulseIn would return the measurement, then 4ms later it would return 0 due to the spike. To deal with this in code, could use something like

unsigned long signalLowDuration = pulseIn(signalPin, HIGH);
if (signalLowDuration) {
  // your code
}

MarkT:
Post your code if you want help with it...

Here, it's my code...

int pulsepin = 8;
int value = 0;

void setup() 
{
   pinMode(pulsepin, INPUT); 
   Serial.begin(9600);
}

void loop()
{
   value = pulseIn(pulsepin, HIGH);
   Serial.println(value);
   delay(1000);
}