09 April 2024

ADC. Rezolutii si Volti

ADC-urile convertesc eșantioanele unui semnal analogic în valori digitale.

RezoluÈ›ia ADC-ului este numărul de biÈ›i pe care îl utilizează în vederea digitizării eÈ™antioanelor de intrare. 

Pentru un ADC pe n biÈ›i, numărul de niveluri digitale discrete care pot fi produse este 2n. 

Astfel, un digitizor pe 12 biÈ›i poate rezolva 212 sau 4096 niveluri. 

Cel mai puÈ›in semnificativ bit (lsb) reprezintă cel mai mic interval care poate fi detectat È™i, în cazul unui digitizor pe 12 biÈ›i, este 1/4096 sau 2,4 x 10-4. 

Pentru a converti lsb într-o tensiune, luăm intervalul de intrare al digitizorului și îl împărțim la doi, ridicat la rezoluția digitizorului.

27 March 2024

VFO Encoder selection for Xiegu G90

From time to time someone start searching for part number of the VFO encoder.

Here is a selection of part numbers for encoders without detent (no clicks) and with detents (like the original one).

A NOTE FROM  PA2HJK, received by e-mail:

Hello Adrian, 

Thank you for all the information about the Xiegu G90.  I used it to replace my VFO encoder but I had to reverse the outer connections  ( of the 3 pins side) of the encoder. The switch worked fine but the rotation was inversed. I have tried several encoders from Bourns and ALPS but they where all reversed.

Maybe you can add this information to your website to help other Hams.
 

73’s  Harm Jan  PA2HJK

 

An email exchange with Paul VE7NRI showed the same problem. 

A note based on IV3TEK Luca emails and practical experience:

 



On the left is the broken original encoder while in the right side is the Bourns replacement 
PEC11R-4120K-S0018.

While PEC11R-4120K-S0018 have knurled shaft, it is slightly longer than the original Chinese encoder as seend in the picture above.

 

Luca made a PVC disk to compensate for that:

If keeping the original knob is not mandatory, a flatted shaft will have the same lenght.

Thank you Luca for the detailed feedback! 


 

 

 A NOTE FROM ME:

When I searched for the proper replacement I assumed that Xiegu G90 use standard phase in it's rotary encoders and focused on dimensions and mechanichal criterias; never imagined that they are not delivering the same way. 

Therefore, it is necessary to cross the terminals (small pieces of wire) for the below encoders in order for it to function properly.

 Taken the above into account, you must cross the pins to match the rotation of the new encoder with the result of the VFO or to search for the cheap Chinese-made replacements.

To match the desire of the user, ICOM use a lever to "add" detents to some of their radios. When using in mobile, detents may be convenient while using it stationary, no detents might be the choice.

There are a lot of manufacturers that make cheap PC11 type encoder but the reliability is not very good; while they can be used in home-made projects, in the radio a more sturdy one is needed. 

Also, they might fail and most hams try to find a faster way to repair the radio than to send it back to China and wait a few months.

Therefore, here are a few options for those "brave hams" that will take the things into their hands and will repair the radio by themselves.

As a personal observation, with more than 18 pulses per revolution it is a pain to use a no detents encoder...


From BOURNS:


No detens:

PEC11R-4020K-S0018 with knurled shaft, 20mm lenght, no detents, momentary switch and 18 pulses per revolution.

PEC11R-4025F-S0018 with flatted shaft. From ALPS, EC11E, 20mm long flatted shaft (only) momentary switch.

With  detents:

PEC11R-4120K-S0018 - 20mm long shaft, knurled (4120F for flatted shaft), momentary switch.

PEC11R-4125K-S0018 - 25mm long shaft, knurled (4125F for flatted shaft), momentary switch.

 

From ALPS: 


No detents:

EC11E153440D with 15 pulses per revolution. Flatted shaft. 20mm long, momentary switch.

EC11E18344OC with 18 pulses per revolution. Flatted shaft. 20mm long, momentary switch.

With detents:

EC11E18244AU with 32 detents, 18 pulses per revolution. Flatted shaft. 20mm long, momentary switch.

EC11E15244B2  with 30 detents, 15 pulses per revolution. Flatted shaft. 20mm long, momentary switch.

 

Serrated (knurled). Please check the dimensions of the shaft for proper selection of the knob.


Without detent:

EC11G1574402 - 15 pulses per revolution, momentary switch.

With detent:

EC11G1564411 - 30 detents, 15 pulses per revolution, momentary switch.


For both producers I reccomend study their product selection datasheets which can be downloaded as pdf clicking on their names.

The pinout of the above encoders is compatible with the one in the radio.

I usually like to have longer shafts and cut them to my needs so, if you want a shorter one, just check the datasheets for the part number. 

Both manufacturers are producing compatible encoders for VFO, VOL and FUNCTION. 

 

23 March 2024

Simplyfying the code by using a tic-tac machine

Playing with Arduino and it's C++ I often use timed tasks.

Basically, in Arduino you can do things at specific interval either by adding delay() at some strategic points or using wellknown non-blocking code:

const unsigned long interval = 1000; // Interval for LED blink (in milliseconds)
unsigned long previousMillis = 0;    // Variable to store time since last LED update

int ledPin = 13; // Pin for the LED

void setup() {
                    pinMode(ledPin, OUTPUT); // Initialize LED pin as an output
  }

void loop() {

                  unsigned long currentMillis = millis(); // Get the current time

  // Check if it's time to update the LED
  if (currentMillis - previousMillis >= interval) {
                    previousMillis = currentMillis; // Save the last time LED was updated
                    digitalWrite(ledPin, !digitalRead(ledPin)); // Toggle the LED state
          }

      // Other non-blocking tasks can be added here
}
 
What if, the code need more than one timer?
Well, we  can use multiple timers like that!
While this is the simple and easy way, in a big code we start loosing track of what does what and if the code is big, each byte counts! Let's not forget that  each unsigned long type variable cost us 4 bytes of precious memory; each byte consists of 8 bits, and an unsigned long on Arduino is a 32-bit data type, so it occupies 4 bytes (32 bits / 8 bits per byte = 4 bytes).
I have a program in which I have to test multiple timers with multiple distinct intervals and the memory cost was huge.
So, I stayed and think and found a very elegant solution.
While I may reinvented the wheel, I think it is nice to share it with you!
It is all about making a single time measuring function and asign boolean variables to keep track of various things.
  unsigned long previousMillis_ONESECOND = 0; // Variable to store the last time the ONESECOND was flipped
  const unsigned long interval_ONESECOND = 1000; // Interval at which to flip the ONESECOND (in milliseconds)
    bool ONESECOND = false;

void loop(){
    updateONESECOND(); }

void updateONESECOND(){
          unsigned long currentMillis = millis(); // Get the current time
 
          // Check if it's time to flip ONESECOND
          if (currentMillis - previousMillis_ONESECOND >= interval_ONESECOND) {
            // Save the last time ONESECOND was flipped
            previousMillis_ONESECOND = currentMillis;

           // Flip ONESECOND
            ONESECOND = !ONESECOND;
      }
}
then, I have other functions that check various conditions AND bool.
For example, a function that blink a special character on a LCD: 
 
bool ProcessSTART = false;
 
void fLCD(){  // alternate symbol at a rate of one second while StartLog is activated
            if (ONESECOND && ProcessSTART){
                     printFN_Char();
                            }
                else {
                     printFP_Char();
                }
}

the other bool ProcessSART is flipped in other part of the program.
In other functions you can count the number of seconds using this tic-tac function and get other intervals derived from it, using less bytes in a simple arithmetic function.
It's like using an external time generator for all the functions in the code.

Most viewed posts in last 30 days