I'm looking to see if anyone has a sketch that might work for a test I need to do. I'd like to use a GM TPS sensor (0-5v) to control the "throttle" back into the arduino. Then from that output a square wave to trigger a tachometer. Would be nice to have the RPM delay in increasing from throttle input to simulate the delay. Maybe another pot on the input side to simulate load (increase delay).
TPS sensors come in many varieties, most are pulse outputs. For the square wave take the pulse stream from the TPS into the clock input of a D flop, connect the Data to the Q output and the Q output is your square wave 50% / 50% and 50% of the pulses. You can generate what you want with a arbitrary function generator. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil
patracy:
I'm looking to see if anyone has a sketch that might work for a test I need to do. I'd like to use a GM TPS sensor (0-5v) to control the "throttle" back into the arduino. Then from that output a square wave to trigger a tachometer. Would be nice to have the RPM delay in increasing from throttle input to simulate the delay. Maybe another pot on the input side to simulate load (increase delay).
What frequency range do you need at the tach output?
~0V = X Hz
~5V = Y Hz
I think there is a little confusion here. I would assume that by TPS that the OP is referring to a throttle position sensor which is usually a potentiometer. Will have to see if the OP confirms this.
https://www.youtube.com/watch?v=l30-TNXj9Qc
So: Blue is the signal, Yellow/Beige is +5V, and Black? Dark grey? is Ground.
The analogRead() should get you a number from 0 to 1023.
You can use the "tone()" function to give an output frequency.
Maybe throttle = ((9 * throttle) + analogRead(throttlePin)) / 10; to give some lag.
const byte TPS_AIPin = A0;
const byte Tach_DOPin = 4;
const byte Lag = 10; // Higher numbers create slower response
unsigned Throttle = 0; // 0 to 1023
const unsigned MinThrottleFrequency = 800;
const unsigned MaxThrottleFrequency = 6500;
void setup()
{
pinMode(Tach_DOPin, OUTPUT);
}
void loop()
{
Throttle = (((Lag - 1) * Throttle) + analogRead(TPS_AIPin)) / Lag;
tone(Tach_DOPin, map(Throttle, 0, 1024, MinThrottleFrequency, MaxThrottleFrequency));
delay(Lag);
}