Update and rename qst2_promini33_rfm69_FELD_HELL_GPS_20180116.ino to promini33_rfm69_FELD_HELL_GPS_20180116.ino

master
SnkMtn000 2018-01-31 17:46:38 -05:00 zatwierdzone przez GitHub
rodzic 0edf236237
commit b0617c99fd
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 259 dodań i 259 usunięć

Wyświetl plik

@ -1,260 +1,260 @@
/* /*
* A simple GPS Feld Hell Telemetry sender * A simple GPS Feld Hell Telemetry sender
* for the HopeRF rfm69hcw * for the HopeRF rfm69hcw
* on a ProMini 3.3 * on a ProMini 3.3
* Charles Webb * Charles Webb
* KC1ENN@arrl.net * KC1ENN@arrl.net
* *
* with thanks to James Coxon * with thanks to James Coxon
* *
* Feld Hell for HopeRF rfm69hcw modifed from source below * Feld Hell for HopeRF rfm69hcw modifed from source below
* https://github.com/jamescoxon/PicoAtlas/blob/master/Pico6MK3/sketch_apr02b/sketch_apr02b.ino * https://github.com/jamescoxon/PicoAtlas/blob/master/Pico6MK3/sketch_apr02b/sketch_apr02b.ino
* *
* *
*/ */
#include <SPI.h> #include <SPI.h>
#include <TinyGPS++.h> #include <TinyGPS++.h>
#include <SoftwareSerial.h> #include <SoftwareSerial.h>
#define MY_DELAY 5000 // delay in loop, between sending the message #define MY_DELAY 5000 // delay in loop, between sending the message
//#define POWER 0x50 // -2 dBm //#define POWER 0x50 // -2 dBm
///#define POWER 0x52 // 0 dBm ///#define POWER 0x52 // 0 dBm
//#define POWER 0x55 // 3 dBm //#define POWER 0x55 // 3 dBm
//#define POWER 0x58 // 6 dBm //#define POWER 0x58 // 6 dBm
//#define POWER 0x5B // 9 dBm //#define POWER 0x5B // 9 dBm
//#define POWER 0x5E // 12 dBm //#define POWER 0x5E // 12 dBm
#define POWER 0x7F // 17 dBm #define POWER 0x7F // 17 dBm
#define ssPin 10 // SS #define ssPin 10 // SS
#define rstPin 9 // reset pin #define rstPin 9 // reset pin
#define radioPower 0x7F #define MODULATION 0x48 // Modulation for OOK, Continuous w.o bit synch, OOK, no shaping
#define myFrequency 433200000 #define myFrequency 433200000
//#define myFrequency 915000000 //#define myFrequency 915000000
unsigned int count = 0; unsigned int count = 0;
char mytext[80]; char mytext[80];
String myCallSign = "CALLSIGN/B"; String myCallSign = "CALLSIGN/B";
String myString = ""; String myString = "";
int myHour, myMinute, mySecond, myAlt, mySpd, mySat; int myHour, myMinute, mySecond, myAlt, mySpd, mySat;
double myLat, myLng; double myLat, myLng;
TinyGPSPlus gps; TinyGPSPlus gps;
SoftwareSerial ss(6,7); // Tx Rx SoftwareSerial ss(6,7); // Tx Rx
void setup(){ void setup(){
Serial.begin(9600); Serial.begin(9600);
ss.begin(9600); ss.begin(9600);
pinMode(ssPin, OUTPUT); pinMode(ssPin, OUTPUT);
pinMode(rstPin, OUTPUT); pinMode(rstPin, OUTPUT);
setupSPI(); setupSPI();
delay(1000); delay(1000);
resetRFM69(); resetRFM69();
delay(1000); delay(1000);
setupRFM69(); setupRFM69();
} }
void loop(){ void loop(){
count++; count++;
fetchGPS(); fetchGPS();
buildString(); buildString();
myString.toCharArray(mytext,myString.length() + 1); myString.toCharArray(mytext,myString.length() + 1);
hellsendmsg(mytext); hellsendmsg(mytext);
delay(MY_DELAY); delay(MY_DELAY);
} }
void buildString() { void buildString() {
myString = "..."; myString = "...";
myString += myCallSign; myString += myCallSign;
myString += " COUNT " + String(count); myString += " COUNT " + String(count);
myString += " TIME " + String(myHour) + "/" + String(myMinute) + "/" + String(mySecond); myString += " TIME " + String(myHour) + "/" + String(myMinute) + "/" + String(mySecond);
myString += " LAT " + String(myLat,7) + " LNG " + String(myLng,7); myString += " LAT " + String(myLat,7) + " LNG " + String(myLng,7);
myString += " ALT " + String(myAlt) + " SPD " + String(mySpd) + " SAT " + String(mySat); myString += " ALT " + String(myAlt) + " SPD " + String(mySpd) + " SAT " + String(mySat);
myString += "..."; myString += "...";
Serial.print("I am sending: "); Serial.println(myString); Serial.print("I am sending: "); Serial.println(myString);
} }
void fetchGPS() { //Remeber to only enable and softwear serial as needed, to thre the GPS then disable as it messes with the timing/printing of FH void fetchGPS() { //Remeber to only enable and softwear serial as needed, to thre the GPS then disable as it messes with the timing/printing of FH
myHour = gps.time.hour(); myHour = gps.time.hour();
myMinute = gps.time.minute(); myMinute = gps.time.minute();
mySecond = gps.time.second(); mySecond = gps.time.second();
myLat = gps.location.lat(); myLat = gps.location.lat();
myLng = gps.location.lng(); myLng = gps.location.lng();
myAlt = gps.altitude.feet(); myAlt = gps.altitude.feet();
mySpd = gps.speed.mph(); mySpd = gps.speed.mph();
mySat = gps.satellites.value(); mySat = gps.satellites.value();
smartDelay(1000); smartDelay(1000);
} }
void setupRFM69() { void setupRFM69() {
writeReg(0x01,0x0C); writeReg(0x01,0x0C);
writeReg(0x02,0x34); // Modulation for OOK, Continuous w.o bit synch, OOK, no shaping writeReg(0x02,MODULATION);
setFrequency(myFrequency); setFrequency(myFrequency);
Serial.print("Frequency set to "); Serial.println(myFrequency); Serial.print("Frequency set to "); Serial.println(myFrequency);
writeReg(0x26,0x07); // CLK off to save power writeReg(0x26,0x07); // CLK off to save power
} }
// set the frequency (in Hz) // set the frequency (in Hz)
void setFrequency(uint32_t freqHz){ void setFrequency(uint32_t freqHz){
freqHz /= 61; // divide down by FSTEP to get FRF freqHz /= 61; // divide down by FSTEP to get FRF
writeReg(0x07, freqHz >> 16); writeReg(0x07, freqHz >> 16);
writeReg(0x08, freqHz >> 8); writeReg(0x08, freqHz >> 8);
writeReg(0x09, freqHz); writeReg(0x09, freqHz);
} }
void resetRFM69() { void resetRFM69() {
digitalWrite(rstPin, HIGH); digitalWrite(rstPin, HIGH);
delay(100); delay(100);
digitalWrite(rstPin, LOW); digitalWrite(rstPin, LOW);
delay(100); delay(100);
} }
void printReg(byte data) { void printReg(byte data) {
Serial.print("Register "); Serial.print("Register ");
Serial.print(data); Serial.print(data);
Serial.print(" = "); Serial.print(" = ");
Serial.println(readReg(data), HEX); Serial.println(readReg(data), HEX);
} }
void writeReg(uint8_t addr, uint8_t value) { void writeReg(uint8_t addr, uint8_t value) {
digitalWrite(ssPin,LOW); digitalWrite(ssPin,LOW);
SPI.transfer(addr | 0x80); SPI.transfer(addr | 0x80);
SPI.transfer(value); SPI.transfer(value);
digitalWrite(ssPin, HIGH); digitalWrite(ssPin, HIGH);
} }
uint8_t readReg(uint8_t addr) { uint8_t readReg(uint8_t addr) {
digitalWrite(ssPin, LOW); digitalWrite(ssPin, LOW);
SPI.transfer(addr & 0x7F); SPI.transfer(addr & 0x7F);
uint8_t regval = SPI.transfer(0); uint8_t regval = SPI.transfer(0);
digitalWrite(ssPin, HIGH); digitalWrite(ssPin, HIGH);
return regval; return regval;
} }
void setupSPI() { void setupSPI() {
SPI.begin(); SPI.begin();
SPI.setBitOrder(MSBFIRST); SPI.setBitOrder(MSBFIRST);
SPI.setClockDivider(SPI_CLOCK_DIV4); SPI.setClockDivider(SPI_CLOCK_DIV4);
} }
//***************Hellschreiber****************** //***************Hellschreiber******************
struct t_htab { char c; int hellpat[5]; } ; struct t_htab { char c; int hellpat[5]; } ;
struct t_htab helltab[] = { struct t_htab helltab[] = {
{'1', { B00000100, B00000100, B01111100, B00000000, B00000000 } }, {'1', { B00000100, B00000100, B01111100, B00000000, B00000000 } },
{'2', { B01001000, B01100100, B01010100, B01001100, B01000000 } }, {'2', { B01001000, B01100100, B01010100, B01001100, B01000000 } },
{'3', { B01000100, B01000100, B01010100, B01010100, B00111100 } }, {'3', { B01000100, B01000100, B01010100, B01010100, B00111100 } },
{'4', { B00011100, B00010000, B00010000, B01111100, B00010000 } }, {'4', { B00011100, B00010000, B00010000, B01111100, B00010000 } },
{'5', { B01000000, B01011100, B01010100, B01010100, B00110100 } }, {'5', { B01000000, B01011100, B01010100, B01010100, B00110100 } },
{'6', { B00111100, B01010010, B01001010, B01001000, B00110000 } }, {'6', { B00111100, B01010010, B01001010, B01001000, B00110000 } },
{'7', { B01000100, B00100100, B00010100, B00001100, B00000100 } }, {'7', { B01000100, B00100100, B00010100, B00001100, B00000100 } },
{'8', { B00111100, B01001010, B01001010, B01001010, B00111100 } }, {'8', { B00111100, B01001010, B01001010, B01001010, B00111100 } },
{'9', { B00001100, B01001010, B01001010, B00101010, B00111100 } }, {'9', { B00001100, B01001010, B01001010, B00101010, B00111100 } },
{'0', { B00111000, B01100100, B01010100, B01001100, B00111000 } }, {'0', { B00111000, B01100100, B01010100, B01001100, B00111000 } },
{'A', { B01111000, B00101100, B00100100, B00101100, B01111000 } }, {'A', { B01111000, B00101100, B00100100, B00101100, B01111000 } },
{'B', { B01000100, B01111100, B01010100, B01010100, B00101000 } }, {'B', { B01000100, B01111100, B01010100, B01010100, B00101000 } },
{'C', { B00111000, B01101100, B01000100, B01000100, B00101000 } }, {'C', { B00111000, B01101100, B01000100, B01000100, B00101000 } },
{'D', { B01000100, B01111100, B01000100, B01000100, B00111000 } }, {'D', { B01000100, B01111100, B01000100, B01000100, B00111000 } },
{'E', { B01111100, B01010100, B01010100, B01000100, B01000100 } }, {'E', { B01111100, B01010100, B01010100, B01000100, B01000100 } },
{'F', { B01111100, B00010100, B00010100, B00000100, B00000100 } }, {'F', { B01111100, B00010100, B00010100, B00000100, B00000100 } },
{'G', { B00111000, B01101100, B01000100, B01010100, B00110100 } }, {'G', { B00111000, B01101100, B01000100, B01010100, B00110100 } },
{'H', { B01111100, B00010000, B00010000, B00010000, B01111100 } }, {'H', { B01111100, B00010000, B00010000, B00010000, B01111100 } },
{'I', { B00000000, B01000100, B01111100, B01000100, B00000000 } }, {'I', { B00000000, B01000100, B01111100, B01000100, B00000000 } },
{'J', { B01100000, B01000000, B01000000, B01000000, B01111100 } }, {'J', { B01100000, B01000000, B01000000, B01000000, B01111100 } },
{'K', { B01111100, B00010000, B00111000, B00101000, B01000100 } }, {'K', { B01111100, B00010000, B00111000, B00101000, B01000100 } },
{'L', { B01111100, B01000000, B01000000, B01000000, B01000000 } }, {'L', { B01111100, B01000000, B01000000, B01000000, B01000000 } },
{'M', { B01111100, B00001000, B00010000, B00001000, B01111100 } }, {'M', { B01111100, B00001000, B00010000, B00001000, B01111100 } },
{'N', { B01111100, B00000100, B00001000, B00010000, B01111100 } }, {'N', { B01111100, B00000100, B00001000, B00010000, B01111100 } },
{'O', { B00111000, B01000100, B01000100, B01000100, B00111000 } }, {'O', { B00111000, B01000100, B01000100, B01000100, B00111000 } },
{'P', { B01000100, B01111100, B01010100, B00010100, B00011000 } }, {'P', { B01000100, B01111100, B01010100, B00010100, B00011000 } },
{'Q', { B00111000, B01000100, B01100100, B11000100, B10111000 } }, {'Q', { B00111000, B01000100, B01100100, B11000100, B10111000 } },
{'R', { B01111100, B00010100, B00010100, B00110100, B01011000 } }, {'R', { B01111100, B00010100, B00010100, B00110100, B01011000 } },
{'S', { B01011000, B01010100, B01010100, B01010100, B00100100 } }, {'S', { B01011000, B01010100, B01010100, B01010100, B00100100 } },
{'T', { B00000100, B00000100, B01111100, B00000100, B00000100 } }, {'T', { B00000100, B00000100, B01111100, B00000100, B00000100 } },
{'U', { B01111100, B01000000, B01000000, B01000000, B01111100 } }, {'U', { B01111100, B01000000, B01000000, B01000000, B01111100 } },
{'V', { B01111100, B00100000, B00010000, B00001000, B00000100 } }, {'V', { B01111100, B00100000, B00010000, B00001000, B00000100 } },
{'W', { B01111100, B01100000, B01111100, B01000000, B01111100 } }, {'W', { B01111100, B01100000, B01111100, B01000000, B01111100 } },
{'X', { B01000100, B00101000, B00010000, B00101000, B01000100 } }, {'X', { B01000100, B00101000, B00010000, B00101000, B01000100 } },
{'Y', { B00000100, B00001000, B01110000, B00001000, B00000100 } }, {'Y', { B00000100, B00001000, B01110000, B00001000, B00000100 } },
{'Z', { B01000100, B01100100, B01010100, B01001100, B01100100 } }, {'Z', { B01000100, B01100100, B01010100, B01001100, B01100100 } },
{'.', { B01000000, B01000000, B00000000, B00000000, B00000000 } }, {'.', { B01000000, B01000000, B00000000, B00000000, B00000000 } },
{',', { B10000000, B10100000, B01100000, B00000000, B00000000 } }, {',', { B10000000, B10100000, B01100000, B00000000, B00000000 } },
{'/', { B01000000, B00100000, B00010000, B00001000, B00000100 } }, {'/', { B01000000, B00100000, B00010000, B00001000, B00000100 } },
{'*', { B00000000, B00000000, B00000100, B00001110, B00000100 } } {'*', { B00000000, B00000000, B00000100, B00001110, B00000100 } }
}; };
#define N_HELL (sizeof(helltab)/sizeof(helltab[0])) #define N_HELL (sizeof(helltab)/sizeof(helltab[0]))
void helldelay() { void helldelay() {
//Slow Hell //Slow Hell
//delay(64); //delay(64);
//delayMicroseconds(900); //delayMicroseconds(900);
//Feld-Hell //Feld-Hell
delay(8); // was 8 and hands off delay(8); // was 8 and hands off
delayMicroseconds(100); // was 160 used to adjust slope of displayed text delayMicroseconds(100); // was 160 used to adjust slope of displayed text
} }
void on() { void on() {
writeReg(0x11,radioPower); // PA On writeReg(0x11,radioPower); // PA On
helldelay(); helldelay();
writeReg(0x11,0x00); writeReg(0x11,0x00);
} }
void hellsend(char c) { void hellsend(char c) {
int i ; int i ;
if (c == ' ') { if (c == ' ') {
for (int d=0; d<14; d++){ for (int d=0; d<14; d++){
helldelay(); helldelay();
} }
return ; return ;
} }
for (i=0; i<N_HELL; i++) { for (i=0; i<N_HELL; i++) {
if (helltab[i].c == c) { if (helltab[i].c == c) {
//Serial.print(helltab[i].c) ; //Serial.print(helltab[i].c) ;
for (int j=0; j<=4; j++) for (int j=0; j<=4; j++)
{ {
byte mask = B10000000; byte mask = B10000000;
for (int q=0; q<=6; q++) for (int q=0; q<=6; q++)
{ {
if(helltab[i].hellpat[j] & mask) { if(helltab[i].hellpat[j] & mask) {
on(); on();
} else { } else {
helldelay(); helldelay();
} }
mask >>= 1; mask >>= 1;
} }
} }
for (int d=0; d<14; d++){ for (int d=0; d<14; d++){
helldelay(); helldelay();
} }
return ; return ;
} }
} }
/* if we drop off the end, then we send a space */ /* if we drop off the end, then we send a space */
//Serial.print("?") ; //Serial.print("?") ;
} }
void hellsendmsg(char *str) { void hellsendmsg(char *str) {
//flag = 1; //flag = 1;
delay(1000); delay(1000);
while (*str) while (*str)
hellsend(*str++) ; hellsend(*str++) ;
//Serial.println(""); //Serial.println("");
//flag = 0; //flag = 0;
} }
// This custom version of delay() ensures that the gps object is being "fed". // This custom version of delay() ensures that the gps object is being "fed".
static void smartDelay(unsigned long ms) static void smartDelay(unsigned long ms)
{ {
unsigned long start = millis(); unsigned long start = millis();
do do
{ {
while (ss.available()) while (ss.available())
gps.encode(ss.read()); gps.encode(ss.read());
} while (millis() - start < ms); } while (millis() - start < ms);
} }