projects
/
the_perfect_clock.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Reduced hysteresis to 3 samples. Expanded valid pulse width range.
[the_perfect_clock.git]
/
the_perfect_clock.ino
diff --git
a/the_perfect_clock.ino
b/the_perfect_clock.ino
index 318d641e1cbcaf392fa3527a34085d6862b81cbb..25294922e37eb4ea9aae6ba721ffdb062b21e995 100644
(file)
--- a/
the_perfect_clock.ino
+++ b/
the_perfect_clock.ino
@@
-87,6
+87,11
@@
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() {
+
+ // Reading it three times and taking the average gives us some hysteresis
+ int signal = (digitalRead(wwvb) + digitalRead(wwvb) + digitalRead(wwvb)) / 3;
+
+ // has the timer ticked?
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,14
+106,13
@@
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?
if (signal) {
if (signal) {
- analogWrite(timecodeled,
10
); // it's too bright on my board so we dim it; change to digitalWrite() if not needed
+ analogWrite(timecodeled,
5
); // it's too bright on my board so we dim it; change to digitalWrite() if not needed
}
else {
digitalWrite(timecodeled, LOW);
}
else {
digitalWrite(timecodeled, LOW);
@@
-120,13
+124,13
@@
void loop() {
else if ((!signal) && (previous_signal)) { // trailing edge of pulse detected
pulse_length = millis() - start_of_pulse;
else if ((!signal) && (previous_signal)) { // trailing edge of pulse detected
pulse_length = millis() - start_of_pulse;
- if (pulse_length > 1
75 && pulse_length < 225
) { // "0" bit ~= 200 ms (represented as "0")
+ if (pulse_length > 1
50 && pulse_length < 250
) { // "0" bit ~= 200 ms (represented as "0")
this_pulse = 0;
}
this_pulse = 0;
}
- else if (pulse_length > 4
75 && pulse_length < 525
) { // "1" bit ~= 500 ms (represented as "1")
+ else if (pulse_length > 4
50 && pulse_length < 550
) { // "1" bit ~= 500 ms (represented as "1")
this_pulse = 1;
}
this_pulse = 1;
}
- else if (pulse_length > 7
75 && pulse_length < 825
) { // marker bit ~= 800 ms (represented as "2")
+ else if (pulse_length > 7
50 && pulse_length < 850
) { // marker bit ~= 800 ms (represented as "2")
this_pulse = 2;
}
else {
this_pulse = 2;
}
else {