8 Commits

Author SHA1 Message Date
Morgan Redfield
307d33add0 update version to 1.0.3 2017-01-15 12:12:20 -08:00
nick6x
219d89ff60 Merge branch 'master' of https://github.com/EnhancedRadioDevices/HamShield 2017-01-15 12:06:12 -08:00
nick6x
6954402ac6 Clarify example descriptions 2017-01-15 12:05:43 -08:00
morgan
ec0400c1c6 adding narrow/wide band control 2017-01-15 11:31:22 -08:00
morgan
1d02387649 add yaac instructions to example 2016-12-27 12:46:27 -08:00
morgan
4593f1d44c fix KISS example 2016-12-27 12:08:28 -08:00
morgan
292a774a79 make morse dot duration user settable 2016-12-19 11:53:36 -08:00
morgan
5874e6b8e5 make morse tone freq user settable 2016-12-19 11:40:44 -08:00
7 changed files with 258 additions and 94 deletions

View File

@@ -5,9 +5,11 @@
* Connect the HamShield to your Arduino. Screw the antenna * Connect the HamShield to your Arduino. Screw the antenna
* into the HamShield RF jack. Connect the Arduino to wall * into the HamShield RF jack. Connect the Arduino to wall
* power and then to your computer via USB. After uploading * power and then to your computer via USB. After uploading
* this program to your Arduino, open the Serial Monitor. * this program to your Arduino, open the Serial Monitor.
* Type 'h' into the bar at the top of the Serial Monitor * Make sure drop-down menu at the bottom of Serial Monitor
* and click the "Send" button for more instructions. * is set to "Newline". Type 'h' into the bar at the top of
* the Serial Monitor and click the "Send" button for more
* instructions.
*/ */
#define DDS_REFCLK_DEFAULT 38400 #define DDS_REFCLK_DEFAULT 38400

View File

@@ -52,6 +52,9 @@ void setup() {
// Tell the HamShield to start up // Tell the HamShield to start up
radio.initialize(); radio.initialize();
radio.setRfPower(0); radio.setRfPower(0);
radio.setMorseFreq(400);
radio.setMorseDotMillis(200);
// Configure the HamShield to transmit and recieve on 446.000MHz // Configure the HamShield to transmit and recieve on 446.000MHz
radio.frequency(438000); radio.frequency(438000);

View File

@@ -7,16 +7,28 @@
* into the HamShield RF jack. Connect the Arduino to wall * into the HamShield RF jack. Connect the Arduino to wall
* power and then to your computer via USB. Issue commands * power and then to your computer via USB. Issue commands
* via the KISS equipment. * via the KISS equipment.
*
* To use the KISS example with YAAC:
* 1. open the configure YAAC wizard
* 2. follow the prompts and enter in your details until you get to the "Add and Configure Interfaces" window
* 3. Choose "Add Serial KISS TNC Port"
* 4. Choose the COM port for your Arduino
* 5. set baud rate to 9600 (default)
* 6. set it to KISS-only: with no command to enter KISS mode (just leave the box empty)
* 7. Use APRS protocol (default)
* 8. hit the next button and follow directions to finish configuration
*/ */
#include <HamShield.h> #include <HamShield.h>
#include <KISS.h> #include <KISS.h>
#include <DDS.h>
#include <packet.h> #include <packet.h>
#include <avr/wdt.h>
HamShield radio; HamShield radio;
DDS dds; DDS dds;
KISS kiss(&Serial, &radio, &dds);
AFSK afsk; AFSK afsk;
KISS kiss(&Serial, &radio, &dds, &afsk);
#define PWM_PIN 3 #define PWM_PIN 3
#define RESET_PIN A3 #define RESET_PIN A3
@@ -32,27 +44,44 @@ void setup() {
// set up the reset control pin // set up the reset control pin
pinMode(RESET_PIN, OUTPUT); pinMode(RESET_PIN, OUTPUT);
digitalWrite(RESET_PIN, LOW); digitalWrite(RESET_PIN, HIGH);
Serial.begin(9600); Serial.begin(9600);
while (digitalRead(SWITCH_PIN));
// let the AU ot of reset
digitalWrite(RESET_PIN, HIGH);
radio.initialize(); radio.initialize();
radio.setSQOff(); //radio.setSQOff();
radio.setVolume1(0xFF);
radio.setVolume2(0xFF);
radio.setSQHiThresh(-100);
radio.setSQLoThresh(-100);
radio.setSQOn();
radio.frequency(144390); radio.frequency(144390);
dds.start(); dds.start();
afsk.start(&dds); afsk.start(&dds);
delay(100);
radio.setModeReceive();
} }
void loop() { void loop() {
kiss.loop(); kiss.loop();
} }
ISR(ADC_vect) { ISR(TIMER2_OVF_vect) {
kiss.isr(); TIFR2 = _BV(TOV2);
static uint8_t tcnt = 0;
if(++tcnt == 8) {
dds.clockTick();
tcnt = 0;
}
} }
ISR(ADC_vect) {
static uint8_t tcnt = 0;
TIFR1 = _BV(ICF1); // Clear the timer flag
dds.clockTick();
if(++tcnt == 1) {
afsk.timer();
tcnt = 0;
}
}

View File

@@ -28,8 +28,8 @@ Power level P<level>; Set the power amp level, 0 = lowest, 15 = highest
Enable Offset R<state>; 1 turns on repeater offset mode, 0 turns off repeater offset mode No Enable Offset R<state>; 1 turns on repeater offset mode, 0 turns off repeater offset mode No
Squelch S<level>; Set the squelch level No Squelch S<level>; Set the squelch level No
TX Offset T<freq>; The absolute frequency of the repeater offset to transmit on in KHz No TX Offset T<freq>; The absolute frequency of the repeater offset to transmit on in KHz No
RSSI ? Respond with the current receive level in - dBm (no sign provided on numerical response) No RSSI ?; Respond with the current receive level in - dBm (no sign provided on numerical response) No
Voice Level ^ Respond with the current voice level (VSSI) Voice Level ^; Respond with the current voice level (VSSI)
Responses: Responses:

View File

@@ -1,5 +1,5 @@
name=HamShield name=HamShield
version=1.0.2 version=1.0.3
author=Morgan Redfield <morgan@enhancedradio.com>, Casey Halverson <casey@enhancedradio.com> author=Morgan Redfield <morgan@enhancedradio.com>, Casey Halverson <casey@enhancedradio.com>
maintainer=Morgan Redfield <morgan@enhancedradio.com> maintainer=Morgan Redfield <morgan@enhancedradio.com>
sentence=A library for use with HamShield by Enhanced Radio Devices. sentence=A library for use with HamShield by Enhanced Radio Devices.
@@ -7,4 +7,4 @@ paragraph=
category=Device Control category=Device Control
url=http://www.hamshield.com url=http://www.hamshield.com
architectures=* architectures=*
includes=HamShield.h includes=HamShield.h

View File

@@ -24,6 +24,10 @@ const uint32_t MURS[] PROGMEM = {0,151820,151880,151940,154570,154600};
const uint32_t WX[] PROGMEM = {0,162550,162400,162475,162425,162450,162500,162525}; const uint32_t WX[] PROGMEM = {0,162550,162400,162475,162425,162450,162500,162525};
unsigned int morse_freq = 600;
unsigned int morse_dot_millis = 100;
/* morse code lookup table */ /* morse code lookup table */
// This is the Morse table in reverse binary format. // This is the Morse table in reverse binary format.
// It will occupy 108 bytes of memory (or program memory if defined) // It will occupy 108 bytes of memory (or program memory if defined)
@@ -147,10 +151,19 @@ HamShield::HamShield(uint8_t cs_pin) {
digitalWrite(DAT, HIGH); digitalWrite(DAT, HIGH);
} }
/** Power on and prepare for general usage. /** Power on and prepare for general usage.
* *
*/ */
void HamShield::initialize() { void HamShield::initialize() {
initialize(true);
}
/** Power on and prepare for general usage.
*
*/
void HamShield::initialize(bool narrowBand) {
// Note: these initial settings are for UHF 12.5kHz channel // Note: these initial settings are for UHF 12.5kHz channel
// see the A1846S register table and initial settings for more info // see the A1846S register table and initial settings for more info
@@ -179,7 +192,99 @@ void HamShield::initialize() {
tx_data = 0x0AF2; // tx_data = 0x0AF2; //
HSwriteWord(devAddr, 0x33, tx_data); // agc number HSwriteWord(devAddr, 0x33, tx_data); // agc number
// AGC table tx_data = 0x067F; //0x0601; //0x470F;
HSwriteWord(devAddr, 0x41, tx_data); // voice gain tx [6:0]
tx_data = 0x02FF; // using 0x04FF to avoid tx voice delay
HSwriteWord(devAddr, 0x44, tx_data); // tx gain [11:8]
tx_data = 0x7F2F;
HSwriteWord(devAddr, 0x47, tx_data);
tx_data = 0x2C62;
HSwriteWord(devAddr, 0x4F, tx_data);
tx_data = 0x0094;
HSwriteWord(devAddr, 0x53, tx_data); // compressor update time (bits 6:0, 5.12ms per unit)
tx_data = 0x2A18;
HSwriteWord(devAddr, 0x54, tx_data);
tx_data = 0x0081;
HSwriteWord(devAddr, 0x55, tx_data);
tx_data = 0x0B22;
HSwriteWord(devAddr, 0x56, tx_data); // sq detect time
tx_data = 0x1C00;
HSwriteWord(devAddr, 0x57, tx_data);
tx_data = 0x800D;
HSwriteWord(devAddr, 0x58, tx_data);
tx_data = 0x0EDD;
HSwriteWord(devAddr, 0x5A, tx_data); // sq and noise detect times
tx_data = 0x3FFF;
HSwriteWord(devAddr, 0x63, tx_data); // pre-emphasis bypass
// calibration
tx_data = 0x00A4;
HSwriteWord(devAddr, 0x30, tx_data);
delay(100);
tx_data = 0x00A6;
HSwriteWord(devAddr, 0x30, tx_data);
delay(100);
tx_data = 0x0006;
HSwriteWord(devAddr, 0x30, tx_data);
delay(100);
// set band width
if (narrowBand) {
setupNarrowBand();
} else {
setupWideBand();
}
delay(100);
/*
// setup default values
frequency(446000);
//setVolume1(0xF);
//setVolume2(0xF);
setModeReceive();
setTxSourceMic();
setRfPower(0);
setSQLoThresh(80);
setSQOn();
*/
}
/** Set up the AU1846 in Narrow Band mode (12.5kHz).
*/
void HamShield::setupNarrowBand() {
uint16_t tx_data;
// setup for 12.5kHz channel width
tx_data = 0x3D37;
HSwriteWord(devAddr, 0x11, tx_data);
tx_data = 0x0100;
HSwriteWord(devAddr, 0x12, tx_data);
tx_data = 0x1100;
HSwriteWord(devAddr, 0x15, tx_data);
tx_data = 0x4495;
HSwriteWord(devAddr, 0x32, tx_data); // agc target power [11:6]
tx_data = 0x2B8E;
HSwriteWord(devAddr, 0x34, tx_data);
tx_data = 0x40C3;
HSwriteWord(devAddr, 0x3A, tx_data); // modu_det_sel sq setting
tx_data = 0x0407;
HSwriteWord(devAddr, 0x3C, tx_data); // pk_det_th sq setting [8:7]
tx_data = 0x28D0;
HSwriteWord(devAddr, 0x3F, tx_data); // rssi3_th sq setting
tx_data = 0x203E;
HSwriteWord(devAddr, 0x48, tx_data);
tx_data = 0x1BB7;
HSwriteWord(devAddr, 0x60, tx_data);
tx_data = 0x0A10; // use 0x1425 if there's an LNA
HSwriteWord(devAddr, 0x62, tx_data);
tx_data = 0x2494;
HSwriteWord(devAddr, 0x65, tx_data);
tx_data = 0xEB2E;
HSwriteWord(devAddr, 0x66, tx_data);
// AGC table
tx_data = 0x0001; tx_data = 0x0001;
HSwriteWord(devAddr, 0x7F, tx_data); HSwriteWord(devAddr, 0x7F, tx_data);
tx_data = 0x000C; tx_data = 0x000C;
@@ -220,84 +325,80 @@ void HamShield::initialize() {
HSwriteWord(devAddr, 0x7F, tx_data); HSwriteWord(devAddr, 0x7F, tx_data);
// end AGC table // end AGC table
tx_data = 0x067F; //0x0601; //0x470F; }
HSwriteWord(devAddr, 0x41, tx_data); // voice gain tx [6:0]
tx_data = 0x02FF; // using 0x04FF to avoid tx voice delay
HSwriteWord(devAddr, 0x44, tx_data); // tx gain [11:8]
tx_data = 0x7F2F;
HSwriteWord(devAddr, 0x47, tx_data);
tx_data = 0x2C62;
HSwriteWord(devAddr, 0x4F, tx_data);
tx_data = 0x0094;
HSwriteWord(devAddr, 0x53, tx_data); // compressor update time (bits 6:0, 5.12ms per unit)
tx_data = 0x2A18;
HSwriteWord(devAddr, 0x54, tx_data);
tx_data = 0x0081;
HSwriteWord(devAddr, 0x55, tx_data);
tx_data = 0x0B22;
HSwriteWord(devAddr, 0x56, tx_data); // sq detect time
tx_data = 0x1C00;
HSwriteWord(devAddr, 0x57, tx_data);
tx_data = 0x800D;
HSwriteWord(devAddr, 0x58, tx_data);
tx_data = 0x0EDD;
HSwriteWord(devAddr, 0x5A, tx_data); // sq and noise detect times
tx_data = 0x3FFF;
HSwriteWord(devAddr, 0x63, tx_data); // pre-emphasis bypass
// calibration
tx_data = 0x00A4;
HSwriteWord(devAddr, 0x30, tx_data);
delay(100);
tx_data = 0x00A6;
HSwriteWord(devAddr, 0x30, tx_data);
delay(100);
tx_data = 0x0006;
HSwriteWord(devAddr, 0x30, tx_data);
delay(100);
/** Set up the AU1846 in Wide Band mode (25kHz).
// setup for 12.5kHz channel width */
void HamShield::setupWideBand() {
uint16_t tx_data;
// setup for 25kHz channel width
tx_data = 0x3D37; tx_data = 0x3D37;
HSwriteWord(devAddr, 0x11, tx_data); HSwriteWord(devAddr, 0x11, tx_data);
tx_data = 0x0100; tx_data = 0x0100;
HSwriteWord(devAddr, 0x12, tx_data); HSwriteWord(devAddr, 0x12, tx_data);
tx_data = 0x1100; tx_data = 0x1F00;
HSwriteWord(devAddr, 0x15, tx_data); HSwriteWord(devAddr, 0x15, tx_data);
tx_data = 0x4495; tx_data = 0x7564;
HSwriteWord(devAddr, 0x32, tx_data); // agc target power [11:6] HSwriteWord(devAddr, 0x32, tx_data); // agc target power [11:6]
tx_data = 0x2B8E; tx_data = 0x2B8E;
HSwriteWord(devAddr, 0x34, tx_data); HSwriteWord(devAddr, 0x34, tx_data);
tx_data = 0x40C3; tx_data = 0x44C3;
HSwriteWord(devAddr, 0x3A, tx_data); // modu_det_sel sq setting HSwriteWord(devAddr, 0x3A, tx_data); // modu_det_sel sq setting
tx_data = 0x0407; tx_data = 0x1930;
HSwriteWord(devAddr, 0x3C, tx_data); // pk_det_th sq setting [8:7] HSwriteWord(devAddr, 0x3C, tx_data); // pk_det_th sq setting [8:7]
tx_data = 0x28D0; tx_data = 0x29D2;
HSwriteWord(devAddr, 0x3F, tx_data); // rssi3_th sq setting HSwriteWord(devAddr, 0x3F, tx_data); // rssi3_th sq setting
tx_data = 0x203E; tx_data = 0x21C0;
HSwriteWord(devAddr, 0x48, tx_data); HSwriteWord(devAddr, 0x48, tx_data);
tx_data = 0x1BB7; tx_data = 0x101E;
HSwriteWord(devAddr, 0x60, tx_data); HSwriteWord(devAddr, 0x60, tx_data);
tx_data = 0x0A10; // use 0x1425 if there's an LNA tx_data = 0x3767; // use 0x1425 if there's an LNA
HSwriteWord(devAddr, 0x62, tx_data); HSwriteWord(devAddr, 0x62, tx_data);
tx_data = 0x2494; tx_data = 0x248A;
HSwriteWord(devAddr, 0x65, tx_data); HSwriteWord(devAddr, 0x65, tx_data);
tx_data = 0xEB2E; tx_data = 0xFFAE;
HSwriteWord(devAddr, 0x66, tx_data); HSwriteWord(devAddr, 0x66, tx_data);
delay(100); // AGC table
tx_data = 0x0001;
/* HSwriteWord(devAddr, 0x7F, tx_data);
// setup default values tx_data = 0x000C;
frequency(446000); HSwriteWord(devAddr, 0x05, tx_data);
//setVolume1(0xF); tx_data = 0x0024;
//setVolume2(0xF); HSwriteWord(devAddr, 0x06, tx_data);
setModeReceive(); tx_data = 0x0214;
setTxSourceMic(); HSwriteWord(devAddr, 0x07, tx_data);
setRfPower(0); tx_data = 0x0224;
setSQLoThresh(80); HSwriteWord(devAddr, 0x08, tx_data);
setSQOn(); tx_data = 0x0314;
*/ HSwriteWord(devAddr, 0x09, tx_data);
tx_data = 0x0324;
HSwriteWord(devAddr, 0x0A, tx_data);
tx_data = 0x0344;
HSwriteWord(devAddr, 0x0B, tx_data);
tx_data = 0x0384;
HSwriteWord(devAddr, 0x0C, tx_data);
tx_data = 0x1384;
HSwriteWord(devAddr, 0x0D, tx_data);
tx_data = 0x1B84;
HSwriteWord(devAddr, 0x0E, tx_data);
tx_data = 0x3F84;
HSwriteWord(devAddr, 0x0F, tx_data);
tx_data = 0xE0EB;
HSwriteWord(devAddr, 0x12, tx_data);
tx_data = 0xF2FE;
HSwriteWord(devAddr, 0x13, tx_data);
tx_data = 0x0A16;
HSwriteWord(devAddr, 0x14, tx_data);
tx_data = 0x2424;
HSwriteWord(devAddr, 0x15, tx_data);
tx_data = 0x2424;
HSwriteWord(devAddr, 0x16, tx_data);
tx_data = 0x2424;
HSwriteWord(devAddr, 0x17, tx_data);
tx_data = 0x0000;
HSwriteWord(devAddr, 0x7F, tx_data);
// end AGC table
} }
/** Verify the I2C connection. /** Verify the I2C connection.
@@ -1283,6 +1384,29 @@ bool HamShield::waitForChannel(long timeout = 0, long breakwindow = 0, int setRS
return false; return false;
} }
// Get current morse code tone frequency (in Hz)
unsigned int HamShield::getMorseFreq() {
return morse_freq;
}
// Set current morse code tone frequency (in Hz)
void HamShield::setMorseFreq(unsigned int morse_freq_hz) {
morse_freq = morse_freq_hz;
}
// Get current duration of a morse dot (shorter is more WPM)
unsigned int HamShield::getMorseDotMillis() {
return morse_dot_millis;
}
// Set current duration of a morse dot (shorter is more WPM)
void HamShield::setMorseDotMillis(unsigned int morse_dot_dur_millis) {
morse_dot_millis = morse_dot_dur_millis;
}
/* Morse code out, blocking */ /* Morse code out, blocking */
@@ -1295,11 +1419,11 @@ void HamShield::morseOut(char buffer[HAMSHIELD_MORSE_BUFFER_SIZE]) {
// We delay by 4 here, if we previously sent a symbol. Otherwise 7. // We delay by 4 here, if we previously sent a symbol. Otherwise 7.
// This could probably just be always 7 and go relatively unnoticed. // 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); tone(HAMSHIELD_PWM_PIN, 6000, morse_dot_millis * 7);
delay(HAMSHIELD_MORSE_DOT*7); delay(morse_dot_millis*7);
} else { } else {
tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT * 4); tone(HAMSHIELD_PWM_PIN, 6000, morse_dot_millis * 4);
delay(HAMSHIELD_MORSE_DOT*4); delay(morse_dot_millis*4);
} }
continue; continue;
} }
@@ -1308,20 +1432,20 @@ void HamShield::morseOut(char buffer[HAMSHIELD_MORSE_BUFFER_SIZE]) {
if(bits) { // If it is a valid character... if(bits) { // If it is a valid character...
do { do {
if(bits & 1) { if(bits & 1) {
tone(HAMSHIELD_PWM_PIN, 600, HAMSHIELD_MORSE_DOT * 3); tone(HAMSHIELD_PWM_PIN, morse_freq, morse_dot_millis * 3);
delay(HAMSHIELD_MORSE_DOT*3); delay(morse_dot_millis*3);
} else { } else {
tone(HAMSHIELD_PWM_PIN, 600, HAMSHIELD_MORSE_DOT); tone(HAMSHIELD_PWM_PIN, morse_freq, morse_dot_millis);
delay(HAMSHIELD_MORSE_DOT); delay(morse_dot_millis);
} }
tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT); tone(HAMSHIELD_PWM_PIN, 6000, morse_dot_millis);
delay(HAMSHIELD_MORSE_DOT); delay(morse_dot_millis);
bits >>= 1; // Shift into the next symbol bits >>= 1; // Shift into the next symbol
} while(bits != 1); // Wait for 1 termination to be all we have left } while(bits != 1); // Wait for 1 termination to be all we have left
} }
// End of character // End of character
tone(HAMSHIELD_PWM_PIN, 6000, HAMSHIELD_MORSE_DOT * 3); tone(HAMSHIELD_PWM_PIN, 6000, morse_dot_millis * 3);
delay(HAMSHIELD_MORSE_DOT * 3); delay(morse_dot_millis * 3);
} }
return; return;
} }

View File

@@ -16,7 +16,6 @@
// HamShield constants // HamShield constants
#define HAMSHIELD_MORSE_DOT 100 // Morse code dot length (smaller is faster WPM)
#define HAMSHIELD_MORSE_BUFFER_SIZE 80 // Char buffer size for morse code text #define HAMSHIELD_MORSE_BUFFER_SIZE 80 // Char buffer size for morse code text
#define HAMSHIELD_AUX_BUTTON 2 // Pin assignment for AUX button #define HAMSHIELD_AUX_BUTTON 2 // Pin assignment for AUX button
#define HAMSHIELD_PWM_PIN 3 // Pin assignment for PWM output #define HAMSHIELD_PWM_PIN 3 // Pin assignment for PWM output
@@ -256,7 +255,10 @@ class HamShield {
HamShield(); HamShield();
HamShield(uint8_t cs_pin); HamShield(uint8_t cs_pin);
void initialize(); void initialize(); // defaults to 12.5kHz
void initialize(bool narrowBand); // select 12.5kHz if true or 25kHz if false
void setupWideBand();
void setupNarrowBand();
bool testConnection(); bool testConnection();
// read control reg // read control reg
@@ -481,6 +483,10 @@ class HamShield {
void buttonMode(uint8_t mode); void buttonMode(uint8_t mode);
static void isr_ptt(); static void isr_ptt();
static void isr_reset(); static void isr_reset();
unsigned int getMorseFreq();
void setMorseFreq(unsigned int morse_freq_hz);
unsigned int getMorseDotMillis();
void setMorseDotMillis(unsigned int morse_dot_dur_millis);
void morseOut(char buffer[HAMSHIELD_MORSE_BUFFER_SIZE]); void morseOut(char buffer[HAMSHIELD_MORSE_BUFFER_SIZE]);
uint8_t morseLookup(char letter); uint8_t morseLookup(char letter);
bool waitForChannel(long timeout, long breakwindow, int setRSSI); bool waitForChannel(long timeout, long breakwindow, int setRSSI);