From 558414d084e65f0aa685f29355d29b16c31164d8 Mon Sep 17 00:00:00 2001 From: Nick Vahalik Date: Mon, 23 May 2016 06:44:13 -0500 Subject: [PATCH 1/5] Update HamShield.h Remove the hyphen in the define which causes the Arduino compiler to error. This define doesn't seem to be used anywhere. --- HamShield.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HamShield.h b/HamShield.h index a277274..3bee2e8 100644 --- a/HamShield.h +++ b/HamShield.h @@ -242,7 +242,7 @@ #define ROBOT8BW 2 -#define SC2-180 55 +#define SC2180 55 #define MARTIN1 44 // RTTY Frequencies From 868882f81e5a93f34ba0dff2ad5f7aa4fcd362fc Mon Sep 17 00:00:00 2001 From: Nigel Vander Houwen Date: Sun, 5 Jun 2016 11:53:49 -0700 Subject: [PATCH 2/5] Cleanup on AFSK-PacketTester example, verified working with current library and hardware v09 --- .../AFSK-PacketTester/AFSK-PacketTester.ino | 95 ++++++++----------- 1 file changed, 40 insertions(+), 55 deletions(-) diff --git a/examples/AFSK-PacketTester/AFSK-PacketTester.ino b/examples/AFSK-PacketTester/AFSK-PacketTester.ino index 3089bc7..47d9bf6 100644 --- a/examples/AFSK-PacketTester/AFSK-PacketTester.ino +++ b/examples/AFSK-PacketTester/AFSK-PacketTester.ino @@ -4,7 +4,6 @@ * */ - #define DDS_REFCLK_DEFAULT 9600 #include @@ -14,7 +13,6 @@ #define RESET_PIN A3 #define SWITCH_PIN 2 - HamShield radio; DDS dds; String messagebuff = ""; @@ -47,70 +45,61 @@ void setup() { Serial.println("HELLO"); } -String temp[1] = ""; - - void loop() { messagebuff = "KC7IBT,KC7IBT,:HAMSHIELD TEST"; prepMessage(); delay(10000); -} - +} void prepMessage() { - radio.setModeTransmit(); - delay(500); - origin_call = messagebuff.substring(0,messagebuff.indexOf(',')); // get originating callsign - destination_call = messagebuff.substring(messagebuff.indexOf(',')+1,messagebuff.indexOf(',',messagebuff.indexOf(',')+1)); // get the destination call - textmessage = messagebuff.substring(messagebuff.indexOf(":")+1); - - Serial.print("From: "); Serial.print(origin_call); Serial.print(" To: "); Serial.println(destination_call); Serial.println("Text: "); Serial.println(textmessage); + radio.setModeTransmit(); + delay(500); + origin_call = messagebuff.substring(0,messagebuff.indexOf(',')); // get originating callsign + destination_call = messagebuff.substring(messagebuff.indexOf(',')+1,messagebuff.indexOf(',',messagebuff.indexOf(',')+1)); // get the destination call + textmessage = messagebuff.substring(messagebuff.indexOf(":")+1); + + Serial.print("From: "); Serial.print(origin_call); Serial.print(" To: "); Serial.println(destination_call); Serial.println("Text: "); Serial.println(textmessage); - AFSK::Packet *packet = AFSK::PacketBuffer::makePacket(22 + 32); + AFSK::Packet *packet = AFSK::PacketBuffer::makePacket(22 + 32); - packet->start(); - packet->appendCallsign(origin_call.c_str(),0); - packet->appendCallsign(destination_call.c_str(),15,true); - packet->appendFCS(0x03); - packet->appendFCS(0xf0); - packet->print(textmessage); - packet->finish(); - - - bool ret = radio.afsk.putTXPacket(packet); + packet->start(); + packet->appendCallsign(origin_call.c_str(),0); + packet->appendCallsign(destination_call.c_str(),15,true); + packet->appendFCS(0x03); + packet->appendFCS(0xf0); + packet->print(textmessage); + packet->finish(); - if(radio.afsk.txReady()) { - Serial.println(F("txReady")); - radio.setModeTransmit(); - //delay(100); - if(radio.afsk.txStart()) { - Serial.println(F("txStart")); - } else { - radio.setModeReceive(); - } + bool ret = radio.afsk.putTXPacket(packet); + + if(radio.afsk.txReady()) { + Serial.println(F("txReady")); + radio.setModeTransmit(); + //delay(100); + if(radio.afsk.txStart()) { + Serial.println(F("txStart")); + } else { + radio.setModeReceive(); } - // Wait 2 seconds before we send our beacon again. - Serial.println("tick"); - // Wait up to 2.5 seconds to finish sending, and stop transmitter. - // TODO: This is hackery. - for(int i = 0; i < 500; i++) { - if(radio.afsk.encoder.isDone()) - break; - delay(50); - } - Serial.println("Done sending"); - delay(3000); - radio.setModeReceive(); -} - + } + // Wait 2 seconds before we send our beacon again. + Serial.println("tick"); + // Wait up to 2.5 seconds to finish sending, and stop transmitter. + // TODO: This is hackery. + for(int i = 0; i < 500; i++) { + if(radio.afsk.encoder.isDone()) + break; + delay(50); + } + Serial.println("Done sending"); + radio.setModeReceive(); +} ISR(TIMER2_OVF_vect) { TIFR2 = _BV(TOV2); static uint8_t tcnt = 0; if(++tcnt == 8) { - digitalWrite(2, HIGH); - dds.clockTick(); - digitalWrite(2, LOW); + dds.clockTick(); tcnt = 0; } } @@ -118,7 +107,6 @@ ISR(TIMER2_OVF_vect) { ISR(ADC_vect) { static uint8_t tcnt = 0; TIFR1 = _BV(ICF1); // Clear the timer flag - PORTD |= _BV(2); // Diagnostic pin (D2) dds.clockTick(); if(++tcnt == 1) { if(radio.afsk.encoder.isSending()) { @@ -126,7 +114,4 @@ ISR(ADC_vect) { } tcnt = 0; } - PORTD &= ~(_BV(2)); // Pin D2 off again } - - From 3c9965fd62b25a039c4882f09f17232f445089e1 Mon Sep 17 00:00:00 2001 From: Nigel Vander Houwen Date: Sun, 5 Jun 2016 12:02:21 -0700 Subject: [PATCH 3/5] Removed AFSKSend example. Redundant with AFSK-PacketTester. Cleanup on DDS example. Verified working with current library and hardware v09 --- examples/AFSKSend/AFSKSend.ino | 105 --------------------------------- examples/DDS/DDS.ino | 8 +-- 2 files changed, 4 insertions(+), 109 deletions(-) delete mode 100644 examples/AFSKSend/AFSKSend.ino diff --git a/examples/AFSKSend/AFSKSend.ino b/examples/AFSKSend/AFSKSend.ino deleted file mode 100644 index 858cb97..0000000 --- a/examples/AFSKSend/AFSKSend.ino +++ /dev/null @@ -1,105 +0,0 @@ -#include - -HamShield radio; -DDS dds; - -#define PWM_PIN 3 -#define RESET_PIN A3 -#define SWITCH_PIN 2 - -#define DON(p) PORTD |= _BV((p)) -#define DOFF(p) PORTD &= ~(_BV((p))) - -void setup() { - Serial.begin(9600); - - pinMode(4, OUTPUT); - pinMode(5, OUTPUT); - pinMode(6, OUTPUT); - pinMode(7, OUTPUT); - - // NOTE: if not using PWM out, it should be held low to avoid tx noise - pinMode(PWM_PIN, OUTPUT); - digitalWrite(PWM_PIN, LOW); - - // prep the switch - pinMode(SWITCH_PIN, INPUT_PULLUP); - - // set up the reset control pin - pinMode(RESET_PIN, OUTPUT); - // turn on pwr to the radio - digitalWrite(RESET_PIN, HIGH); - - Serial.println(F("Radio test connection")); - Serial.println(radio.testConnection(), DEC); - Serial.println(F("Initialize")); - delay(100); - radio.initialize(); - Serial.println(F("Frequency")); - delay(100); - radio.frequency(145010); - //radio.setRfPower(0); - delay(100); - dds.start(); - delay(100); - radio.afsk.start(&dds); - delay(100); - dds.setFrequency(0); - dds.on(); - dds.setAmplitude(255); - I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x44, 0b0000011111111111); - //I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x53, 0x0); - //I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x32, 0xffff); -} - -void loop() { - DON(6); - AFSK::Packet *packet = AFSK::PacketBuffer::makePacket(22 + 32); - packet->start(); - packet->appendCallsign("VE6SLP",0); - packet->appendCallsign("VA6GA",15,true); - packet->appendFCS(0x03); - packet->appendFCS(0xf0); - packet->print(F("Hello ")); - packet->print(millis()); - packet->println(F("\r\nThis is a test of the HamShield Kickstarter prototype. de VE6SLP")); - packet->finish(); - - bool ret = radio.afsk.putTXPacket(packet); - - if(radio.afsk.txReady()) { - Serial.println(F("txReady")); - radio.setModeTransmit(); - if(radio.afsk.txStart()) { - Serial.println(F("txStart")); - } else { - Serial.println(F("Tx Start failure")); - radio.setModeReceive(); - } - } - // Wait 2 seconds before we send our beacon again. - Serial.println("tick"); - // Wait up to 2.5 seconds to finish sending, and stop transmitter. - // TODO: This is hackery. - DOFF(6); - for(int i = 0; i < 500; i++) { - if(radio.afsk.encoder.isDone()) - break; - delay(50); - Serial.println("Not done"); - } - Serial.println("Done sending"); - delay(100); - radio.setModeReceive(); - delay(2000); -} - -ISR(ADC_vect) { - TIFR1 = _BV(ICF1); // Clear the timer flag - DON(4); - dds.clockTick(); - DON(5); - radio.afsk.timer(); - DOFF(5); - DOFF(4); -} diff --git a/examples/DDS/DDS.ino b/examples/DDS/DDS.ino index a843333..cd6146f 100644 --- a/examples/DDS/DDS.ino +++ b/examples/DDS/DDS.ino @@ -1,7 +1,9 @@ +// Example sketch to show how to transmit arbitrary tones. +// In this case, the sketch alternates between 1200Hz and 2200Hz at 1s intervals. + #define DDS_REFCLK_DEFAULT 9600 #include - #define PWM_PIN 3 #define RESET_PIN A3 #define SWITCH_PIN 2 @@ -24,7 +26,7 @@ void setup() { radio.initialize(); radio.setRfPower(0); - radio.setFrequency(145060); + radio.frequency(438000); radio.setModeTransmit(); dds.start(); dds.playWait(600, 3000); @@ -48,10 +50,8 @@ ISR(ADC_vect) { static unsigned char tcnt = 0; TIFR1 = _BV(ICF1); // Clear the timer flag if(++tcnt == 4) { - //digitalWrite(2, HIGH); tcnt = 0; } dds.clockTick(); - //digitalWrite(2, LOW); } #endif From 8c90a134ad471b86bace01dc889e98ad4f946067 Mon Sep 17 00:00:00 2001 From: Nigel Vander Houwen Date: Sun, 5 Jun 2016 12:41:35 -0700 Subject: [PATCH 4/5] Fixed FMBeacon example, required slight modification to library. TO-DO notes in example header. --- HamShield.cpp | 13 +++++++++---- examples/FMBeacon/FMBeacon.ino | 13 ++++++++----- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/HamShield.cpp b/HamShield.cpp index d2b49d0..50d7a10 100644 --- a/HamShield.cpp +++ b/HamShield.cpp @@ -1288,10 +1288,13 @@ void HamShield::morseOut(char buffer[HAMSHIELD_MORSE_BUFFER_SIZE]) { if(buffer[i] == ' ') { // We delay by 4 here, if we previously sent a symbol. Otherwise 7. // This could probably just be always 7 and go relatively unnoticed. - if(prev == 0 || prev == ' ') + if(prev == 0 || prev == ' '){ + tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT * 7); delay(HAMSHIELD_MORSE_DOT*7); - else + } else { + tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT * 4); delay(HAMSHIELD_MORSE_DOT*4); + } continue; } // Otherwise, lookup our character symbol @@ -1299,17 +1302,19 @@ void HamShield::morseOut(char buffer[HAMSHIELD_MORSE_BUFFER_SIZE]) { if(bits) { // If it is a valid character... do { if(bits & 1) { - tone(HAMSHIELD_PWM_PIN, 1000, HAMSHIELD_MORSE_DOT * 3); + tone(HAMSHIELD_PWM_PIN, 600, HAMSHIELD_MORSE_DOT * 3); delay(HAMSHIELD_MORSE_DOT*3); } else { - tone(HAMSHIELD_PWM_PIN, 1000, HAMSHIELD_MORSE_DOT); + tone(HAMSHIELD_PWM_PIN, 600, HAMSHIELD_MORSE_DOT); delay(HAMSHIELD_MORSE_DOT); } + tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT); delay(HAMSHIELD_MORSE_DOT); bits >>= 1; // Shift into the next symbol } while(bits != 1); // Wait for 1 termination to be all we have left } // End of character + tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT * 3); delay(HAMSHIELD_MORSE_DOT * 3); } return; diff --git a/examples/FMBeacon/FMBeacon.ino b/examples/FMBeacon/FMBeacon.ino index eac2238..0398d48 100644 --- a/examples/FMBeacon/FMBeacon.ino +++ b/examples/FMBeacon/FMBeacon.ino @@ -3,16 +3,18 @@ Morse Code Beacon Test beacon will transmit and wait 30 seconds. Beacon will check to see if the channel is clear before it will transmit. + +TO-DO: Radio chip audio AGC too slow in responding to tones, worked around by playing a 6khz tone between actual dits/dahs. +Should work on adjusting AGC to not require this. */ -// Include the HamSheild +#define DDS_REFCLK_DEFAULT 9600 #include #define PWM_PIN 3 #define RESET_PIN A3 #define SWITCH_PIN 2 -// Create a new instance of our HamSheild class, called 'radio' HamShield radio; // Run our start up things here @@ -42,8 +44,9 @@ void setup() { // Tell the HamShield to start up radio.initialize(); radio.setRfPower(0); + // Configure the HamShield to transmit and recieve on 446.000MHz - radio.frequency(145570); + radio.frequency(438000); Serial.println("Radio Configured."); } @@ -60,13 +63,13 @@ void loop() { radio.setModeTransmit(); // Send a message out in morse code - radio.morseOut("KC7IBT ARDUINO HAMSHIELD"); + radio.morseOut(" KC7IBT ARDUINO HAMSHIELD"); // We're done sending the message, set the radio back into recieve mode. radio.setModeReceive(); Serial.println("Done."); - // Wait 30 seconds before we send our beacon again. + // Wait a second before we send our beacon again. delay(1000); } else { // If we get here, the channel is busy. Let's also print out the RSSI. From 12c9cdf3d9ad0c5bad741d249514eee98d14d694 Mon Sep 17 00:00:00 2001 From: Nigel Vander Houwen Date: Sun, 5 Jun 2016 13:01:39 -0700 Subject: [PATCH 5/5] Fixed FoxHunt example. Verified working with current library and hardware v09 --- examples/FoxHunt/FoxHunt.ino | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/FoxHunt/FoxHunt.ino b/examples/FoxHunt/FoxHunt.ino index cd34744..83d3d01 100755 --- a/examples/FoxHunt/FoxHunt.ino +++ b/examples/FoxHunt/FoxHunt.ino @@ -6,9 +6,9 @@ #define RESET_PIN A3 #define SWITCH_PIN 2 -// transmit for 1 minute, every 10 minutes - -#define TRANSMITLENGTH 1 +// In milliseconds +#define TRANSMITLENGTH 60000 +// In minutes #define INTERVAL 10 #define RANDOMCHANCE 3 @@ -27,23 +27,23 @@ void setup() { digitalWrite(RESET_PIN, HIGH); radio.initialize(); - radio.frequency(145510); + radio.setRfPower(0); + radio.frequency(438000); radio.setModeReceive(); } void loop() { - waitMinute(INTERVAL + random(0,RANDOMCHANCE)); // wait before transmitting, randomly up to 3 minutes later - if(radio.waitForChannel(30000,2000, -90)) { // wait for a clear channel, abort after 30 seconds, wait 2 seconds of dead air for breakers - radio.setModeTransmit(); // turn on transmit mode - tone(1000,11,TRANSMITLENGTH * 60 * 1000); // play a long solid tone - radio.morseOut("1ZZ9ZZ/B FOXHUNT"); // identify the fox hunt transmitter - radio.setModeReceive(); // turn off the transmit mode - } + if(radio.waitForChannel(30000,2000, -90)) { // wait for a clear channel, abort after 30 seconds, wait 2 seconds of dead air for breakers + radio.setModeTransmit(); // turn on transmit mode + tone(PWM_PIN, 1000, TRANSMITLENGTH); // play a long solid tone + delay(TRANSMITLENGTH); + radio.morseOut(" 1ZZ9ZZ/B FOXHUNT"); // identify the fox hunt transmitter + radio.setModeReceive(); // turn off the transmit mode + } + waitMinute(INTERVAL + random(0,RANDOMCHANCE)); // wait before transmitting, randomly } // a function so we can wait by minutes - -void waitMinute(int period) { +void waitMinute(unsigned long period) { delay(period * 60 * 1000); } -