Beim Coprozessor gibt es eine erweiterte Paritätsprüfung, es werden jetzt 59 Impulse gezählt. In der 5 Volt Variante des Anzeigemoduls sind jetzt weniger Variablen.
This commit is contained in:
@ -6,28 +6,33 @@
|
||||
Wenn ein gültiges Signal gesendet wurde, gibt es eine Pause von 30 Minuten,
|
||||
in dieser Zeit wird der DCF Empfänger an Pin 6 abgeschaltet.
|
||||
mit Hilfe von: https://wolles-elektronikkiste.de/dcf77-funkuhr
|
||||
30.04.2025
|
||||
19.05.2025
|
||||
www.buschke.net
|
||||
info@buschke.net
|
||||
*/
|
||||
|
||||
#include <util/parity.h> //comment out if you don't use an AVR MCU
|
||||
|
||||
#define dcfOnOut 6
|
||||
#define dcfOnOff 6
|
||||
int interruptPin = 2;
|
||||
|
||||
volatile unsigned long lastInt = 0;
|
||||
volatile unsigned long long currentBuf = 0;
|
||||
volatile byte bufCounter;
|
||||
volatile bool parityStat = 0;
|
||||
volatile byte parityStat = 0;
|
||||
volatile byte dcf77MinuteEiner = 0;
|
||||
volatile byte dcf77MinuteZehner = 0;
|
||||
volatile byte dcf77HourEiner = 0;
|
||||
volatile byte dcf77HourZehner = 0;
|
||||
|
||||
volatile int testVar = 0;
|
||||
unsigned long startMillis = 0;
|
||||
const long waitingTime = 1800000; // 30 Minuten
|
||||
byte dcfState = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
pinMode(dcfOnOut, OUTPUT);
|
||||
digitalWrite(dcfOnOut, HIGH);
|
||||
pinMode(dcfOnOff, OUTPUT);
|
||||
digitalWrite(dcfOnOff, HIGH);
|
||||
pinMode(interruptPin, INPUT);
|
||||
attachInterrupt(digitalPinToInterrupt(interruptPin), DCF77_ISR, CHANGE);
|
||||
}
|
||||
@ -44,12 +49,26 @@ void loop() {
|
||||
Serial.print(dcf77MinuteEiner);
|
||||
delay(100);
|
||||
|
||||
digitalWrite(dcfOnOut, LOW);
|
||||
dcfState = LOW;
|
||||
digitalWrite(dcfOnOff, dcfState);
|
||||
|
||||
parityStat = 0;
|
||||
delay(1800000); // 30 Minuten, 15 Minuten Wartezeit: 900000
|
||||
digitalWrite(dcfOnOut, HIGH);
|
||||
|
||||
}
|
||||
|
||||
unsigned long currentMillis = millis();
|
||||
|
||||
if (currentMillis - startMillis >= waitingTime) {
|
||||
startMillis = currentMillis;
|
||||
if (dcfState == HIGH) {
|
||||
dcfState = LOW;
|
||||
}
|
||||
else {
|
||||
dcfState = HIGH;
|
||||
}
|
||||
digitalWrite(dcfOnOff, dcfState);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
@ -58,15 +77,17 @@ void loop() {
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
void DCF77_ISR() { //
|
||||
void DCF77_ISR() {
|
||||
unsigned int dur = 0;
|
||||
dur = millis() - lastInt;
|
||||
|
||||
if (digitalRead(interruptPin)) {
|
||||
|
||||
if (dur > 1500) {
|
||||
|
||||
unsigned long highBuf = (currentBuf >> 32) & 0x7FFFFFF;
|
||||
unsigned long lowBuf = (currentBuf & 0xFFFFFFFF);
|
||||
testVar = bufCounter;
|
||||
bufCounter = 0;
|
||||
|
||||
evaluateSequence();
|
||||
@ -78,6 +99,7 @@ void DCF77_ISR() { //
|
||||
currentBuf |= ((unsigned long long)1 << bufCounter);
|
||||
}
|
||||
bufCounter++;
|
||||
|
||||
}
|
||||
lastInt = millis();
|
||||
}
|
||||
@ -106,11 +128,6 @@ void evaluateSequence() {
|
||||
bool parityBitHour = (currentBuf >> 35) & 1;
|
||||
bool parityBitDate = (currentBuf >> 58) & 1;
|
||||
|
||||
/***************************************************************************
|
||||
Paritätsprüfung
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
if ((parity_even_bit(dcf77Minute)) != parityBitMinute) {
|
||||
parityStat = 0;
|
||||
}
|
||||
@ -122,6 +139,9 @@ void evaluateSequence() {
|
||||
{
|
||||
parityStat = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (dcf77MinuteEiner > 9) {
|
||||
parityStat = 0;
|
||||
}
|
||||
@ -134,12 +154,7 @@ void evaluateSequence() {
|
||||
if (dcf77HourZehner > 2) {
|
||||
parityStat = 0;
|
||||
}
|
||||
if (dcf77Hour == 0 && dcf77Minute == 0) {
|
||||
if (testVar != 59) {
|
||||
parityStat = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
unsigned int rawByteToInt(byte raw) {
|
||||
return ((raw >> 4) * 10 + (raw & 0x0F));
|
||||
}
|
||||
|
Reference in New Issue
Block a user