Pages: [1]   Go Down
Author Topic: Reading pulses from another circuit  (Read 420 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So, I'm trying make a shift light for my 1992 BMW.  Looking on the BMW forums, I can get to my tacho wire (not OBDII car is too old).  First off I'm just trying to get pulseIn (or alternative) to work.
I have my Nano with a simple bit of code to provide a pulse that my Uno can read.
pin10 high, delay(100), pin10 low, delay(duration) - duration controlled by a potentiometer on the Nano.
So I'm treating pin10 as the cable i find in the car, I can hopefully calibrate later once i get it functioning.

Not had much luck with pulseIn function and I'm a bit confused about what my wiring should look like. I wonder if anyone can help.

I tried the pulseIn tutorial, (not a lot of info on the page)  also found a nice bit code that could replace pulseIN
if (digitalRead(inputPin) == HIGH)
       {
         pulseBegin = millis();
         while (digitalRead(inputPin) == HIGH){}
         pulseDuration = millis()-pulseBegin;
         Serial.println(pulseDuration);
       }

My wiring tried just bridging output pin 10 on nano to input pin on the uno, but i don't get any change in the serial reading when i tweek the nano potentiometer.

I always think with my electrical brain rather than electronics, what I'd like to wire up is the equivalent of;
The nano/car signal drives a relay coil, then the uno has +5v going to the power side of the relay and a digital-in pin from the NO contact.

I'm beggining to dable with transistors and it feels like I should use one here, but don't quite know how to read by 4 pin relay concept to the 3 pins on the transistor.

Hope this makes sense!

Many thanks
Neal
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6613
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are looking for a 4-pin equivalent of a relay in that situation, use an opto isolator instead of a transistor (with a resistor in series with the input).

BTW the usual way to measure the interval of a regular input signal is to feed it into a pin that supports attachInterrupt, attach a service routine using mode RISING or FALLING, and time the interval between interrupts.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I can get to my tacho wire

You will need to get a sense of what types of signals you are dealing with. My guess is that it is a pwm signal - most tachos are like that.

In that case, you will need to measure duty cycle + period.

It can be a one-timer or two-timer solution, depending on how you want to solve it.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Trying the opto isolator solution this evening. Thanks guys.
Logged

Pages: [1]   Go Up
Jump to: