projects
/
the_perfect_clock.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e764d85
)
Experimental code to clean up the signal by averaging 1000 samples
author
Art Cancro
<ajc@citadel.org>
Fri, 25 Aug 2023 19:34:44 +0000
(15:34 -0400)
committer
Art Cancro
<ajc@citadel.org>
Fri, 25 Aug 2023 19:34:44 +0000
(15:34 -0400)
the_perfect_clock.ino
patch
|
blob
|
history
diff --git
a/the_perfect_clock.ino
b/the_perfect_clock.ino
index 318d641e1cbcaf392fa3527a34085d6862b81cbb..590a1c7fa51ed51306605a47d52fadeda59ef130 100644
(file)
--- a/
the_perfect_clock.ino
+++ b/
the_perfect_clock.ino
@@
-87,6
+87,27
@@
void setup() {
// Note: only write to the display when the readout needs to be updated.
// Speaking I2C on every loop iteration jams the WWVB receiver.
void loop() {
// Note: only write to the display when the readout needs to be updated.
// Speaking I2C on every loop iteration jams the WWVB receiver.
void loop() {
+ int signal;
+ static int total_samples = 0;
+ static int high_samples = 0;
+
+ if (total_samples >= 1000) {
+ if (high_samples > 500) {
+ signal = HIGH;
+ }
+ else {
+ signal = LOW;
+ }
+ total_samples = 0;
+ high_samples = 0;
+ }
+ else {
+ total_samples += 1;
+ if (digitalRead(wwvb) == HIGH) {
+ ++high_samples;
+ }
+ }
+
unsigned long m = millis();
if (m != previous_millis) {
millisecond += (m - previous_millis);
unsigned long m = millis();
if (m != previous_millis) {
millisecond += (m - previous_millis);
@@
-101,11
+122,11
@@
void loop() {
}
}
}
}
}
}
-
}
+ }
previous_millis = m;
int pulse_length;
previous_millis = m;
int pulse_length;
-
int signal = digitalRead(wwvb);
// is the input high or low right now?
+
//int signal = digitalRead(wwvb);
// is the input high or low right now?
if (signal) {
analogWrite(timecodeled, 10); // it's too bright on my board so we dim it; change to digitalWrite() if not needed
if (signal) {
analogWrite(timecodeled, 10); // it's too bright on my board so we dim it; change to digitalWrite() if not needed