Tuesday, September 30, 2014

Minima - Multi-Button Funciton

In previous revisions of my Minima Controller Code, I had used a "table" to lookup and decode the Buttons being pressed.

The buttons are connected together via  identical resistors to form a resistive ladder (see previous post). It was a simple matter of pressing a button, reading the resulting decoded value at the analog port of the ATMEGA328, and then inserting the correct value in the table for that button (Note: some of the current coding details have been left out, see source if necessary).



// ###############################################################################
int btnDown(){
  int val;
  
  val = analogRead(FN_PIN);

  if (val>1000) return 0;
 
  // 47K Pull-up, and 4.7K switch resistors,
  // Val should be approximately = 1024*btnN*4700/(47000+(btnN*4700))
  // N = 0 to Number_of_button - 1

  if (val > 350) return 7;
  if (val > 300) return 6;
  if (val > 250) return 5;
  if (val > 200) return 4;
  if (val > 150) return 3;
  if (val >  50) return 2;
  return 1;

}




That became a little boring, so I decided to replace the table with an algorithm.




// ###############################################################################
int btnDown(){
  int val = 0;

  val = analogRead(FN_PIN);

  if (val>1000) return 0;

  // 47K Pull-up, and 4.7K switch resistors,
  // Val should be approximately = 1024*btnN*4700/(47000+(btnN*4700))
  // N = 0 to Number_of_button - 1

  // 1024L*b*4700L/(47000L+(b*4700L))   >>>  1024*b/(10+b);

  for(int b = MAX_BUTTONS - 1; b >= 0; b--) {
      if(val + 15 > 1024*b/(10+b)) return b+1;
  }
  return 1;
}




The NEW algorithm is smaller, faster and more flexible than the "table", only MAX_BUTTONS need to be change to add/remove new buttons. There is probably a limit to the number of buttons that can reasonably be added to the Resistive/Switch chain, currently I have used eight.

Note: According to ohm's law, with 47K ohm Bias Resistor and 4.7K ohm Switch Resistors, (see previous post) the value read by the ATMEGA should be:

val = 1024 * b * 4700 / (47000 + (b * 4700)); 
 
Where "b" is the button pressed

As long as the Bias and Switch Resistors have a fixed ratio (in this case 10:1), they can be factored-out to leave a much smaller function:

val = 1024 * b / (10 + b);

The biggest disadvantage of using an algorithm is; it can NOT easily be tweaked to solve a resistive tolerance problems - the moral of the story, use good resistors and pay attention to the Bias source for the network and the ATMEGA contained ADC's.


-- Home Page: https://WA0UWH.blogspot.com

Saturday, September 27, 2014

Minima - Proposed Rotary Encoder Circuit

This is just a proposal, the final suggested circuit maybe somewhat different, this is a excerpt, with additions, from a previous post.

My current experimental Encoder software works very smooth with this circuit. Whit a little more testing, it will be published on GitHub soon.

My goal is to be as compatible with the Original Minima as possible.


The following circuit should be added to the Minima to implement a Rotary Encoder and
Multiple Push-Button Switches parallel to the original FN Switch. The original
Tuning POT has been removed to accommodate the Encoder.

--------+
Arduino |
        |
   AVCC |
   pin20|--------+---1K---- +5V
        |        |                       +--------4K7-----+
        |        = 100nF                 |                |
        |        |                       |   +--------+   |
        |        G                       +---|B      C|---+--------------------+
 Tune A2|                              G-----|G  ENC  |                        |
   pin25|--------+---------------------------|A      G|---+                    |
        |        |                           +--------+   |                    |
        |        = 1nF                                    G                    |
        |        |                                                             |
        |        G                                                             |
   AREF |                                                                      |
   pin21|----+-------+                                                         |
        |    |       |                                                         |
        |    |       = 100nF                                                   |
        |    |       |                                                         |
        |    |       G                                                         |
        |   47K                                                                |
        |    |                                                                 |
        |    |                                                                 |
        |    |                                                                 |
    PC3 |    |                                                                 |
   pin26|----+-----+---4K7---+---4K7---+---4K7---+---4K7---+---4K7---+---4K7---+
        |    |     |         |         |         |         |         |         |
        |   FNS    = 1nF     S         S         S         S         S         S
   AGND |    |     |         |         |         |         |         |         |
   pin22|----+-----+---------+---------+---------+---------+---------+---------+
        |    |
--------+    G

            "FN"           "Left"   "Right"   "SBand"     "Up"     "Down"     btn7
           (btn1)          (btn2)    (btn3)   (btn4)     (btn5)    (btn6)    (btn7)


Where:
  4K7 is a 4.7K ohm resistor
  47K is a 47K ohm resistor
  FNS is the original FN switch
    S is a new switch
    = is a capacitor
    G is a ground and AGND
  ENC is the Rotary Encoder with Push Button

Note: The Encoder pins A and B, can be exchanged to reverse the Encoders electrical rotation.

-


More info to follow.

--

Encoder Internals

Just for fun, here are some Rotary Encoder internal details.

Switch Slider and Detent Ball Rotary Switch Mechanism Switch Contacts
Slight Detents can be seen in the edge of the white plastic insulator next to the Detent Ball. The ball is held against the plastic via a spring clip.


-- Home Page: https://WA0UWH.blogspot.com

Friday, September 26, 2014

Minima - With An Encoder

UPDATED: Sep 27, 2014 15:06


An Encoder for the Minima

For the last few days I have been experimenting with three or four implementations to replace the Tuning POT with a Quadrature Encoder (Encoder for short) on the Minima. The implementations range from "Proper" to "Economical". Where "Proper" requires circuit modification and "Most Economical" is 100% compatible with Farhan's original circuit as published. I have experimented and tested each of these solutions, with better than expected results.

The range of solutions each have their pro's and con's.

With exception of adding a simple resistor chain and push-button switches, my overall goals has been to stay compatible (as much as possible) with Farhan's original Minima.

Background
Rotary Encoders

The advantage of a Encoder vs a POT for tuning is that the Encoder does not have "stops" at the extremes, and therefore it is easier to use as re-centering is not necessary.

A typical Encoder internally consists of two switches that turn ON and OFF in sequence when rotated, the sequence can be detected and therefore used to determine the direction of user knob twist.

The switches are connected to Pins Labelled "A" and "B", a third pin "G" is a common to both (normally connect to ground). The switches are normally "open" when the knob is in the detent rest position. Most Encoder also contain a push-button switch labelled "C", which can be used by software to effect mode changes.

Inexpensive ($2 to $5) Encoder are available on Ebay and Electronic Supply houses (Mouser). These inexpensive encoders typically have 16 to 24 detents per knob revolution. Expensive Encoders (>$60) are typically optical and have >200 detents (or pulses) per knob revolution. For the Minima, I suggest the inexpensive Encoders.

I have used Rotary Encoders in several of my previous projects.

Note: for all Encoders, pins "A" and "B" can be connected in reverse to correct direction of rotation.

Now for some proposed implementation details

A Proper Implementation

A "Proper" Encoder circuit requires two (or three, if push-button is used) dedicated I/O line from the microprocessor. At least one of the two lines should be connected to an I/O pin that is configured for Interrupts. When the Encoder is turned, the direction and magnitude can be determined. Software can be written to use this information to change Frequencies, or select Menus, or etc, etc.

Because the original Minima does NOT have extra I/O pin available, modification of the original circuit is necessary to use a "Proper" encoder implementation. To free up some I/O pins, a typical modification include moving the LCD Display to I2C via an inexpensive "BackPack". But this has it own problems, as the Minima currently uses the I2C pins to control the Si570 VFO. The Si570 is a 3.3volt device and the BackPacks are typically a 5.0volt device. The voltage disparity can be alleviated via the addition of a resistor network and/or an I2C Expander (details are not included).

To used this "Proper" configuration, Interrupt Software and Encoder Libraries need to be downloaded and included to be compiled into the Minima Sketch. This included software and libraries uses precious space that could be used for other functionality.

The major advantage is responsiveness of the Encoder and with little or no adverse reaction on other hardware elements. The accumulated magnitude of the interrupts can be used to implement a type of inertia feel, found with normal radio dials.

A Modified Proper Implementation

A modified version of "Proper" implementation is the same as above, except the Interrupt and Encoder Libraries are not used. Software Polling of the Encoder I/O lines is used to get the rotation valuses. On the surface, this may seem unacceptable, but in practice the Sketch's Idle Display Loop is quick enough to display changing digits faster than the eye can see and therefore polling fast enough to be usable.

The disadvantage of this implementation is that Polling is necessary and any stupid delays within the Idle Loop will adversely effect over all performance. Programmed Idle loop delays should be avoided. With polling, magnitude accumulation is slower and therefore it is more difficult to implement an inertia dial feel.

Special code that runs outside of the normal Idle Display Loop has to accommodate Encoder polling. My implementation of Beacons come to mind.

An Economical Implementation

A modified Minima that uses my suggested Resistive Chain Push-button switches can be easily augmented to use an Encoder.

The POT is removed. The "A" pin of the Encoder is connected to the POT's abandoned processor connection (pin A2).  The Encoder's pin "C" (the push-button) is connected across (or replace) button 7.  The Encoder's pin "B" is connected to Encoder pin "C" with a 4.7K ohm resistor.

Note: a better description and diagram will be published later.

This may seem to be a strange configuration, but when the Encoder is being turned, the "FN" button is not typically being used. And, when the "FN" button (or any button) is be pressed the Encoder is not being twisted. Software can detect this and do the right thing.

Experiments, and in practice, has shown that this works very well.

This will probably be my first published implementation. To avoid Interrupt Software and Encoder Libraries, polling software (with its small code space requirement) will be used to detect the Encoder rotation.

The goal will be to eventually publish all implementation with conditional compile flags that the user can select.


The Most Economical Implementation

Farhan's original Minima circuit can be made to work with an Encoder with only slight modification. Similar to above, the POT is removed. The "A" pin of the Encoder is connected to the POT's abandoned processor connection.   The Encoder's pin "C" (the push-button) is connected across the "FN" button.  The Encoder pin "B" pin is connected to Encoder pin "C" with a 4.7K ohm resistor.

This may seem to be a strange configuration, but as stated above, it works.

Software changes are necessary to decode and use this configuration, but the results will be the same as original. Or better yet , the software can be improved to not require re-centering of the dial before reverse tuning can be effected.

Theoretically, an original Minima could be built with only a Display and an Encoder Knob on the face plate, this is because the FN button is contained within the Encoder.

As time permits, and if desired, I may publish this software implementation.

Stay Tuned

More information will follow.


-- Home Page: https://WA0UWH.blogspot.com

Friday, September 19, 2014

Decapping a Small CFPX-5 Crystal

In preparation for building the "Smaller Bandpass Filter" (see previous post), I wanted to see how these very small Crystals are made. The crystals packages CFPX-5 measures 3.2 x 2.5 mm, the actual contained crystal must be very-very small.

I had a spare 16MHz Crystal that was sacrificed to satisfy my curiosity.  I removed the lid by grinding away the at the edges.

3.2 x 2.5 mm 16MHz Crystal
For scale, the edge of a Dime is shown.

The photo shows the small crystal chip inside of a cavity supported by two gold plated corners on two gold rounded mounds. The electrical connection appears to be just a gold-on-gold contact, with a dab of silicone on each terminal for shock mount. The other end is free floating without support.
3.3 x 2.5 mm 16MHz Crystal
In my efforts to DECAP the lid, I broke the crystal, as can be seen in the photo, the crack runs from upper right to lower mid. On inspection of the edge of the fracture, the crystal appear to be thick in the middle and thin on the edges. Perhaps etching is used to adjust to published tolerance.

I an not sure that I can expect much from these when used is a multiple crystal Bandpass Filter, but it will be a fun experiment. I expect too much drive level will be the biggest concern. As per Farhan's original circuit, I will use 8 of these to build the filter.

--

Thursday, September 11, 2014

Minima - Smaller Bandpass Filter

OK, ok, . . . I have NOT finished my Minima Audio Modules yet,  . . . What am I doing designing another RF circuit?

Well, I like RF circuits, and not so much for Audio Circuits. As I have stated before, the audio Capacitors are too big for my liking and building interests.

This new RF circuit is a Trial Bandpass Filter using very-VERY small crystals (2x2.5mm). I know, small SMT crystals may not perform well as a Bandpass Filter, but I could not pass up the chance to experiment with them.

My first Minima Bandpass Filter is 1x2 inches (2 sq inches).

My Original Minima Bandpass Filter Module
The new Filter will only be 0.8x1 inches (0.8 sq inch).
New Smaller Bandpass Filter
About 2.5 times smaller than the Original
The boards are on order from OshPark.com, three boards will only be $4.00.

I am not sure this will work well for the Minima Bandpass Filter, but it will be a fun experiment and, I really enjoy small projects.


-- Home Page: https://WA0UWH.blogspot.com

Monday, September 8, 2014

Minima - Wayne's Build

Sunday I had a chance to work with Jeff - KO7M via Skype for a few hours. He has the loan of Wayne's (NB6M) Minima Transceiver for a few weeks while Wayne is on vacation - Thanks Wayne.

A large part of the discussion was about "How to Use Git and GitHub" for software development.

Wayne's Mimima
Afterwards, we decided to try to update Wayne's Minima to my latest Alternate Tuning Method transceiver control code. Wayne had previously downloaded and was using a much older copy of my code. The older copy did NOT have many of the NEW and current features and functions. Our goal was to exercise these new features on Wayne's hardware.

When we first downloaded my NEW Revision, Wayne's Minima went NUTS, with a loud Buzzing sound on all frequencies.

We reinstalled the old software and the Buzz went away.

Something that I had done over the last few weeks has made my software almost useless. With a little work, and via the process of elimination (removing sections of code), Jeff was able to track down the offending routine.

I had inappropriately moved two of the PTT Pin Initialization Statements to within the main TX/RX Idle Loop. This pin is also used to control the TX/RX relay. Rapid re-initialization of the PTT pin was producing hash that the receiver was picking up. Removing the two nu-necessary and redundant statements solved the problem. Initialization of the PTT pin is now done between Receive and Transmit and then when switched back.

The GitHub copy has now been updated.

While we had Wayne's Minima NOW working so well with the new updated code, I wanted to exercise each of the new functions. Wayne does not yet have a "seventh" push button installed, and therefore we had to use a jumper wire as a switch to access some of the functions. For the full list of new functions that I have added to Farhan's original Minima code, see Link. Everything worked better than expected - I am a Happy Camper.

One of my main interest was to see how well the CW ID and MACRO's worked, and how well the QRSS Beacon worked. They actually worked much better than expected!!

The Non-Volatile Save and Load of User Memories worked as expected. Dial Calibration for both USB and LSB was an easy task.

Over the next few weeks, Jeff will be introducing some new hardware support and functionality for the Minima. He has plans for multiple Si570's (VFO and BFO), other I2C Displays and more. See his blog at: http://ko7m.blogspot.com/search/label/Minima.

Contributing to the Minima Hardware and Software has been a very rewarding and interesting project, . . . Thanks, Farhan.


-- Home Page: https://WA0UWH.blogspot.com