Newb wanting to scale input to output

Hi guys, I am very new to this and am doing alot of searching but wanted to see if anyone wanted to give me a boost on the learning curve/project.

I've got a truck that I need to give vehicle speed to the pcm with the standard being 8000 pulses per mile. I have a tone wheel on the drive shaft with 18 teeth that will give me 39312 pulses per mile that I need to convert to 8000 pulses per mile digital to go to the pcm and speedometer. The signal from the sensor is a sine wave which I'll attach a picture of.

The speedometer is a project for another day but it's not drivable until I have the speed for shift points.

I am sure I have left out alot of information but if any one has any pointers it'd be awesome.

What's your concrete problem?

That sounds like a job for the map() function. It is a bit confusing to beginners, so if you don't understand it, let us know, and we will explain it in more detail.

DrDiettrich
At the moment the problem is setting the Arduino up to read the pulses from the tone wheel and convert it to digital.

jack wp
I looked up the map function and it looks exactly like what I need for scaling so I'll start messing with it.

Would I be right to assume I need to use INPUT_PULLUP for my input as it is 2 volts?

That input could be tricky.
Is it 2v rms or 2v peak to peak?
Can you hook a common ground, or do you want a capacitor to decouple the DC?

Off hand, I may try using a capacitor to decouple the DC. Use a pair of resistors as a voltage divider to provide 2.5 volts (mid range).

5V------|
/
\ 10k
/
|
|
---||---+--> dio arduino
.1uf |
/

/ 10k
|
GND

Or maybe a pot would work well here.

GMHuggins:
Would I be right to assume I need to use INPUT_PULLUP for my input as it is 2 volts?

More information about the electric circuitry around the tone wheel would be helpful. A wheel doesn't provide electric pulses by itself.

DrDiettrich:
More information about the electric circuitry around the tone wheel would be helpful. A wheel doesn't provide electric pulses by itself.

I would but about all the info I have on the sensor is it's a two wire magnetic. It's an automotive sensor so I don't have a data sheet on it. On it's factory wiring diagram you have one pin that is signal return and the other is vehicle speed to pcm. Resistance is listed as 781ohms - 1979ohms.

It is probably a magneto. As the shaft turns with a magnet(s) on it, a coil of wire picks up emf, and sends it out by the two wires. Probably no semiconductors in that circuit.

I also haven't commited to this sensor. I have another sensor, also automotive, that is a 5 volt reference sensor that will give me a square wave if need be.

I think the 5Volt square wave would be easier for the arduino to see, but would that mean you had to provide power (more wires)?
It's good to have a backup option, in case one does not work as expected.

You need a Schmitt trigger input so the output will be a level that you can read.

Ok, so I've got the input side of it taken care of. I'm using the 3 wire hall effect and the internal pullup to get a 5v square wave. Now I'm starting to play with the output side of it.

so now i have the input and output working properly but i need to up the output from a 5v pattern to 12v. The output is going to a vehicles pcm so no real load. I've started to look into photocouplers and mosfets, is this the right direction?

Yes.

Hi,

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Tom.... :slight_smile:

i doubt it's done right as this is my first sketch and alot is from other sources but here it is

// Frequency counter sketch, for measuring frequencies low enough to execute an interrupt for each cycle
// Connect the frequency source to the INT0 pin (digital pin 2 on an Arduino Uno)
// Using pin 2 as a pullup, cmp sensor in goes here
volatile unsigned long firstPulseTime;
volatile unsigned long lastPulseTime;
volatile unsigned long numPulses;


void isr()
{
 unsigned long now = micros();
 if (numPulses == 1)
 {
   firstPulseTime = now;
 }
 else
 {
   lastPulseTime = now;
 }
 ++numPulses;
}

void setup()
{
 Serial.begin(9600);    // this is here so that we can print the result
 digitalWrite(2,HIGH);
 pinMode(3,OUTPUT);
}

// Measure the frequency over the specified sample time in milliseconds, returning the frequency in Hz
float readFrequency(unsigned int sampleTime)
{
 numPulses = 0;                      // prime the system to start a new reading
 attachInterrupt(0, isr, FALLING);    // enable the interrupt
 delay(sampleTime);
 detachInterrupt(0);
 return (numPulses < 3) ? 0 : (1000000.0 * (float)(numPulses - 2))/(float)(lastPulseTime - firstPulseTime);
}

void loop()
{
 float freq = readFrequency(50);
 int val = freq;
 val = map(val, 0, 2184, 0, 2184);
 tone(3,val);
 Serial.print(val);
 Serial.print(freq);


 delay(500);
}

I got a mosfet board (tinkerkit t010020) and am now getting a 12v pattern but its very dirty (see attatched pic) from what I've gathered I need a pulldown circuit but I am not sure. In the picture the green is from the arduino and the yellow is the output of the mosfet.