I have a volvo 240 that has a analog speedometer powered by a electric pcb that needs a input of sine wave frequentie to driven the needle.
I'm working on a Arduino Uno project with a Neo M8N GPS and a AD9850 DDS. All works well untill around 120kmh. I figured out with a simple sketch that the speedometer reads up to 193Hz (193Hz ~ 120kmh). After 193Hz the needle of my speedo drops down to zero and does nothing.
Does someone know why it wont read after 193Hz?
The AD9850 DDS is connected via arduino 5V and Ground
Sine wave output to speedo.
Simple sketch:
const int W_CLK = 8;
const int FQ_UD = 9;
const int DATA = 10;
const int RESET = 11;
// Setup
void setup() {
// Arduino setup port direction.
pinMode(FQ_UD, OUTPUT);
pinMode(W_CLK, OUTPUT);
pinMode(DATA, OUTPUT);
pinMode(RESET, OUTPUT);
// Init AD9850
pulseHigh(RESET);
pulseHigh(W_CLK);
pulseHigh(FQ_UD); // Enable serial mode - Datasheet page 12 figure 10
}
// Loop
void loop() {
sendFrequency(193); // freq
while(1);
} // end loop
/******************************** Functions ****************************************/
// Toggle a pin.
void pulseHigh(int pin) {
digitalWrite(pin, HIGH);
digitalWrite(pin, LOW);
}
// transfers a byte, a bit at a time, LSB first to the AD9850 via serial DATA line
void tfr_byte(byte data)
{
for (int i=0; i<8; i++, data>>=1) {
digitalWrite(DATA, data & 0x01);
pulseHigh(W_CLK); //after each bit sent, CLK is pulsed high
}
}
// Set the desired frequency.
// frequency calc from datasheet page 8 = * /2^32
void sendFrequency(double frequency) {
int32_t freq = frequency * 4294967295/125000000; // note 125 MHz clock on AD9850
for (int b=0; b<4; b++, freq>>=8) { // Send 4 words to AD9850
tfr_byte(freq & 0xFF);
}
tfr_byte(0x000); // Final control byte, all 0 for AD9850 chip.
pulseHigh(FQ_UD); // Frequency update, output is set.
}
The document at the link you supplied in the OP seems to imply that the voltage on the G pin of the speedometer should be of the order of 250mV RMS, (however, it is not completely clear what the measuring points are). If you are driving it at 5v, that is 20 times more. Maybe try a resistor divider to bring the voltage down to that target range.
Thanks @6v6gt ! because of you I went in the right direction.
With a multimeter I read 350mV AC voltage between the G and ground from the output of the DDS.
I placed a 47 ohm resistor between the G and the ground. The output AC was then 160mV.
Now the speedo will go up to 220 kmh. Thanks a lot!