Dynamic frequency change?

Is it possible to do dynamic frequency altering on the fly with Arduino Uno? I'm looking to multiply a signal that comes from a magnetic speed sensor and the signal varies from 0 ppm and up. It would then be multiplied with a fixed multiplier and send to the output. The idea is to build this for a car that gets speed information from an abs sensor and then convert it to suitable hz for the speedometer. I have some programming background but i have not used arduino before. I think it does not need a very complex code to achieve my goal but is the board up to the task? Thank you for your help in advance.

What input frequencies and what multiplier?

I'm not sure what the input frequencies are. I think they could be calculated from the triggerplate on the wheel and compare to the circumference of the tyre? I'm not sure about the multiplier either as i was going to adjust it on the fly by trial and error approach. I know that 33hz will display in the speedometer as around 30 km/h.

The main question i'm after here is that is my goal achievable with arduino? I don't want to purchase it and bang my head to a brick wall just to find out that it is not possible to do the job with it. I've done that with Dakota Digitals signal converter and i'm now running out of options if this is not my solution.

It may be possible, but without the information requested in reply #1, anyone would be just guessing. You are the only one with the hardware, and you need to do some basic research.

There are probably much better ways to accomplish your goal.

33 pulses per second = 30303 microSeconds per pulse times 30 km/h = 909090. So, km/h = 909090 / micros per pulse. What kind of signal does the ABS sensor produce (voltage, waveform)?

It's a passive sensor and this is what i've found on it from the internet:

The rotational movement of the ABS ring and the associated alternation of teeth and gaps effects a change in the magnetic flux through the pulse wheel and the coil. The changing magnetic field induces an alternating voltage in the coil that can be measured. The frequencies and amplitudes of the alternating voltage are related to the wheel speed. The sensor creates a AC signal that changes frequency as the wheel changes speed.

When measuring the sensor with a standard multimeter and the same time rotating the wheel by hand it produces a few millivolts.

Electricity is not my strongest point so I apologize for my dumb questions...

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.

What make/model car/sensor?
What make/model car/speedo?
Usually you can find through google what the output will be.

Have you googled
speedometer signal converter

or

speedometer signal converter arduino

Thanks.. Tom... :slight_smile:

Tried to google but none of my findings match on my particular problem.

The car is VW Golf MK3 1995. The car originally has a VSS in the transmission but i changed the trans to a newer Golf one that does not have the VSS (the speed is calculated from ABS system in that model). My Golf has ABS but from my experience if you piggyback the signal from one of the original ABS sensors the ABS system does not behave as it should be. So i installed an extra ABS sensor (original and similar to the other four but no idea of it's make) to the left front trigger plate and i was planning to use it to get the speed signal to a signal converter and then pass it on to the instrument cluster (original VDO) and ecu. As i earlier posted, i purchased a Dakota Digital SGI-5E signal converter but i can't get it dialed in properly for my setup and it is hard to fine tune it. So i did some googling and Arduino seemed to be the next thing to try. I've now ordered Arduino Uno Rev3 SMD and i try to google some example codes but as i'm starting from scratch here, any help would be appreciated...

I tried this code that i found on this forum:

#include <TimerOne.h>
//https://github.com/PaulStoffregen/TimerOne

//volatile unsigned long count = 0;
volatile unsigned int count = 0;
float cf = 1.085; // correction faktor
//float copyCount = 0;
int copyCount = 0;
//float SpeedPulseOut;
int SpeedPulseOut = 0;
const byte pulseOutPin = 9;

unsigned long lastRead = 0;
unsigned long interval = 500; // updatespeed 0,5sec

void setup()
{
  Serial.begin(115200);
  pinMode(3, INPUT_PULLUP); //external interrupt 1 on pin 3
  attachInterrupt(1, isrCount, RISING);
  //tone(3, 500);//500hz on pin 3 test input
  pinMode(pulseOutPin, OUTPUT);
  
  //Timer1 library interrupt to output sq wave
  Timer1.initialize(500000);//base time interrupt every .5 sec
  Timer1.attachInterrupt(pulseOutput);
}

void loop()
{
  if (millis() - lastRead >= interval) //read interrupt count every interval
  {
    lastRead  += interval; //millis();
    // disable interrupts, make copy of count, reenable interrupts
    noInterrupts();
    copyCount = count;
    count = 0;
    interrupts();

    SpeedPulseOut = copyCount * 1000UL / interval * cf;
    Serial.println(SpeedPulseOut);
    //tone(9, SpeedPulseOut); //replace with Timer1 interrupt
  }
}

void isrCount()
{
  count++;
}

void (pulseOutput)()  //toggle output pin 1Hz minimum
{
  Timer1.initialize(500000 / SpeedPulseOut);//change frequency
  //toggle output pin
  digitalWrite(pulseOutPin, !digitalRead(pulseOutPin));
}

But it gives an error when compiling:

Timer1.attachInterrupt(pulseOutput);

^~~~~~~~~~~

pulseOutPin

exit status 1
'pulseOutput' was not declared in this scope

I tried to look at the code of that library, but did not get any pointers on how to fix the problem?
I was planning to use the code for testing the speedometer without the car at first to see if it works with static out put and then try it with the sensor input.

rotating the wheel by hand it produces a few millivolts

You need to have a much better idea about the signal levels in a realistic application.

A change of about 3 V is required to trigger an edge interrupt, and the edge should be rather sharp. You will probably need an amplifier or a zero crossing detector for the sensor output.

void (pulseOutput)()  //toggle output pin 1Hz minimum
{
  Timer1.initialize(500000 / SpeedPulseOut);//change frequency
  //toggle output pin
  digitalWrite(pulseOutPin, !digitalRead(pulseOutPin));
}

Incorrect syntax. Remove the parentheses from aroung the function declaration and the code compiles.

void pulseOutput()  //toggle output pin 1Hz minimum
{
  Timer1.initialize(500000 / SpeedPulseOut);//change frequency
  //toggle output pin
  digitalWrite(pulseOutPin, !digitalRead(pulseOutPin));
}

Thank you for your help and comments. The code compiled after removing parentheses.

Now i'm wondering why the output voltage on pin9 is just 2,5volts? My speedometer requires 5 volts to operate.

jremington: Any suggestions on that amplifier or should i change to a different type of sensor? That is possible as i'm looking for a solution that does not require a lot of components to keep this simple. I think an optical sensor would not work as the sensor would be located near the driveshaft in a place that has a lot of dust...? Does hall sensor give a sharper edge to the signal? I can change the passive sensor to that.

Now i'm wondering why the output voltage on pin9 is just 2,5volts? My speedometer requires 5 volts to operate.

const byte pulseOutPin = 9;

void (pulseOutput)()  //toggle output pin 1Hz minimum
{
  Timer1.initialize(500000 / SpeedPulseOut);//change frequency
  //toggle output pin
  digitalWrite(pulseOutPin, !digitalRead(pulseOutPin));
}

How are you measuring this? You are toggling pin 9 between 0 and 5v. The average voltage will be 2.5 if read with a multimeter.

cattledog:
How are you measuring this? You are toggling pin 9 between 0 and 5v. The average voltage will be 2.5 if read with a multimeter.

Yes, i measured it with a multimeter and did not think about it to display the voltage like that. So now that it is ok, i'm wondering if my spare speedometer is broken as it does nothing when plugging the pin 9 to the VSS input pin behind the cluster... I'll have to test it again with the cluster that is installed to the car as it previously worked when it got it's signal from the gearbox.

javanator:
Thank you for your help and comments. The code compiled after removing parentheses.

Now i'm wondering why the output voltage on pin9 is just 2,5volts? My speedometer requires 5 volts to operate.

If you are outputting pulses, then using a DMM and measuring DC volts will not show it working.
You need to look at the frequency of the output.
2.5Vdc sounds right for a 50% duty cycle 5Vdc square-wave, but 2.5Vdc reading will not change in Vdc as the frequency changes.
What DMM do you have and does it have a Hz scale or do you have access to an oscilloscope?
Tom... :slight_smile:

Can you please let us know what the output of the ABS you added? Is the signal properly driving the interrupt count on the Arduino?

What is the required input for the speedometer?

Your code are varies the frequency of 5v square wave based on the interrupt count from the ABS sensor, and there are tests in the code using tone() to simulate that. Was tone() successful in driving the speedometer?

TomGeorge:
If you are outputting pulses, then using a DMM and measuring DC volts will not show it working.
You need to look at the frequency of the output.
2.5Vdc sounds right for a 50% duty cycle 5Vdc square-wave, but 2.5Vdc reading will not change in Vdc as the frequency changes.
What DMM do you have and does it have a Hz scale or do you have access to an oscilloscope?
Tom... :slight_smile:

My DMM is a basic one like this:
voltmeter

Sadly i do not have an oscilloscope yet.

cattledog:
Can you please let us know what the output of the ABS you added? Is the signal properly driving the interrupt count on the Arduino?

What is the required input for the speedometer?

Your code are varies the frequency of 5v square wave based on the interrupt count from the ABS sensor, and there are tests in the code using tone() to simulate that. Was tone() successful in driving the speedometer?

Sorry for my bad output. I earlier tested the speedo with that tone() and tried to output 50hz to it as then it should show about 50km/h. I also tested the arduino with my other speedo that is mounted to the car and it does not do anything there either. I don't think there is a point to try to read the signal from the ABS before i can get the output working?

I know that 33hz will display in the speedometer as around 30 km/h.

Do you have any documentation on the speedometer? If this speedo received the signals from the VSS sensor, do you know how those low voltage AC signals were processed for the speedometer? Do you have any documentation on the speedometer?

Until you can define the required input for the speedometer, and the output from the ABS signal source, you don't need to be working on code unless it is diagnostic.

If tone() does not drive the speedo, then the output from the sketch will not do that either.

I can't find any documents on the speedo but i got the wiring diagram for my car. There the VSS is directly connected to the instrument cluster and the VSS is supplied by 12 volts so no wonder arduino is not able to make the speed dial to work... So what do i need to make the 5 volts output to 12 volts? I found this MegaMoto motorshield for arduino but it seems like a little too hardcore solution for this project.

I can't find any documents on the speedo but i got the wiring diagram for my car. There the VSS is directly connected to the instrument cluster and the VSS is supplied by 12 volts so no wonder arduino is not able to make the speed dial to work... So what do i need to make the 5 volts output to 12 volts?

There are too many unknowns. My guess is that the speedometer is a stepper motor dial gauge and does not take direct pulses from the VSS sensor. Some other piece of electronics inputs the pulses and outputs steps to the gauge.
However, it is possible that those electronics are in the speedometer unit, and not some off board processing unit. In that case, if the VSS pulses were at 12v, then you may be able to directly substitute a 12 volt signal using a transistor as a switch.

EDIT: It's possible that you have an air core speedometer gauge and that is a completely different driver situation.

There may indeed be 12v pulses to the stepper, but just inputting a 12v square wave to the speedometer input at some varying frequency is not likely to work in my opinion unless the stepper processing is in the speedometer.

Because there are all kinds of unknown signal processing between the VSS output and the speedometer input. Trying to replicate that with unspecified output from an ABS sensor is even more difficult.

Without the hardware and the ability to experiment and use an oscilloscope, its going to be difficult for anyone to help you.

You will really need to provide us with more details about the original system, what signals came from the VSS unit, where did they go and what did the input to the speedometer looks like. All these questions have been asked before.