Heb vandaag weer zitten prutsen aan de arduino nano
koppelen aan de PA8W 2.3 Doppler peiler.
Bedoeling is dat er agrelo (%bbb) uit de USB komt
voor allerlei kaart programma's
Nog niet alles klaar maar alvast een voor proefje.
De arduino sketch zit er ook bij
Niet alles is klaar en working Yet !
Groeten,
Lodewijk
Source
===============================================================
/*
((C))PA3BNX Arduino PA8W Agelo
19-09-2017 Not all ready yet!
2^5 data bits from PA8W and Strobe
I think tap from 4017 the 5 bits and tap the freeze led as Strobe/Squelch
2^4 data bits and strobe from other dopplers
Purpose is to give Agrelo Serial out with a cheap arduino(Uno,Nano)
on existing doppler.
-------
Use a inverting transistor to interface bits and strobe from doppler to arduino
-------
Arduino outputs Agrelo like %DDD<cr><lf>
Replacement 1995-N7LUE.pdf Agrelo Interface BY ROBERT SWAIN
4 or 5 counter hardware bits from 4040 or 4060 in hardware doppler
and the strobe Zerocross pin.
//Options also possible with arduino ?
Arduino could also do GPS Module and output NMEA on software serial port ?
Arduino could also do FluxCompas HMC5883 TWI interface ?
22-09-2017
04-08-2018
20-11-2019
potmeter 0 offset degrees so hardware pelorus same as agrelo pelorus ??? 22-11-2019
*/
//Const
const int cNodegrees = 999; //Squelch
const int cReset = 888; //Reset averaged with last degrees value only
const double f = 359/1023;
const int cSquelchOpenMax= 5000;//Max averaged time in Averaged sub
//Limit Degrees 0 to 360 degrees
int LimitDegrees360(int d) {
//Limit degrees 0 to 360 here
//If 999 then return 999
if (d == cNodegrees)
{
return d;
}
else
{
int x;
x = d % 360;
if (x < 0)
{
x += 360;
}
return x;
}
}//-------------------------------------Last LimitDegrees360==============================
//Get data from 4040 or 4060 counter in the doppler ?
//Digital counting
//So get time to get the degrees counter lines
//Create new Function detecting Strobe for some time?
int GetBearing4()
{
int x = 0;
if (digitalRead(pinStrobe) == HIGH)
{
for (byte i = 0; i < 3; i++)
{
if (digitalRead(pinData == LOW))
{
x += pow(i, 2);
}
}
return int(x * 22.5);
}
else
{
return cNodegrees;
}
}
int GetBearing5()
{
int x = 0;
if (digitalRead(pinStrobe) == HIGH)
{
for (byte i = 0; i < 4; i++)
if (digitalRead(pinData == LOW))
{
x += pow(i, 2);
}
return int(x * 11.25);
}
else
{
return cNodegrees;
}
}
//----------------------------------------Average Degrees------------------------------------
int Average(int d) {
//If d = 999 (cNoDegrees) then reset average and return last avDegrees witch is 999
//If d = 888 (cReset) then Reset all and put last avDegrees back in arrays
//Always return avDegrees and Set bMultiPath
//Integer
static unsigned int sum[4] = {0, 0, 0, 0}; //Sum of counts for each kwadrant can be now 2^16=65536
static int c[4] = {0, 0, 0, 0}; //Amount of count
static int totalCount = 0; //Sum of all counts
static int avDegrees = cNodegrees; //Averaged degrees
int xx[4] = {0, 0, 0, 0}; //Adjacent kwadrants counts
int z = 0; //Most adjacent headings
int z1 = 0; //Other two kwandants headings Multipath
int y = 0; //Index where the most headings are
//Reset/clear and return cNodegrees or last avDegrees
//01-06-2015 No Averaging
if (bAverage == false) {
return d;
}
//No Overflow in sum[]
if (totalCount >= 180)
{
for (byte i = 0; i < 4; i++)
{
sum = 0;
c = 0;
}
}
switch (d) {
case cNodegrees:
//Reset and Clear
for (byte i = 0; i < 4; i++)
{
sum = 0;
c = 0;
}
bMultiPathAverage = false;
avDegrees = cNodegrees;
return avDegrees; //Exit now
case cReset: //Reset and fill with avDegrees
//Reset
for (byte i = 0; i < 4; i++)
{
sum = 0;
c = 0;
}
//Fill with last avDegrees
d = avDegrees; //Put last degrees in again
}
if (d >= 0 && d < 90) {
sum[0] += d;
c[0]++;
}
if (d >= 90 && d < 180) {
sum[1] += d;
c[1]++;
}
if (d >= 180 && d < 270) {
sum[2] += d;
c[2]++;
}
if (d >= 270 && d <= 360) {
sum[3] += d;
c[3]++;
}
//No degrees found so exit function
totalCount = c[0] + c[1] + c[2] + c[3];
if (totalCount == 0)
{
bMultiPathAverage = false;
avDegrees = cNodegrees;
return avDegrees;
}
//Find 2 adjacent kwadrants with hold most heading counts
//Find out in witch two kwadrants the most headings are
for (byte i = 0; i < 4; i++) {
if (xx > z) {
z = xx[i]; //Most adjacent Headings counts
y = i; //Witch 2 adjacent Array Index from xx[1]
}
}
//Check for multipath kwadrants
switch (z) {
case 0:
z1 = 2;
break;
case 1:
z1 = 3;
break;
case 2:
z1 = 0;
break;
case 3:
z1 = 1;
break;
}
void loop() {
//Put your main code here, to run repeatedly:
static int OldDegrees;
int x = cNodegrees;
GetOffset();
if (bDemo == true)
{
x = GetDemo(110, 290); //begin and end degrees
}
else
{
//Does the strobe be positive or negative edge triggerd ?
//Squelch can be detected through ? and trigger LED_BUILTIN
int start = millis() + 10;
do
{
x = GetBearing4();
//x=GetBearing5();
} while (start < millis() && x != cNodegrees);
}
x = Average(x);
//Detect when squelch = closed
if (OldDegrees==cNodegrees)
{
SquelchOpenStart = millis() + cSquelchOpenMax;
}
//bMultiPathAverage, bAverage, cReset ????
//Reduce data over RS232
if (OldDegrees != x )
{
if (bMultiPathAverage == false || x == cNodegrees)
{
//Serial.println(Format3Degrees(LimitDegrees360(x)));
Serial.println(Format3Degrees(Calibrate(x)));
if (x == cNodegrees) {
digitalWrite(LED_BUILTIN, HIGH);
} else {
digitalWrite(LED_BUILTIN, LOW);
}
OldDegrees = x;
}
}
//reset average after a while averaging ???
if (millis() > SquelchOpenStart)
{
SquelchOpenStart = millis() + cSquelchOpenMax;
Average(cReset);//Save only last Averaged degrees value
}
/*
* You may think you know what the following code does.
* But you dont. Trust me.
* Fiddle with it, and youll spend many a sleepless
* night cursing the moment you thought youd be clever
* enough to "optimize" the code below.
* Now close this file and go play with something else.
*/
Oh en verder vond ik dit in de kringloop
"Contact" Carl Sagan
Super leuk boek met raak vlakken met radio ham SETI
At first it seemed impossible - a radio signal that came not from Earth but from far beyond the nearest stars. But then the signal was translated, and what had been impossible became terrifying. For the signal contains the information to build a Machine that can travel to the stars. A Machine that can take a human to meet those that sent the message. They are eager to meet ...more