# Measuring the pulsewidth of a signal with 2.7v peak

I have a pulse signal which has the following characteristics :

1. HIGH voltage is 2.7v.
2. LOW in 0v.
3. Delay is 5mS.

I have an Arduino Nano.

How can use it to measure and print the value of the pulsewidth?

Straight from the Arduino reference pages.

The example prints the time duration of a pulse on pin 7.

``````int pin = 7;
unsigned long duration;

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

void loop() {
duration = pulseIn(pin, HIGH);
Serial.println(duration);
}
``````

The minimum voltage on an input pin that is guaranteed to read as a HIGH is 0.6 * Vcc when Vcc is between 2.4V and 5.5V. On a 5V Arduino Nano that's 3V so you can't reliably use a 2.7V signal on a 5V Arduino Nano. You could use a 8 MHz 3.3V Nano which will read a 2.7V signal with no problems.

If the 2.7V signal is from an Open Collector or Open Drain output you can connect that to a 5V INPUT_PULLUP pin directly. The pull-up will provide the HIGH signal and the Open Collector/Open Drain output will drag the pin LOW.

If it's not from an Open Collector or Open Drain output you could add your own NPN transistor to make it into an Open Collector output. The signal will be inverted. When the signal goes HIGH and puts 2.7V on the Base of the transistor the Collector of the transistor will be connected to Ground through the Emitter of the transistor and that pulls the pin LOW.

johnwasser:
On a 5V Arduino Nano that's 3V so you can't reliably use a 2.7V signal on a 5V Arduino Nano.

You could be lucky there if you power the Nano from USB.
A Nano on USB power runs on ~4.6volt, because of a schottky backflow protection diode that drops ~0.4volt.
That puts 0.6*VCC (logic HIGH) at ~2.76volt.

Better to solve it with extra circuitry though.
Post a link/diagram of the 'thing' that outputs 2.7volt.
A pull up resistor and/or diode could be needed.
Or simply use a 3.3volt Arduino.
Leo..

Or use a comparator (or any op-amp set for maximum gain). Connect the 2.7V signal to the + input, and a couple of resistors as a voltage divider to set the - input to around 1.0~1.5V.

johnwasser:
If it's not from an Open Collector or Open Drain output you could add your own NPN transistor to make it into an Open Collector output.

+1 for this solution. Simple, cheap and effective. Just two components: a transistor and base resistor (1k or so), if using the internal pull-up of the Arduino.