Last active
March 14, 2019 22:00
-
-
Save mttrb/4712611 to your computer and use it in GitHub Desktop.
Elecraft T1 Arduino Interface to integrate with DDUtil and the FlexRadio 1500
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************** | |
* Elecraft T1 Interface * | |
* * | |
* This Arduino sketch allows DDUtil to control * | |
* an Elecraft T1 ATU via the T1's remote control * | |
* interface. * | |
* * | |
* Copyright (c) Matthew Robinson - VK6MR, 2011 * | |
* * | |
* This code is released under a Creative Commons * | |
* Attribution-NonCommercial-ShareAlike 3.0 * | |
* Unported (CC BY-NC-SA 3.0) license. * | |
* * | |
* http://creativecommons.org/licenses/by-nc-sa/3.0/ * | |
* * | |
******************************************************/ | |
int TUNE = 2; | |
int DATA = 3; | |
int prevBand = -1; | |
int band = 0; | |
char buffer[64]; | |
int bufptr = 0; | |
void setup() { | |
Serial.begin(9600); | |
pinMode(TUNE, OUTPUT); | |
digitalWrite(TUNE, LOW); | |
pinMode(DATA, INPUT); | |
} | |
void loop() { | |
if (Serial.available()) { | |
char character = Serial.read(); | |
if (character != '\n' && character != '\r') { | |
buffer[bufptr] = character; | |
if (buffer[bufptr] == ';') { | |
// Message should always be 14 chars | |
if (bufptr == 13) { | |
parseBuffer(); | |
if (band != -1) { | |
if (band != prevBand) { | |
sendBand(); | |
prevBand = band; | |
} | |
} | |
} | |
bufptr = 0; | |
} | |
else { | |
bufptr++; | |
// Don't overrun the buffer, messages should only be 14 chars anyway | |
if (bufptr > 60) | |
bufptr = 0; | |
} | |
} | |
} | |
} | |
// buffer is of form: | |
// IF00003700000; | |
// IF00051000000; | |
void parseBuffer() { | |
if (buffer[0] != 'I' || buffer[1] != 'F') { | |
band = -1; | |
return; | |
} | |
// We are only interested in the significant figures | |
int freq = buffer[6] - 48; | |
freq += (buffer[5] - 48) * 10; | |
band = 0; | |
if (freq >= 1 && freq <= 2) { | |
band = 1; // 160 | |
} | |
else if (freq >= 3 && freq <= 4) { | |
band = 2; // 80 | |
} | |
else if (freq == 5) { | |
band = 3; // 60 | |
} | |
else if (freq == 7) { | |
band = 4; // 40 | |
} | |
else if (freq == 10) { | |
band = 5; // 30 | |
} | |
else if (freq == 14) { | |
band = 6; // 20 | |
} | |
else if (freq == 18) { | |
band = 7; // 17 | |
} | |
else if (freq == 21) { | |
band = 8; // 15 | |
} | |
else if (freq == 24) { | |
band = 9; // 12 | |
} | |
else if (freq >= 28 && freq <= 29) { | |
band = 10; // 10 | |
} | |
else if (freq >= 50 && freq <= 54) { | |
band = 11; // 6 | |
} | |
} | |
void sendBand() { | |
// Pull the TUNE line high for half a second | |
digitalWrite(TUNE, HIGH); | |
delay(500); | |
digitalWrite(TUNE, LOW); | |
// The ATU will pull the DATA line HIGH for 50ms | |
while(digitalRead(DATA) == LOW) { | |
} | |
while(digitalRead(DATA) == HIGH) { | |
} | |
// Wait 10ms | |
delay(10); | |
// and then send data on the DATA line | |
pinMode(DATA, OUTPUT); | |
// 1 bits are HIGH for 4ms | |
// 0 bits are HIGH for 1.5ms | |
// Gap between digits is 1.5ms LOW | |
// 1st bit | |
sendBit(band & 8); | |
sendBit(band & 4); | |
sendBit(band & 2); | |
sendBit(band & 1); | |
// Leave the line LOW | |
digitalWrite(DATA, LOW); | |
// and switch it back to an input | |
pinMode(DATA, INPUT); | |
} | |
void sendBit(int bit) { | |
digitalWrite(DATA, HIGH); | |
if (bit != 0) { | |
delay(4); | |
} else { | |
delayMicroseconds(1500); | |
} | |
digitalWrite(DATA, LOW); | |
delayMicroseconds(1500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
I made the arduino + smal board for connection to the T1.
Sketch compiled and uploaded well.
Try tot connect to powersdr with DDutil and vspMger.
But it is not working.
Perhaps I do something wrong in my setup.
Can you tell me exact how you did setup Powersdr (2.5.3) Vpsmgr and DDutil (v3)
Thanks in advance for answering
Regards
Onno
pa0ono
(nano