updated for HS05

This commit is contained in:
morgan 2015-11-23 08:54:10 -08:00
parent a196501f15
commit 807617de83
24 changed files with 513 additions and 203 deletions

View File

@ -137,10 +137,6 @@ HamShield::HamShield(uint8_t address) {
* *
*/ */
void HamShield::initialize() { void HamShield::initialize() {
// set up PWM output for RF power control - commenting out to get rid of terrible buzzing noise
// pwr_control_pin = 9;
// 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
@ -156,6 +152,11 @@ void HamShield::initialize() {
tx_data = 0x03AC; // default is 0x32C tx_data = 0x03AC; // default is 0x32C
I2Cdev::writeWord(devAddr, 0x09, tx_data); I2Cdev::writeWord(devAddr, 0x09, tx_data);
// AGC problem improve settings?
tx_data = 0x43A0;
I2Cdev::writeWord(devAddr, 0x0A, tx_data);
tx_data = 0xA100;
I2Cdev::writeWord(devAddr, 0x13, tx_data);
tx_data = 0x0031; tx_data = 0x0031;
I2Cdev::writeWord(devAddr, 0x31, tx_data); // included as per AU supplied register table I2Cdev::writeWord(devAddr, 0x31, tx_data); // included as per AU supplied register table
@ -167,15 +168,15 @@ void HamShield::initialize() {
I2Cdev::writeWord(devAddr, 0x34, tx_data); // Rx digital gain - included as per AU supplied register table I2Cdev::writeWord(devAddr, 0x34, tx_data); // Rx digital gain - included as per AU supplied register table
// bits 6:0 are for digital voice gain // bits 6:0 are for digital voice gain
tx_data = 0x470F; tx_data = 0x060f; //0x470F;
I2Cdev::writeWord(devAddr, 0x41, tx_data); I2Cdev::writeWord(devAddr, 0x41, tx_data);
// bits 11:8 are for voice digital gain after tx ADC downsample // bits 11:8 are for voice digital gain after tx ADC downsample
// bits 7:0 are for rx volume control // bits 7:0 are for rx volume control
tx_data = 0x0DFF; tx_data = 0x0AFF;
I2Cdev::writeWord(devAddr, 0x44, tx_data); // addx was A1846S_RX_VOLUME_REG I2Cdev::writeWord(devAddr, 0x44, tx_data); // addx was A1846S_RX_VOLUME_REG
tx_data = 0x7FFF; tx_data = 0x7F2F;
I2Cdev::writeWord(devAddr, 0x47, tx_data);// soft mute I2Cdev::writeWord(devAddr, 0x47, tx_data);// soft mute
tx_data = 0x2C62; tx_data = 0x2C62;
@ -193,13 +194,13 @@ void HamShield::initialize() {
tx_data = 0x1C00; tx_data = 0x1C00;
I2Cdev::writeWord(devAddr, 0x57, tx_data);// bypass rssi lpfilter I2Cdev::writeWord(devAddr, 0x57, tx_data);// bypass rssi lpfilter
tx_data = 0x0EDB; tx_data = 0x0EDD;
I2Cdev::writeWord(devAddr, 0x5A, tx_data);// SQ detection time I2Cdev::writeWord(devAddr, 0x5A, tx_data);// SQ detection time
tx_data = 0x101E; tx_data = 0x101E;
I2Cdev::writeWord(devAddr, 0x60, tx_data);// SQ noise threshold I2Cdev::writeWord(devAddr, 0x60, tx_data);// SQ noise threshold
tx_data = 0x16AD; tx_data = 0x3FFF;
I2Cdev::writeWord(devAddr, 0x63, tx_data);// pre-emphasis bypass threshold I2Cdev::writeWord(devAddr, 0x63, tx_data);// pre-emphasis bypass threshold
// calibration // calibration
@ -214,22 +215,28 @@ void HamShield::initialize() {
delay(10); delay(10);
// continue default setup in 12.5kHz mode // continue default setup in 12.5kHz mode
tx_data = 0x3D37;
I2Cdev::writeWord(devAddr, 0x11, tx_data); // tuning bit
tx_data = 0x0100;
I2Cdev::writeWord(devAddr, 0x12, tx_data); // tuning bit
tx_data = 0x1100; tx_data = 0x1100;
I2Cdev::writeWord(devAddr, 0x15, tx_data); // tuning bit I2Cdev::writeWord(devAddr, 0x15, tx_data); // tuning bit
tx_data = 0x1495; // 4495 tx_data = 0x4495; // 4495
I2Cdev::writeWord(devAddr, 0x32, tx_data); // agc target power I2Cdev::writeWord(devAddr, 0x32, tx_data); // agc target power
tx_data = 0x40C3; tx_data = 0x40C3;
I2Cdev::writeWord(devAddr, 0x3A, tx_data); // modu_det_sel sq setting I2Cdev::writeWord(devAddr, 0x3A, tx_data); // modu_det_sel sq setting
tx_data = 0x0F1E; tx_data = 0x0407;
I2Cdev::writeWord(devAddr, 0x3C, tx_data); // pk_det_thr sq setting I2Cdev::writeWord(devAddr, 0x3C, tx_data); // pk_det_thr sq setting
tx_data = 0x28D0; tx_data = 0x28D0;
I2Cdev::writeWord(devAddr, 0x3F, tx_data); // pk_det_thr sq setting I2Cdev::writeWord(devAddr, 0x3F, tx_data); // pk_det_thr sq setting
tx_data = 0x20BE; tx_data = 0x203E;
I2Cdev::writeWord(devAddr, 0x48, tx_data); // pk_det_thr sq setting I2Cdev::writeWord(devAddr, 0x48, tx_data); // pk_det_thr sq setting
tx_data = 0x0A50; tx_data = 0x0A50;
@ -241,7 +248,7 @@ void HamShield::initialize() {
tx_data = 0x2494; tx_data = 0x2494;
I2Cdev::writeWord(devAddr, 0x65, tx_data); // setting th_sif for SQ rssi detect I2Cdev::writeWord(devAddr, 0x65, tx_data); // setting th_sif for SQ rssi detect
tx_data = 0x2494; tx_data = 0xEB2E;//0x2494;
I2Cdev::writeWord(devAddr, 0x66, tx_data); // setting th_sif for SQ rssi detect I2Cdev::writeWord(devAddr, 0x66, tx_data); // setting th_sif for SQ rssi detect
// AGC gain table settings // AGC gain table settings
@ -250,28 +257,40 @@ void HamShield::initialize() {
tx_data = 0x0001; tx_data = 0x0001;
I2Cdev::writeWord(devAddr, 0x7F, tx_data); I2Cdev::writeWord(devAddr, 0x7F, tx_data);
tx_data = 0x0014; tx_data = 0x000C;
I2Cdev::writeWord(devAddr, 0x06, tx_data); I2Cdev::writeWord(devAddr, 0x05, tx_data);
tx_data = 0x020C; tx_data = 0x020C;
I2Cdev::writeWord(devAddr, 0x07, tx_data); I2Cdev::writeWord(devAddr, 0x06, tx_data);
tx_data = 0x0214;
I2Cdev::writeWord(devAddr, 0x08, tx_data);
tx_data = 0x030C; tx_data = 0x030C;
I2Cdev::writeWord(devAddr, 0x09, tx_data); I2Cdev::writeWord(devAddr, 0x07, tx_data);
tx_data = 0x0314;
I2Cdev::writeWord(devAddr, 0x0A, tx_data);
tx_data = 0x0324; tx_data = 0x0324;
I2Cdev::writeWord(devAddr, 0x0B, tx_data); I2Cdev::writeWord(devAddr, 0x08, tx_data);
tx_data = 0x0344;
I2Cdev::writeWord(devAddr, 0x0C, tx_data);
tx_data = 0x1344; tx_data = 0x1344;
I2Cdev::writeWord(devAddr, 0x09, tx_data);
tx_data = 0x3F44;//
I2Cdev::writeWord(devAddr, 0x0A, tx_data);
tx_data = 0x3F44;
I2Cdev::writeWord(devAddr, 0x0B, tx_data);
tx_data = 0x3F44;
I2Cdev::writeWord(devAddr, 0x0C, tx_data);
tx_data = 0x3F44;
I2Cdev::writeWord(devAddr, 0x0D, tx_data); I2Cdev::writeWord(devAddr, 0x0D, tx_data);
tx_data = 0x1B44; tx_data = 0x3F44;
I2Cdev::writeWord(devAddr, 0x0E, tx_data); I2Cdev::writeWord(devAddr, 0x0E, tx_data);
tx_data = 0x3F44; tx_data = 0x3F44;
I2Cdev::writeWord(devAddr, 0x0F, tx_data); I2Cdev::writeWord(devAddr, 0x0F, tx_data);
tx_data = 0xE0EB; tx_data = 0xE0ED;
I2Cdev::writeWord(devAddr, 0x12, tx_data); I2Cdev::writeWord(devAddr, 0x12, tx_data);
tx_data = 0xF2FE;
I2Cdev::writeWord(devAddr, 0x13, tx_data);
tx_data = 0x0A16;
I2Cdev::writeWord(devAddr, 0x14, tx_data);
tx_data = 0x2424;
I2Cdev::writeWord(devAddr, 0x15, tx_data);
tx_data = 0x2424;
I2Cdev::writeWord(devAddr, 0x16, tx_data);
tx_data = 0x2424;
I2Cdev::writeWord(devAddr, 0x17, tx_data);
// done writing to upper page addresses, so set 0x7F back // done writing to upper page addresses, so set 0x7F back
tx_data = 0x0000; tx_data = 0x0000;
@ -339,32 +358,21 @@ void HamShield::setFrequency(uint32_t freq_khz) {
radio_frequency = freq_khz; radio_frequency = freq_khz;
uint32_t freq_raw = freq_khz << 4; // shift by 4 to multiply by 16 (was shift by 3 in old 1846 chip) uint32_t freq_raw = freq_khz << 4; // shift by 4 to multiply by 16 (was shift by 3 in old 1846 chip)
// turn off tx/rx
I2Cdev::writeBitsW(devAddr, A1846S_CTL_REG, 6, 2, 0);
// if we're using a 12MHz crystal and the frequency is // if we're using a 12MHz crystal and the frequency is
// 136.5M,409.5M and 455M, then we have to do special stuff // 136.5M,409.5M and 455M, then we have to do special stuff
if (radio_frequency == 136500 || if (radio_frequency == 136500 ||
radio_frequency == 490500 || radio_frequency == 490500 ||
radio_frequency == 455000) { radio_frequency == 455000) {
// close TX or RX
I2Cdev::readWord(devAddr, 0x00, radio_i2c_buf);
I2Cdev::writeWord(devAddr, 0x30, 0x06);
// set up AU1846 for funky freq // set up AU1846 for funky freq
I2Cdev::writeWord(devAddr, 0x05, 0x86D3); I2Cdev::writeWord(devAddr, 0x05, 0x86D3);
// open TX or RX
I2Cdev::writeWord(devAddr, 0x30, radio_i2c_buf[0]);
} else { } else {
// just undo it regardless of what the last frequency was
// close TX or RX
I2Cdev::readWord(devAddr, 0x00, radio_i2c_buf);
I2Cdev::writeWord(devAddr, 0x30, 0x06);
// set up AU1846 for normal freq // set up AU1846 for normal freq
I2Cdev::writeWord(devAddr, 0x05, 0x8763); I2Cdev::writeWord(devAddr, 0x05, 0x8763);
// open TX or RX
I2Cdev::writeWord(devAddr, 0x30, radio_i2c_buf[0]);
} }
// send top 16 bits to A1846S_FREQ_HI_REG // send top 16 bits to A1846S_FREQ_HI_REG
@ -373,54 +381,35 @@ void HamShield::setFrequency(uint32_t freq_khz) {
// send bottom 16 bits to A1846S_FREQ_LO_REG // send bottom 16 bits to A1846S_FREQ_LO_REG
freq_half = (uint16_t) (freq_raw & 0xFFFF); freq_half = (uint16_t) (freq_raw & 0xFFFF);
I2Cdev::writeWord(devAddr, A1846S_FREQ_LO_REG, freq_half); I2Cdev::writeWord(devAddr, A1846S_FREQ_LO_REG, freq_half);
if (rx_active) {
setRX(true);
} else if (tx_active) {
setTX(true);
}
} }
uint32_t HamShield::getFrequency() { uint32_t HamShield::getFrequency() {
return radio_frequency; return radio_frequency;
} }
void HamShield::setUHF() { void HamShield::setTxBand2m() {
setGpioHi(2); // turn off VHF setGpioLow(4); // V1
setGpioLow(3); // turn on UHF setGpioHi(5); // V2
} }
void HamShield::setVHF() { void HamShield::setTxBand1_2m() {
setGpioHi(3); // turn off UHF setGpioHi(4); // V1
setGpioLow(2); // turn on VHF setGpioLow(5); // V2
} }
void HamShield::setNoFilters() { void HamShield::setTxBand70cm() {
setGpioHi(3); // turn off UHF setGpioHi(4); // V1
setGpioHi(2); // turn off VHF setGpioHi(5); // V2
} }
/*
// band
// 00 - 400-520MHz
// 10 - 200-260MHz
// 11 - 134-174MHz
// TODO: add write to 0x32 based on band selection
void HamShield::setBand(uint16_t band){
if (band == 0) {
setUHF();
} else if (band == 2) {
// not quite in the band for our filters, but use VHF
setVHF();
} else if (band == 3) {
setVHF();
} else {
// illegal write code, turn UHF and VHF channels both off
setNoFilters();
// turn off transmit as well to make sure we don't break anything
setTX(0);
}
I2Cdev::writeBitsW(devAddr, A1846S_BAND_SEL_REG, A1846S_BAND_SEL_BIT, A1846S_BAND_SEL_LENGTH, band);
}
uint16_t HamShield::getBand(){
I2Cdev::readBitsW(devAddr, A1846S_BAND_SEL_REG, A1846S_BAND_SEL_BIT, A1846S_BAND_SEL_LENGTH, radio_i2c_buf);
return radio_i2c_buf[0];
}
*/
/* /*
// xtal frequency (kHz) // xtal frequency (kHz)
@ -493,15 +482,30 @@ uint16_t HamShield::getChanMode(){
void HamShield::setTX(bool on_noff){ void HamShield::setTX(bool on_noff){
// make sure RX is off // make sure RX is off
if (on_noff) { if (on_noff) {
setRX(false); tx_active = true;
rx_active = false;
setRX(false);
// set RX output off if((radio_frequency >= 134000) && (radio_frequency <= 174000)) {
setGpioHi(4); // remember that RX and TX are active low setTxBand2m();
// set TX output on }
setGpioLow(5); // remember that RX and TX are active low if((radio_frequency >= 200000) && (radio_frequency <= 260000)) {
setTxBand1_2m();
}
if((radio_frequency >= 400000) && (radio_frequency <= 520000)) {
setTxBand70cm();
}
delay(500);
} }
I2Cdev::writeBitW(devAddr, A1846S_CTL_REG, A1846S_TX_MODE_BIT, on_noff); I2Cdev::writeBitW(devAddr, A1846S_CTL_REG, A1846S_TX_MODE_BIT, on_noff);
/*
if (on_noff) {
delay(6000);
}
*/
} }
bool HamShield::getTX(){ bool HamShield::getTX(){
I2Cdev::readBitW(devAddr, A1846S_CTL_REG, A1846S_TX_MODE_BIT, radio_i2c_buf); I2Cdev::readBitW(devAddr, A1846S_CTL_REG, A1846S_TX_MODE_BIT, radio_i2c_buf);
@ -509,15 +513,15 @@ bool HamShield::getTX(){
} }
void HamShield::setRX(bool on_noff){ void HamShield::setRX(bool on_noff){
// make sure TX is off // make sure TX is off
if (on_noff) { if (on_noff) {
setTX(false); tx_active = false;
rx_active = true;
setTX(false);
// set TX output off setGpioLow(4); // V1
setGpioHi(5); // remember that RX and TX are active low setGpioLow(5); // V2
// set RX output on }
setGpioLow(4); // remember that RX and TX are active low
}
I2Cdev::writeBitW(devAddr, A1846S_CTL_REG, A1846S_RX_MODE_BIT, on_noff); I2Cdev::writeBitW(devAddr, A1846S_CTL_REG, A1846S_RX_MODE_BIT, on_noff);
} }
@ -529,24 +533,29 @@ bool HamShield::getRX(){
void HamShield::setModeTransmit(){ void HamShield::setModeTransmit(){
// check to see if we should allow them to do this // check to see if we should allow them to do this
if(restrictions == true) { if(restrictions == true) {
if((radio_frequency > 139999) & (radio_frequency < 148001)) { setRX(false); setTX(true); } if((radio_frequency > 139999) & (radio_frequency < 148001)) { setRX(false); }
if((radio_frequency > 218999) & (radio_frequency < 225001)) { setRX(false); setTX(true); } if((radio_frequency > 218999) & (radio_frequency < 225001)) { setRX(false); }
if((radio_frequency > 419999) & (radio_frequency < 450001)) { setRX(false); setTX(true); } if((radio_frequency > 419999) & (radio_frequency < 450001)) { setRX(false); }
} else { } else {
// turn off rx, turn on tx
setRX(false); // break before make
setTX(true); setTX(true);
} }
} }
void HamShield::setModeReceive(){ void HamShield::setModeReceive(){
// turn on rx, turn off tx // turn on rx, turn off tx
setTX(false); // break before make
setRX(true); setRX(true);
} }
void HamShield::setModeOff(){ void HamShield::setModeOff(){
// turn off rx, turn off tx, set pwr_dwn bit // turn off tx/rx
setTX(false); I2Cdev::writeBitsW(devAddr, A1846S_CTL_REG, 6, 2, 0);
setRX(false);
// turn off amplifiers
setGpioLow(4); // V1
setGpioLow(5); // V2
tx_active = false;
rx_active = true;
//TODO: set pwr_dwn bit
} }
// set tx source // set tx source
@ -983,6 +992,11 @@ uint16_t HamShield::getGpioMode(uint16_t gpio){
return radio_i2c_buf[0]; return radio_i2c_buf[0];
} }
uint16_t HamShield::getGpios(){
I2Cdev::readWord(devAddr, A1846S_GPIO_MODE_REG, radio_i2c_buf);
return radio_i2c_buf[0];
}
// Int // Int
void HamShield::enableInterrupt(uint16_t interrupt){ void HamShield::enableInterrupt(uint16_t interrupt){
I2Cdev::writeBitW(devAddr, A1846S_INT_MODE_REG, interrupt, 1); I2Cdev::writeBitW(devAddr, A1846S_INT_MODE_REG, interrupt, 1);
@ -1053,34 +1067,41 @@ uint16_t HamShield::readDTMFCode(){
void HamShield::setRfPower(uint8_t pwr) { void HamShield::setRfPower(uint8_t pwr) {
int max_pwr = 15; int max_pwr = 15;
if (pwr > max_pwr) { if (pwr > max_pwr) {
pwr = max_pwr; pwr = max_pwr;
} }
I2Cdev::writeBitsW(devAddr, A1846S_PABIAS_REG, A1846S_PADRV_BIT, A1846S_PADRV_LENGTH, pwr); // turn off tx/rx
I2Cdev::writeBitsW(devAddr, A1846S_CTL_REG, 6, 2, 0);
I2Cdev::writeBitsW(devAddr, A1846S_PABIAS_REG, A1846S_PADRV_BIT, A1846S_PADRV_LENGTH, pwr);
if (rx_active) {
setRX(true);
} else if (tx_active) {
setTX(true);
}
} }
bool HamShield::frequency(uint32_t freq_khz) { bool HamShield::frequency(uint32_t freq_khz) {
if((freq_khz >= 134000) && (freq_khz <= 174000)) { if((freq_khz >= 134000) && (freq_khz <= 174000)) {
setVHF(); setTxBand2m();
//setBand(3); // 0b11 is 134-174MHz
setFrequency(freq_khz); setFrequency(freq_khz);
return true; return true;
} }
if((freq_khz >= 200000) && (freq_khz <= 260000)) { if((freq_khz >= 200000) && (freq_khz <= 260000)) {
setVHF(); setTxBand1_2m();
//setBand(2); // 10 is 200-260MHz
setFrequency(freq_khz); setFrequency(freq_khz);
return true; return true;
} }
if((freq_khz >= 400000) && (freq_khz <= 520000)) { if((freq_khz >= 400000) && (freq_khz <= 520000)) {
setUHF(); setTxBand70cm();
//setBand(00); // 00 is 400-520MHz
setFrequency(freq_khz); setFrequency(freq_khz);
return true; return true;
} }

View File

@ -18,8 +18,8 @@
#define HAMSHIELD_MORSE_DOT 100 // Morse code dot length (smaller is faster WPM) #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 5 // Pin assignment for AUX button #define HAMSHIELD_AUX_BUTTON 2 // Pin assignment for AUX button
#define HAMSHIELD_PWM_PIN 11 // Pin assignment for PWM output #define HAMSHIELD_PWM_PIN 3 // Pin assignment for PWM output
#define HAMSHIELD_EMPTY_CHANNEL_RSSI -110 // Default threshold where channel is considered "clear" #define HAMSHIELD_EMPTY_CHANNEL_RSSI -110 // Default threshold where channel is considered "clear"
#define HAMSHIELD_AFSK_RX_FIFO_LEN 16 #define HAMSHIELD_AFSK_RX_FIFO_LEN 16
@ -272,16 +272,10 @@ class HamShield {
uint32_t getFrequency(); uint32_t getFrequency();
// band // band
// 00 - 400-520MHz void setTxBand2m();
// 10 - 200-260MHz void setTxBand1_2m();
// 11 - 134-174MHz void setTxBand70cm();
void setBand(uint16_t band); bool frequency(uint32_t freq_khz);
uint16_t getBand();
void setUHF();
void setVHF();
void setNoFilters();
bool frequency(uint32_t freq_khz);
// xtal frequency (kHz) // xtal frequency (kHz)
// 12-14MHz crystal: this reg is set to crystal freq_khz // 12-14MHz crystal: this reg is set to crystal freq_khz
@ -483,6 +477,7 @@ class HamShield {
void setGpioLow(uint16_t gpio); void setGpioLow(uint16_t gpio);
void setGpioHi(uint16_t gpio); void setGpioHi(uint16_t gpio);
uint16_t getGpioMode(uint16_t gpio); uint16_t getGpioMode(uint16_t gpio);
uint16_t getGpios();
// Int // Int
void enableInterrupt(uint16_t interrupt); void enableInterrupt(uint16_t interrupt);
@ -551,7 +546,8 @@ class HamShield {
private: private:
uint8_t devAddr; uint8_t devAddr;
uint16_t radio_i2c_buf[4]; uint16_t radio_i2c_buf[4];
int pwr_control_pin; bool tx_active;
bool rx_active;
uint32_t radio_frequency; uint32_t radio_frequency;
uint32_t FRS[]; uint32_t FRS[];
uint32_t GMRS[]; uint32_t GMRS[];

4
KISS.h
View File

@ -20,11 +20,11 @@ public:
TIFR1 = _BV(ICF1); // Clear the timer flag TIFR1 = _BV(ICF1); // Clear the timer flag
dds->clockTick(); dds->clockTick();
if(++tcnt == (DDS_REFCLK_DEFAULT/9600)) { if(++tcnt == (DDS_REFCLK_DEFAULT/9600)) {
PORTD |= _BV(2); // Diagnostic pin (D2) //PORTD |= _BV(2); // Diagnostic pin (D2)
radio->afsk.timer(); radio->afsk.timer();
tcnt = 0; tcnt = 0;
} }
PORTD &= ~(_BV(2)); //PORTD &= ~(_BV(2));
} }
private: private:
Stream *io; Stream *io;

View File

@ -11,6 +11,12 @@
#include <Wire.h> #include <Wire.h>
#include <avr/wdt.h> #include <avr/wdt.h>
//TODO: move these into library
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
HamShield radio; HamShield radio;
DDS dds; DDS dds;
String messagebuff = ""; String messagebuff = "";
@ -20,16 +26,27 @@ String textmessage = "";
int msgptr = 0; int msgptr = 0;
void setup() { void setup() {
// 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.begin(115200); Serial.begin(115200);
Wire.begin(); Wire.begin();
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
radio.initialize(); radio.initialize();
radio.frequency(144390); radio.frequency(144390);
radio.setRfPower(15); radio.setRfPower(8);
dds.start(); dds.start();
radio.afsk.start(&dds); radio.afsk.start(&dds);
pinMode(11, INPUT); // Bodge for now, as pin 3 is hotwired to pin 11
delay(100); delay(100);
Serial.println("HELLO"); Serial.println("HELLO");
} }

View File

@ -11,6 +11,10 @@
#include <Wire.h> #include <Wire.h>
#include <avr/wdt.h> #include <avr/wdt.h>
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
HamShield radio; HamShield radio;
DDS dds; DDS dds;
String messagebuff = ""; String messagebuff = "";
@ -20,16 +24,25 @@ String textmessage = "";
int msgptr = 0; int msgptr = 0;
void setup() { void setup() {
// 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 the radio
digitalWrite(RESET_PIN, HIGH);
Serial.begin(115200); Serial.begin(115200);
Wire.begin(); Wire.begin();
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
radio.initialize(); radio.initialize();
radio.frequency(145570); radio.frequency(145570);
radio.setRfPower(15); radio.setRfPower(15);
dds.start(); dds.start();
radio.afsk.start(&dds); radio.afsk.start(&dds);
pinMode(11, INPUT); // Bodge for now, as pin 3 is hotwired to pin 11
delay(100); delay(100);
Serial.println("HELLO"); Serial.println("HELLO");
} }
@ -75,7 +88,7 @@ void prepMessage() {
if(radio.afsk.txReady()) { if(radio.afsk.txReady()) {
Serial.println(F("txReady")); Serial.println(F("txReady"));
radio.setModeTransmit(); //radio.setModeTransmit();
//delay(100); //delay(100);
if(radio.afsk.txStart()) { if(radio.afsk.txStart()) {
Serial.println(F("txStart")); Serial.println(F("txStart"));
@ -98,13 +111,14 @@ void prepMessage() {
} }
// TODO: d2 is now our switch, so don't write to that
ISR(TIMER2_OVF_vect) { ISR(TIMER2_OVF_vect) {
TIFR2 = _BV(TOV2); TIFR2 = _BV(TOV2);
static uint8_t tcnt = 0; static uint8_t tcnt = 0;
if(++tcnt == 8) { if(++tcnt == 8) {
digitalWrite(2, HIGH); //digitalWrite(2, HIGH);
dds.clockTick(); dds.clockTick();
digitalWrite(2, LOW); //digitalWrite(2, LOW);
tcnt = 0; tcnt = 0;
} }
} }
@ -112,7 +126,7 @@ ISR(TIMER2_OVF_vect) {
ISR(ADC_vect) { ISR(ADC_vect) {
static uint8_t tcnt = 0; static uint8_t tcnt = 0;
TIFR1 = _BV(ICF1); // Clear the timer flag TIFR1 = _BV(ICF1); // Clear the timer flag
PORTD |= _BV(2); // Diagnostic pin (D2) //PORTD |= _BV(2); // Diagnostic pin (D2)
dds.clockTick(); dds.clockTick();
if(++tcnt == 1) { if(++tcnt == 1) {
if(radio.afsk.encoder.isSending()) { if(radio.afsk.encoder.isSending()) {
@ -120,7 +134,7 @@ ISR(ADC_vect) {
} }
tcnt = 0; tcnt = 0;
} }
PORTD &= ~(_BV(2)); // Pin D2 off again //PORTD &= ~(_BV(2)); // Pin D2 off again
} }

View File

@ -4,19 +4,33 @@
HamShield radio; HamShield radio;
DDS dds; DDS dds;
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
#define DON(p) PORTD |= _BV((p)) #define DON(p) PORTD |= _BV((p))
#define DOFF(p) PORTD &= ~(_BV((p))) #define DOFF(p) PORTD &= ~(_BV((p)))
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
Wire.begin(); Wire.begin();
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT); pinMode(4, OUTPUT);
pinMode(5, OUTPUT); pinMode(5, OUTPUT);
pinMode(6, OUTPUT); pinMode(6, OUTPUT);
pinMode(7, 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(F("Radio test connection"));
Serial.println(radio.testConnection(), DEC); Serial.println(radio.testConnection(), DEC);
Serial.println(F("Initialize")); Serial.println(F("Initialize"));
@ -24,14 +38,12 @@ void setup() {
radio.initialize(); radio.initialize();
Serial.println(F("Frequency")); Serial.println(F("Frequency"));
delay(100); delay(100);
radio.setVHF();
radio.frequency(145010); radio.frequency(145010);
//radio.setRfPower(0); //radio.setRfPower(0);
delay(100); delay(100);
dds.start(); dds.start();
delay(100); delay(100);
radio.afsk.start(&dds); radio.afsk.start(&dds);
pinMode(11, INPUT); // Bodge for now, as pin 3 is hotwired to pin 11
delay(100); delay(100);
dds.setFrequency(0); dds.setFrequency(0);
dds.on(); dds.on();

View File

@ -1,24 +1,35 @@
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h> #include <Wire.h>
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
HamShield radio; HamShield radio;
DDS dds; DDS dds;
void setup() { void setup() {
// 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 radio
digitalWrite(RESET_PIN, HIGH);
Serial.begin(9600); Serial.begin(9600);
Wire.begin(); Wire.begin();
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
Serial.println(F("Radio test connection")); Serial.println(F("Radio test connection"));
Serial.println(radio.testConnection(), DEC); Serial.println(radio.testConnection(), DEC);
Serial.println(F("Initialize")); Serial.println(F("Initialize"));
delay(100); delay(100);
radio.initialize(); radio.initialize();
radio.frequency(145010); radio.frequency(145010);
radio.setVHF();
radio.setSQOff(); radio.setSQOff();
I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x30, 0x06);
I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x30, 0x26);
I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x44, 0b11111111); I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x44, 0b11111111);
Serial.println(F("Frequency")); Serial.println(F("Frequency"));
delay(100); delay(100);
@ -36,7 +47,6 @@ void setup() {
delay(100); delay(100);
radio.afsk.start(&dds); radio.afsk.start(&dds);
Serial.println(F("Starting...")); Serial.println(F("Starting..."));
pinMode(11, INPUT); // Bodge for now, as pin 3 is hotwired to pin 11
delay(100); delay(100);
dds.setAmplitude(255); dds.setAmplitude(255);
} }
@ -57,11 +67,12 @@ void loop() {
} }
} }
//TODO: d2 is the switch input, so remove this
ISR(ADC_vect) { ISR(ADC_vect) {
static uint8_t tcnt = 0; static uint8_t tcnt = 0;
TIFR1 = _BV(ICF1); // Clear the timer flag TIFR1 = _BV(ICF1); // Clear the timer flag
PORTD |= _BV(2); // Diagnostic pin (D2) //PORTD |= _BV(2); // Diagnostic pin (D2)
//dds.clockTick(); //dds.clockTick();
radio.afsk.timer(); radio.afsk.timer();
PORTD &= ~(_BV(2)); // Pin D2 off again //PORTD &= ~(_BV(2)); // Pin D2 off again
} }

View File

@ -5,21 +5,32 @@
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h> #include <Wire.h>
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
HamShield radio; HamShield radio;
DDS dds; DDS dds;
void setup() { void setup() {
// 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 radio
digitalWrite(RESET_PIN, HIGH);
Serial.begin(9600); Serial.begin(9600);
Wire.begin(); Wire.begin();
radio.initialize(); radio.initialize();
radio.setVHF();
radio.setRfPower(0); radio.setRfPower(0);
radio.setFrequency(145050); radio.setFrequency(145050);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(11, INPUT);
dds.start(); dds.start();
dds.setFrequency(1200); dds.setFrequency(1200);
dds.on(); dds.on();
@ -236,7 +247,7 @@ ISR(ADC_vect) {
static uint8_t lastADC = 127; static uint8_t lastADC = 127;
cli(); cli();
TIFR1 = _BV(ICF1); TIFR1 = _BV(ICF1);
PORTD |= _BV(2); //PORTD |= _BV(2);
dds.clockTick(); dds.clockTick();
sei(); sei();
if(listening) { if(listening) {
@ -255,5 +266,5 @@ ISR(ADC_vect) {
} }
lastADC = ADCH; lastADC = ADCH;
} }
PORTD &= ~_BV(2); //PORTD &= ~_BV(2);
} }

View File

@ -2,18 +2,31 @@
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h> #include <Wire.h>
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
HamShield radio; HamShield radio;
DDS dds; DDS dds;
void setup() { void setup() {
// 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 radio
digitalWrite(RESET_PIN, HIGH);
Wire.begin(); Wire.begin();
radio.initialize(); radio.initialize();
radio.setRfPower(0); radio.setRfPower(0);
radio.setVHF();
radio.setFrequency(145060); radio.setFrequency(145060);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(11, INPUT);
radio.setModeTransmit(); radio.setModeTransmit();
dds.start(); dds.start();
dds.playWait(600, 3000); dds.playWait(600, 3000);
@ -37,10 +50,10 @@ ISR(ADC_vect) {
static unsigned char tcnt = 0; static unsigned char tcnt = 0;
TIFR1 = _BV(ICF1); // Clear the timer flag TIFR1 = _BV(ICF1); // Clear the timer flag
if(++tcnt == 4) { if(++tcnt == 4) {
digitalWrite(2, HIGH); //digitalWrite(2, HIGH);
tcnt = 0; tcnt = 0;
} }
dds.clockTick(); dds.clockTick();
digitalWrite(2, LOW); //digitalWrite(2, LOW);
} }
#endif #endif

View File

@ -9,11 +9,26 @@ Beacon will check to see if the channel is clear before it will transmit.
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h> #include <Wire.h>
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
// Create a new instance of our HamSheild class, called 'radio' // Create a new instance of our HamSheild class, called 'radio'
HamShield radio; HamShield radio;
// Run our start up things here // Run our start up things here
void setup() { void setup() {
// 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);
digitalWrite(RESET_PIN, HIGH);
// Set up the serial port at 9600 Baud // Set up the serial port at 9600 Baud
Serial.begin(9600); Serial.begin(9600);
@ -30,10 +45,9 @@ void setup() {
// Tell the HamShield to start up // Tell the HamShield to start up
radio.initialize(); radio.initialize();
radio.setRfPower(15); radio.setRfPower(8);
// Configure the HamShield to transmit and recieve on 446.000MHz // Configure the HamShield to transmit and recieve on 446.000MHz
radio.frequency(145570); radio.frequency(145570);
pinMode(11, INPUT); // Bodge for now, as pin 3 is hotwired to pin 11
Serial.println("Radio Configured."); Serial.println("Radio Configured.");
} }

View File

@ -3,6 +3,10 @@
#include <HAMShield.h> #include <HAMShield.h>
#include <Wire.h> #include <Wire.h>
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
// transmit for 1 minute, every 10 minutes // transmit for 1 minute, every 10 minutes
#define TRANSMITLENGTH 1 #define TRANSMITLENGTH 1
@ -12,6 +16,17 @@
HAMShield radio; HAMShield radio;
void setup() { void setup() {
// 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);
digitalWrite(RESET_PIN, HIGH);
Wire.begin(); Wire.begin();
radio.initialize(); radio.initialize();
radio.setFrequency(145510); radio.setFrequency(145510);

View File

@ -3,9 +3,24 @@
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h> #include <Wire.h>
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
HamShield radio; HamShield radio;
void setup() { void setup() {
// 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);
digitalWrite(RESET_PIN, HIGH);
Wire.begin(); Wire.begin();
Serial.begin(9600); Serial.begin(9600);
Serial.println("If the sketch freezes at radio status, there is something wrong with power or the shield"); Serial.println("If the sketch freezes at radio status, there is something wrong with power or the shield");

View File

@ -10,6 +10,10 @@ Simple gauges for the radio receiver.
#include <HAMShield.h> #include <HAMShield.h>
#include <Wire.h> #include <Wire.h>
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
HAMShield radio; HAMShield radio;
void clr() { void clr() {
@ -20,6 +24,17 @@ void clr() {
} }
void setup() { void setup() {
// 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);
digitalWrite(RESET_PIN, HIGH);
analogReference(DEFAULT); analogReference(DEFAULT);
Serial.begin(115200); Serial.begin(115200);
Wire.begin(); Wire.begin();

View File

@ -5,13 +5,28 @@
#include <Wire.h> #include <Wire.h>
#include <SPI.h> #include <SPI.h>
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
HAMShield radio; HAMShield radio;
void setup() { void setup() {
// 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);
digitalWrite(RESET_PIN, HIGH);
Robot.begin(); Robot.begin();
Wire.begin(); Wire.begin();
radio.initialize(); radio.initialize();
radio.setFrequency(145510); radio.frequency(145510);
} }
void loop() { void loop() {

View File

@ -6,11 +6,16 @@ Arduino audio overlay example
*/ */
#include <HAMShield.h> #include <HAMShield.h>
#include <Wire.h> #include <Wire.h>
#define DOT 100 #define DOT 100
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
HAMShield radio; HAMShield radio;
const char *bascii = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,?'!/()&:;=+-_\"$@", const char *bascii = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,?'!/()&:;=+-_\"$@",
@ -22,6 +27,17 @@ const char *callsign = {"1ZZ9ZZ/B"} ;
char morsebuffer[8]; char morsebuffer[8];
void setup() { void setup() {
// 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);
digitalWrite(RESET_PIN, HIGH);
Serial.begin(9600); Serial.begin(9600);
Serial.println("starting up.."); Serial.println("starting up..");
Wire.begin(); Wire.begin();
@ -29,7 +45,7 @@ void setup() {
int result = radio.testConnection(); int result = radio.testConnection();
Serial.println(result,DEC); Serial.println(result,DEC);
radio.initialize(); radio.initialize();
radio.setFrequency(446000); radio.frequency(446000);
radio.setVolume1(0xF); radio.setVolume1(0xF);
radio.setVolume2(0xF); radio.setVolume2(0xF);
radio.setModeReceive(); radio.setModeReceive();

View File

@ -3,9 +3,24 @@
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h> #include <Wire.h>
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
HamShield radio; HamShield radio;
void setup() { void setup() {
// 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);
digitalWrite(RESET_PIN, HIGH);
Wire.begin(); Wire.begin();
Serial.begin(9600); Serial.begin(9600);
Serial.println("If the sketch freezes at radio status, there is something wrong with power or the shield"); Serial.println("If the sketch freezes at radio status, there is something wrong with power or the shield");

View File

@ -6,20 +6,35 @@ HamShield radio;
DDS dds; DDS dds;
KISS kiss(&Serial, &radio, &dds); KISS kiss(&Serial, &radio, &dds);
//TODO: move these into library
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
void setup() { void setup() {
pinMode(2, OUTPUT); // NOTE: if not using PWM out, it should be held low to avoid tx noise
pinMode(3, OUTPUT); pinMode(PWM_PIN, OUTPUT);
pinMode(11, INPUT); digitalWrite(PWM_PIN, LOW);
// prep the switch
pinMode(SWITCH_PIN, INPUT_PULLUP);
// set up the reset control pin
pinMode(RESET_PIN, OUTPUT);
digitalWrite(RESET_PIN, LOW);
Serial.begin(9600); Serial.begin(9600);
while (digitalRead(SWITCH_PIN));
// let the AU ot of reset
digitalWrite(RESET_PIN, HIGH);
Wire.begin(); Wire.begin();
radio.initialize(); radio.initialize();
radio.setVHF();
radio.setSQOff(); radio.setSQOff();
radio.setFrequency(145010); radio.setFrequency(144390);
I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x30, 0x06); //I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x44, 0x05FF);
I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x30, 0x26);
I2Cdev::writeWord(A1846S_DEV_ADDR_SENLOW, 0x44, 0x05FF);
dds.start(); dds.start();
radio.afsk.start(&dds); radio.afsk.start(&dds);

View File

@ -1,13 +1,25 @@
#include <HamShield.h> #include <HamShield.h>
#include "varicode.h" #include "varicode.h"
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
DDS dds; DDS dds;
void setup() { void setup() {
// 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);
digitalWrite(RESET_PIN, HIGH);
Serial.begin(9600); Serial.begin(9600);
pinMode(11, OUTPUT);
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
// put your setup code here, to run once: // put your setup code here, to run once:
dds.setReferenceClock(32000); dds.setReferenceClock(32000);
dds.start(); dds.start();
@ -65,7 +77,7 @@ ISR(ADC_vect) {
if(tcnt > (255-81)) if(tcnt > (255-81))
dds.setAmplitude(amplitudeShape[(tcnt-174)/2]); dds.setAmplitude(amplitudeShape[(tcnt-174)/2]);
dds.clockTick(); dds.clockTick();
PORTD &= ~_BV(2); //PORTD &= ~_BV(2);
if(outer++ == 3) { if(outer++ == 3) {
outer = 0; outer = 0;
} else { } else {
@ -89,5 +101,5 @@ ISR(ADC_vect) {
dds.changePhaseDeg(+180); dds.changePhaseDeg(+180);
} }
} }
PORTD &= ~_BV(2); //PORTD &= ~_BV(2);
} }

View File

@ -9,6 +9,10 @@ A bit robotic and weird
#include <HAMShield.h> #include <HAMShield.h>
#include <Wire.h> #include <Wire.h>
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
#define RATE 500 #define RATE 500
#define SIZE 1500 #define SIZE 1500
@ -21,6 +25,17 @@ int16_t rssi;
byte mode = 8; byte mode = 8;
void setup() { void setup() {
// 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);
digitalWrite(RESET_PIN, HIGH);
Wire.begin(); Wire.begin();
// int result = radio.testConnection(); // int result = radio.testConnection();
radio.initialize(); radio.initialize();

View File

@ -1,13 +1,26 @@
#include <HamShield.h> #include <HamShield.h>
#include "varicode.h" #include "varicode.h"
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
DDS dds; DDS dds;
void setup() { void setup() {
// 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);
digitalWrite(RESET_PIN, LOW);
Serial.begin(9600); Serial.begin(9600);
pinMode(11, OUTPUT);
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
// put your setup code here, to run once: // put your setup code here, to run once:
dds.setReferenceClock(32000); dds.setReferenceClock(32000);
dds.start(); dds.start();

View File

@ -4,6 +4,10 @@ Sends an SSTV test pattern
*/ */
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
#define DOT 100 #define DOT 100
#define CALLSIGN "1ZZ9ZZ/B" #define CALLSIGN "1ZZ9ZZ/B"
@ -18,13 +22,24 @@ int16_t rssi;
/* get our radio ready */ /* get our radio ready */
void setup() { void setup() {
// 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);
digitalWrite(RESET_PIN, HIGH);
Wire.begin(); Wire.begin();
Serial.begin(9600); Serial.begin(9600);
Serial.print("Radio status: "); Serial.print("Radio status: ");
int result = radio.testConnection(); int result = radio.testConnection();
Serial.println(result); Serial.println(result);
radio.initialize(); radio.initialize();
radio.setFrequency(446000); radio.frequency(446000);
radio.setModeReceive(); radio.setModeReceive();
} }

View File

@ -4,6 +4,10 @@
#include <HamShield.h> #include <HamShield.h>
#include <Wire.h> #include <Wire.h>
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
HamShield radio; HamShield radio;
DDS dds; DDS dds;
// Defined at the end of the sketch // Defined at the end of the sketch
@ -15,6 +19,17 @@ extern const uint16_t image[256*20] PROGMEM;
ddsAccumulator_t freqTable[3]; ddsAccumulator_t freqTable[3];
void setup() { void setup() {
// 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);
digitalWrite(RESET_PIN, HIGH);
Serial.begin(9600); Serial.begin(9600);
Wire.begin(); Wire.begin();
// Query the HamShield for status information // Query the HamShield for status information
@ -26,11 +41,7 @@ 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.setVHF(); radio.frequency(145500);
radio.setFrequency(145500);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(11, INPUT); // HiZ
// put your setup code here, to run once: // put your setup code here, to run once:
//dds.setReferenceClock(34965/4); //dds.setReferenceClock(34965/4);
dds.start(); dds.start();

View File

@ -49,6 +49,10 @@ Debug Msg @<text>; 32 character debug message
#include "Wire.h" #include "Wire.h"
#include "HamShield.h" #include "HamShield.h"
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
int state; int state;
int txcount = 0; int txcount = 0;
long timer = 0; long timer = 0;
@ -68,6 +72,17 @@ HamShield radio;
void setup() { void setup() {
// 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);
digitalWrite(RESET_PIN, HIGH);
Serial.begin(115200); Serial.begin(115200);
Serial.print(";;;;;;;;;;;;;;;;;;;;;;;;;;"); Serial.print(";;;;;;;;;;;;;;;;;;;;;;;;;;");
Wire.begin(); Wire.begin();

View File

@ -14,6 +14,10 @@ Plays back the current signal strength level and morses out it's call sign at th
#include <Wire.h> #include <Wire.h>
#include <PCM.h> #include <PCM.h>
#define PWM_PIN 3
#define RESET_PIN A3
#define SWITCH_PIN 2
HAMShield radio; HAMShield radio;
int16_t rssi; int16_t rssi;
int peak = -150; int peak = -150;
@ -74,13 +78,24 @@ const unsigned char dbm[] PROGMEM = {
/* get our radio ready */ /* get our radio ready */
void setup() { void setup() {
// 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);
digitalWrite(RESET_PIN, HIGH);
Wire.begin(); Wire.begin();
Serial.begin(9600); Serial.begin(9600);
Serial.print("Radio status: "); Serial.print("Radio status: ");
int result = radio.testConnection(); int result = radio.testConnection();
Serial.println(result); Serial.println(result);
radio.initialize(); radio.initialize();
radio.setFrequency(446000); radio.frequency(446000);
radio.setVolume1(0xF); radio.setVolume1(0xF);
radio.setVolume2(0xF); radio.setVolume2(0xF);
radio.setModeReceive(); radio.setModeReceive();
@ -104,7 +119,7 @@ void loop() {
if(rssi < -120) { if(rssi < -120) {
Serial.println("Transmit On"); Serial.println("Transmit On");
radio.setTX(1); radio.setModeTransmit();
delay(250); delay(250);
tone(11,1000,500); tone(11,1000,500);
delay(1000); delay(1000);
@ -131,9 +146,8 @@ void loop() {
delay(1000); delay(1000);
Serial.println("done!"); Serial.println("done!");
radio.morseOut(CALLSIGN); radio.morseOut(CALLSIGN);
radio.setTX(0);
Serial.println("Transmit off");
radio.setModeReceive(); radio.setModeReceive();
Serial.println("Transmit off");
delay(1000); delay(1000);
} }
} }