Zerodegreec:
I have made some decent progress. The frequency does jump around quite a bit, but I have been able to filter it out -to some extent- just by clipping the spikes. Next I will do some averaging work to find a stable reading. Here is a bit of code I have cobbled together. Yes I know there are some pieces of un-used garbage floating around in the code, haven't spent much time cleaning it up as its a proof of concept thus far.
What I plan on doing with it is a speed readout for my street that can hopefully slow the idiots down driving past my house and kids. I have a matrix LED marquee display -circa 1980's- that I am re-purposing once I sort out the wiring for all the shift registers.
//* connect pin 7 to input circuit
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include <FreqPeriod.h>
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
double lfrq;
long int pp;
float kph = 0;
float mph = 0;
float omax = 0;
float nmax = 0;
float kmax = 0;
int count = 0;
void setup() {
Serial.begin(9600);
FreqPeriod::begin();
lcd.begin(16, 2);
Serial.println("Radar ON!!!");
lcd.print(" Radar ON!!!");
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("KPH:");
lcd.setCursor(0,1);
lcd.print("MPH:");
}
void loop() {
uint8_t buttons = lcd.readButtons();
pp=FreqPeriod::getPeriod(); // read the value from the sensor:
lfrq= 16000400.0 / pp;
if (buttons & BUTTON_SELECT) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("KPH:");
lcd.setCursor(0,1);
lcd.print("MPH:");
}
if(lfrq < 5000)
{
if (pp ){
count++;
Serial.print("Freq:");
Serial.print(lfrq);
Serial.print(" Hz / ");
Serial.print("Count: ");
Serial.print(count);
Serial.print(" / ");
mph = (lfrq / 31.36);
kph = (mph * 1.609344);
nmax = mph;
constrain(mph,0,100);
constrain(kph,0,100);
if(nmax > omax)
{
omax = nmax;
kmax = omax * 1.609344;
}
Serial.print(kph);
Serial.print(" KPH ");
Serial.print(mph);
Serial.println(" MPH");
lcd.setCursor(11,0);
lcd.print(kph,2);
lcd.setCursor(11,1);
lcd.print(mph,2);
lcd.setCursor(4,0);
lcd.print(kmax,2);
lcd.setCursor(4,1);
lcd.print(omax,2);
if(count == 10)
{
omax = 0;
count = 0;
}
}
}
}
Hello Zerodegreec and Arduinofreak, did you guys could make this to work ?
Because I could not make this to work and get the cars speed with Arduino...
If you could help me, I really appreciate that! Check out my post: Radar Speed based on doppler device - Sensors - Arduino Forum