¿ªÔÆÌåÓý

tuning step size for the SI5351 / Radunio version


 

On Dec 27, 2016 10:17 AM, "Sandeep Lohia" <sandeeplohia12@...> wrote:

> Carbon film Pot don't last long if not wire wound,

VU2DEV was also trying as to use a carbon Pot with link below, a couple of weeks ago.

Also got codes for 20 Meter for above link using 10 Mhz IF.
PM me, if any interested in homebreawing...
I baked such 2 in 2012.

& for above one can just switch off external counter after read, & thus abatement?of birdies...


 


Jack,

Can you share the sketch/code that has the encoder automatic tuning increment as mentioned below?

We don't all have access to QRP Quarterly.

thanks
Darryl


---In BITX20@..., <econjack@...> wrote :

I do use a rotary encoder to tune my Forty-9er (see March, 2016, QST) and will likely soon add one to the BITX40 I just bought. The increment is an issue that is often one of personal preference. For CW, I use a 100Hz increment as the default. However, if I want to traverse from one end of the band to the other, it takes a bazillion turns of the encoder shaft to make the move. To overcome this limitation, I wrote a routine that senses how fast you are turning the encoder shaft using one of the Nano timers. If the "detent spacing" is fairly long, that is interpreted as you slowly fine tuning a station. If the spacing is short (and you can define the time differences), the software automatically increases the increment to 50KHz (which you can also set). As you zero in on your target frequency and slow down the shaft turning rate, the software automatically drops down to the default tuning increment (e.g., 100Hz, or whatever).?

My article appears in?¡°Rotary Encoders Revisited¡±, QRP Quarterly, April, 2016.?

Jack, W8TEE




Jack Purdum
 

Sure:
See below. I've attached the article and the code.
Jack, W8TEE

From: "darryl@... [BITX20]" <BITX20@...>
To: BITX20@...
Sent: Thursday, December 29, 2016 9:47 PM
Subject: Re: [BITX20] tuning step size for the SI5351 / Radunio version

?
Jack,
Can you share the sketch/code that has the encoder automatic tuning increment as mentioned below?
We don't all have access to QRP Quarterly.
thanksDarryl

---In BITX20@..., <econjack@...> wrote :

I do use a rotary encoder to tune my Forty-9er (see March, 2016, QST) and will likely soon add one to the BITX40 I just bought. The increment is an issue that is often one of personal preference. For CW, I use a 100Hz increment as the default. However, if I want to traverse from one end of the band to the other, it takes a bazillion turns of the encoder shaft to make the move. To overcome this limitation, I wrote a routine that senses how fast you are turning the encoder shaft using one of the Nano timers. If the "detent spacing" is fairly long, that is interpreted as you slowly fine tuning a station. If the spacing is short (and you can define the time differences), the software automatically increases the increment to 50KHz (which you can also set). As you zero in on your target frequency and slow down the shaft turning rate, the software automatically drops down to the default tuning increment (e.g., 100Hz, or whatever).?
My article appears in?¡°RotaryEncoders Revisited¡±, QRPQuarterly,April, 2016.?
Jack, W8TEE


#yiv4915944323 #yiv4915944323 -- #yiv4915944323ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv4915944323 #yiv4915944323ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv4915944323 #yiv4915944323ygrp-mkp #yiv4915944323hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv4915944323 #yiv4915944323ygrp-mkp #yiv4915944323ads {margin-bottom:10px;}#yiv4915944323 #yiv4915944323ygrp-mkp .yiv4915944323ad {padding:0 0;}#yiv4915944323 #yiv4915944323ygrp-mkp .yiv4915944323ad p {margin:0;}#yiv4915944323 #yiv4915944323ygrp-mkp .yiv4915944323ad a {color:#0000ff;text-decoration:none;}#yiv4915944323 #yiv4915944323ygrp-sponsor #yiv4915944323ygrp-lc {font-family:Arial;}#yiv4915944323 #yiv4915944323ygrp-sponsor #yiv4915944323ygrp-lc #yiv4915944323hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv4915944323 #yiv4915944323ygrp-sponsor #yiv4915944323ygrp-lc .yiv4915944323ad {margin-bottom:10px;padding:0 0;}#yiv4915944323 #yiv4915944323actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv4915944323 #yiv4915944323activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv4915944323 #yiv4915944323activity span {font-weight:700;}#yiv4915944323 #yiv4915944323activity span:first-child {text-transform:uppercase;}#yiv4915944323 #yiv4915944323activity span a {color:#5085b6;text-decoration:none;}#yiv4915944323 #yiv4915944323activity span span {color:#ff7900;}#yiv4915944323 #yiv4915944323activity span .yiv4915944323underline {text-decoration:underline;}#yiv4915944323 .yiv4915944323attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv4915944323 .yiv4915944323attach div a {text-decoration:none;}#yiv4915944323 .yiv4915944323attach img {border:none;padding-right:5px;}#yiv4915944323 .yiv4915944323attach label {display:block;margin-bottom:5px;}#yiv4915944323 .yiv4915944323attach label a {text-decoration:none;}#yiv4915944323 blockquote {margin:0 0 0 4px;}#yiv4915944323 .yiv4915944323bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv4915944323 .yiv4915944323bold a {text-decoration:none;}#yiv4915944323 dd.yiv4915944323last p a {font-family:Verdana;font-weight:700;}#yiv4915944323 dd.yiv4915944323last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv4915944323 dd.yiv4915944323last p span.yiv4915944323yshortcuts {margin-right:0;}#yiv4915944323 div.yiv4915944323attach-table div div a {text-decoration:none;}#yiv4915944323 div.yiv4915944323attach-table {width:400px;}#yiv4915944323 div.yiv4915944323file-title a, #yiv4915944323 div.yiv4915944323file-title a:active, #yiv4915944323 div.yiv4915944323file-title a:hover, #yiv4915944323 div.yiv4915944323file-title a:visited {text-decoration:none;}#yiv4915944323 div.yiv4915944323photo-title a, #yiv4915944323 div.yiv4915944323photo-title a:active, #yiv4915944323 div.yiv4915944323photo-title a:hover, #yiv4915944323 div.yiv4915944323photo-title a:visited {text-decoration:none;}#yiv4915944323 div#yiv4915944323ygrp-mlmsg #yiv4915944323ygrp-msg p a span.yiv4915944323yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv4915944323 .yiv4915944323green {color:#628c2a;}#yiv4915944323 .yiv4915944323MsoNormal {margin:0 0 0 0;}#yiv4915944323 o {font-size:0;}#yiv4915944323 #yiv4915944323photos div {float:left;width:72px;}#yiv4915944323 #yiv4915944323photos div div {border:1px solid #666666;height:62px;overflow:hidden;width:62px;}#yiv4915944323 #yiv4915944323photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv4915944323 #yiv4915944323reco-category {font-size:77%;}#yiv4915944323 #yiv4915944323reco-desc {font-size:77%;}#yiv4915944323 .yiv4915944323replbq {margin:4px;}#yiv4915944323 #yiv4915944323ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv4915944323 #yiv4915944323ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv4915944323 #yiv4915944323ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv4915944323 #yiv4915944323ygrp-mlmsg select, #yiv4915944323 input, #yiv4915944323 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv4915944323 #yiv4915944323ygrp-mlmsg pre, #yiv4915944323 code {font:115% monospace;}#yiv4915944323 #yiv4915944323ygrp-mlmsg * {line-height:1.22em;}#yiv4915944323 #yiv4915944323ygrp-mlmsg #yiv4915944323logo {padding-bottom:10px;}#yiv4915944323 #yiv4915944323ygrp-msg p a {font-family:Verdana;}#yiv4915944323 #yiv4915944323ygrp-msg p#yiv4915944323attach-count span {color:#1E66AE;font-weight:700;}#yiv4915944323 #yiv4915944323ygrp-reco #yiv4915944323reco-head {color:#ff7900;font-weight:700;}#yiv4915944323 #yiv4915944323ygrp-reco {margin-bottom:20px;padding:0px;}#yiv4915944323 #yiv4915944323ygrp-sponsor #yiv4915944323ov li a {font-size:130%;text-decoration:none;}#yiv4915944323 #yiv4915944323ygrp-sponsor #yiv4915944323ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv4915944323 #yiv4915944323ygrp-sponsor #yiv4915944323ov ul {margin:0;padding:0 0 0 8px;}#yiv4915944323 #yiv4915944323ygrp-text {font-family:Georgia;}#yiv4915944323 #yiv4915944323ygrp-text p {margin:0 0 1em 0;}#yiv4915944323 #yiv4915944323ygrp-text tt {font-size:120%;}#yiv4915944323 #yiv4915944323ygrp-vital ul li:last-child {border-right:none !important;}#yiv4915944323


----------

/
* Program to test variable increment speed based on encoder rotation speed.
*
* Dr. jack Purdum, W8TEE
* Dec., 26, 2115, Rel. 1.0
/
#include <rotary.h>
#include <Wire.h>

#define DEBUG 1


#define ELEMENTCOUNT(x) (sizeof(x) / sizeof(x[0])) // A macro that calculates the number
// of elements in an array.

#define ROTARYSWITCHPIN 7

#define DEFAULTINCREMENT 100L // Make it a long since it works with frequency
#define FASTINCREMENT 5000L // Defaullt when we're in a hurry
#define DEFAULTTRIGGER 100L // Normal increment speed

volatile int rotationDirection; // Since in ISR, use volatile to force reload
volatile unsigned char result;
volatile unsigned long startTime, endTime;

Rotary r = Rotary(2, 3); // Instantiate rotary object

int incrementIndex = 0;

static char *incrementStrings[] = {"10", "50", "100", "1", "5", "10", "100"}; // These two allign
static long incrementTable[] = { 10, 50, 100, 1000, 5000, 10000, 100000};

unsigned long frequency = 7000000L; // A pretend frequency
unsigned long increment = DEFAULTINCREMENT; // How much the frequency changes
unsigned long delayTrigger = DEFAULTTRIGGER; // How fast does it have to spin

void setup() {

Serial.begin(115200);
// Not active for testing
pinMode(ROTARYSWITCHPIN, INPUT);
pinMode(ROTARYSWITCHPIN, INPUT_PULLUP); // The switch could be used to change the default increment

PCICR |= (1 << PCIE2); // Set up ISR registers for the routine
PCMSK2 |= (1 << PCINT18) | (1 << PCINT19);
sei(); // Enable interrupts, just in case
rotationDirection = 0;
}


void loop() {
static int state = 1; // 1 because of pull-ups on encoder switch
static int oldState = 1;
static int incrementIndex = 2;

if (rotationDirection != 0 || startTime != 0L) { // Are they tuning?
if (startTime - endTime <= DEFAULTTRIGGER) { // Sre they spinning it fast?
increment = FASTINCREMENT; // Yep
} else {
increment = incrementTable[incrementIndex];
}
switch (rotationDirection) {
case -1: // CCW
frequency -= increment;
break;
case 1: // CW
frequency += increment;
break;
default:
Serial.println("Shouldn't be here. rotationDirection =");
break;
}

Serial.print(rotationDirection); // 1 = CW, -1 = CCW
Serial.print(" ");
Serial.print(startTime); // When did they start tuning
Serial.print(" ");
Serial.print(endTime); // When they stopped
Serial.print(" ");
Serial.print(frequency); // New frequency
Serial.print(" ");
Serial.print(startTime - endTime); // Spin interval
Serial.print(" increment = ");
Serial.println(increment); // Value of increment
endTime = startTime;
startTime = 0L;
rotationDirection = 0;
}

state = digitalRead(ROTARYSWITCHPIN); // See if they pressed encoder switch

// if (state != oldState) { // Only if it's been changed...
if (state == LOW) { // Only if it's been changed...
if (incrementIndex < ELEMENTCOUNT(incrementTable) - 1) { // Adjust the increment size
incrementIndex++;
} else {
incrementIndex = 0; // Wrap around to zero
}

increment = incrementTable[incrementIndex];

Serial.print("*** state = ");
Serial.print(state);
Serial.print(" oldState = ");
Serial.print(oldState);
Serial.print(" CCW to change Small Increment, CW to change Fast Increment:");
Serial.print(" increment: ");
Serial.println(increment);
state = HIGH;
oldState = state;
delay(500);
}
}

/
* Purpose: Interrupt Serice Routine (ISR) to sense turning of rotary encoder
*
* Parameter list:
* PCINT2_vect the external service vector for ISR
*
* Return value:
* N/A
/
ISR(PCINT2_vect) {
// unsigned char result = r.process();

result = r.process(); // Something happened...

switch (result) {
case 0: // No movement now?
rotationDirection = 0;
startTime = 0L;
break;

case DIR_CW:
rotationDirection = 1;
startTime = millis();
break;

case DIR_CCW:
rotationDirection = -1;
startTime = millis();
break;
}
}