Thursday, January 17, 2019

Holidays over, Getting back to projects

The holidays are over and I am back home from visiting family.  So it is about time to get back to some of my projects.  I am going to start the year with a update to my SNA Jr.   I had started it previously, and ran into problems with my original design.  After looking around the net I found two different designs that have some of the options I want to include in my design.  One is the Antenna Analyzer by IW2NDH and other the SI5351 Network Analyzer by UR5FFR. With a lot of help from Google Translate I was able to get all the information I wanted from their documents.  

My new design will include much of the circuitry from their projects, along with some of the things I developed while working on the 'Test Gadget'.  My earlier design used an Arduino Nano as the processor, but I found I needed more program and storage memory.  This design will use a ESP32 development module, along with a 320 x 240 TFT display.  I will also use a small Joystick instead of a rotary encoder for the user input.  Before the holidays I designed a PCB board and sent it off to one of the Chinese board houses that I have been using recently.  The board arrived shortly after I returned home, and I started building up one so I can test it in sections.

One of the things I want is that the instrument will run off of an internal battery.  In the earlier version of the SNA, I used a pair of 18650 lipo batteries with a separate charge controller board.  This gave me around 7-8 volts that I could feed to a 5 volt regulator on the main SNA board.  I recently found a lipo module that has a built in holder for a 18650 battery, a charge controller,  boost converter and regulators that gives 5 and 3 volts regulated out.  One of these should power the new SNA  board with the ESP32 without having to include a regulator on board.  But,  just in case it does not work out I did include a 5V regulator on the circuit board.

After I got all the major parts in, I could design a case for everything to fit in.  What I really like about having the 3D printer is the ability to design a case to exactly fit the project.  Along with the proper holes for controls and displays, I can also design in all the mounting posts and standoffs for all the major components.  It might take a couple tries to get everything to fir the way I want them.  But it usually costs less than a dollar in plastic to print a part in draft quality.  When everything is the way you want it, print in higher resolution.  
It took a couple tries to get everything exactly the way I wanted, but finally printed the top and have all the parts mounted.  Just need to finish wiring everything up.  Using one of the early attempts as a mounting platform to use while working on the software. The case I have now is in regular PLA, but I have some Carbon Fiber filled filament that I might try.  It should add some RF shielding, but don't know if it will help in the HF range or just at VHF and UHF frequencies. The way I designed the clam-shell case, the top and bottom are symmetrical.  When I get around to designing the bottom half, all I have to do is remove the existing cutouts and mounting posts and replace them with the posts needed for the SNA circuit board itself.



Monday, December 17, 2018

Getting ready for the holidays

I have not been doing much with actual electronics for the last month or so.  Made a big mistake and took a look at Thingiverse.com to try and find a model for something some storage containers for some of my SMD parts.  Well I found them and also several things that I want to make for family for Christmas.  Since then I have been spending most of my time printing parts and putting things together.

I did do a little design and printing related to electronics projects based on a question from Chuck K7QO in the qrp-tech group. He was wondering about 3D printing a Tuning Dial Bezel for small projects, and listed a couple of examples.  I did a set of quick designs and finally got around to printing them.

 One is for a dial mounted on the front of the cabinet, and the other is for a rear mounted dial.
The rear mounted one is about 50 x 60 mm. and I designed for use with a tuning dial around 1.5" diamater.

 
The one for a front mount dial is about 50 x 70 mm and 4 mm deep to provide room for the dial pointer to fit between it and the face.  I made two different dial pointers, one to slip over a .25" dia. shaft.  The other should fit on a vernier drive if used.  I do not have a drive to test it with but going from some pictures I found it should fit some of them at least.
Both designs look like the would nice on a small QRP transceiver.




I did do a couple circuit board layouts for 'test gadgets' and have them on order from China.  Since I will not get around to doing anything with them, I  ordered delivery by slow boat.  They should be here when I get back from visiting family for the holidays. 

A week ago we had the Christmas Lunch for the North Georgia QRP Club.  We had  a very nice turn out.  It was great to see everyone together again.

All the festivities made me want to go and listen to my all time favorite Christmas song.

https://www.youtube.com/watch?v=BmKzZRyzV6w

I guess this is it for now. See you all next year and everyone have a Wonderful Winter Solstice.






Wednesday, October 3, 2018

Audio Test Gadget

While I was waiting on some parts and a set of boards to come in from China, I decided to try making an audio frequency test gadget.
Since I had some of what I wanted to do already done for a Nano, I will see if I can quickly port that over to the Nano Test Gadget mother board.  The mother board is set up for a I2C LCD that I quickly replaced with a 1.3" OLED  display that is also I2C.   Only software required is a driver library from Adafruit, and their graphics library.  This is small but its 128 x 64 pixel display gives fairly good resolution for displaying things like a simulated analog meter and a simple AF spectrum analyzer.  These are things that I have already working on a pro-mini as a stand alone simulated analog meter for a transceiver.

The upper limit for the spectrum analyzer software with this display is about 4Kkz.  which is fine for the audio frequencies usually found in normal HF transceivers.  With that in mind I decided to limit the display range and the tone generator to 4500 Hz.  Using an Arduino tone library, I wrote a small function to generate tones from 50 to 4500 Hz.  This is a square wave output, so I will have to calculate the values for a low pass filter to make the output appear to be more of a sine wave. 


 A function similar to what I used in other projects is used to display the frequency set the value sent to the tone() function. To make it a little easier I just chose 50Hz. as the step size as a compromise between speed and resolution.

Next thing I waned was a AC voltmeter with a frequency response up to 4.5 KHz. at least.  I found some code from Adafruit  for a sound level meter and used  part of that to get the peak to peak value of the AC signal.  This code samples the input pin for  50 ms. and finds the highest and lowest values and uses the difference as the peak to peak value.  After I had it working I checked the values compared to that of a scope over the desired 4.5 KHz. frequency range and found it to be very accurate.

unsigned int  getACVolts( char inputPin) {
#define sampleWindow  50  //  50 ms  20 Hz. sample rate 
  unsigned long startMillis = millis();  // start of sample window
  unsigned int PeaktoPeak = 0;          // peak-to-peak level
  unsigned int SignalMax = 0;
  unsigned int SignalMin = 1024;
  while ( millis() - startMillis < sampleWindow ) {
    sample = analogRead( inputPin);
    if (sample < 1024) {
      if (sample > SignalMax) {
        SignalMax = sample;                                
// saves just the max levels
      }
      else if (sample < SignalMin) {
        SignalMin = sample;                               
// saves just the min levels
      }
    }
  }
  PeaktoPeak = SignalMax - SignalMin;                      
// max - min = peak-peak amplitude
  return  PeaktoPeak ;

}


Since most of what I work on has a peak to peak value of less than 5 volts I am going with a single range for now.  I could easily switch between the 5 volt reference and the 1.1 volt internal reference for the ADC If I want a more sensitive range,
I decided to just use a current limiting  resistor and forget about a voltage divider for the input.  After getting the p-p value from the ADC, I used that as the value  to find the position of the needle on the simulated display.  This is the same code I have used in several projects detailed in earlier Blog posts.  I decided to convert this to rms for the display scale, and also a digital display on the meter face.  


While I was working on the simulated analog meter for a Bitx, I added some code to do a audio frequency spectrum analyzer display.  While I found this would be mostly useless for a transceiver, it will fit in nicely with this test gadget.  


The code ported over very easily, and after adding a rough frequency scale to the display I was very pleased with the result.  Using the simple menu system I have used on most of my recent projects, I wrapped these up into a fairly simple multifunction test gadget for working with audio frequency circuits.  One thing I did find while trying to get this working is that the combination of the OLED display with its screen buffer stored in the Arduino RAM and the buffers used by the FFT, I quickly started to run out of memory.   It took quite a bit of playing to get every thing to play well together.  But now I can set a frequency on the tone generator and read it with either the voltmeter or the spectrum analyzer.

I have a little work to do on the hardware before this is finished, but it is coming along nicely so far.  The other day I saw a article on a
small Arduino based oscilloscope.  Just thinking about seeing if I can cram another function into this test gadget.

Wednesday, September 5, 2018

CWTD.ORG Test Gadget mother boards

In the last CWTD.org podcast, we discussed 3 possible implementations of a standard 'Test Gadget' platform.  There seems to be a desire for a basic platform using a Nano and another more powerful version using either a Teensy or a ESP32.  One thing that is needed to be standardized is a common 'bus' configuration for the 'gadget' modules.  My original 'test gadget' platform, had started out as a test bed for evaluating the ESP32 as the primary processor I will use for some of my upcoming projects.  Later, after I saw the CWTD project I started building modules along that line.

Since I had a circuit board layout that would be workable with a few changes, I decided to modify it slightly.  This will bring out most of the available pins, that could be configured to closely match those available if using an Arduino Nano.  I came up with two board layouts and ordered 10 of each from a Chinese board house that I have been using for some time now.  After they arrived I started putting together the Nano version.  


Because of the memory available and processing power of the Nano, I decided to only have two connectors for the 'gadgets'. Everything is pretty standard for a simple Nano project, except that I added a separate 3.3 volt regulator instead of using the 3.3 volts from the Nano.  On the Nano the 3.3 volts is provided by the USB serial converter, and has limited current capability. The ESP32 is a 3.3 volt only processor, so I will power some of the 'gadgets' directly from 3.3 volts.  Since I want to be able to swap 'gadgets' between the Nano and the ESP32 system,  I added the additional regulator to take care of any 'gadgets' that need a hefty 3.3 volt supply.  The board has a connector that brings out the I2C signals and power for a I2C LCD display, could also be used with a small I2C OLED display if limited graphics are desired.  I also have pads for directly mounting a rotary encoder on the board.

While I was waiting for the boards to arrive, I had designed a case to hold the 'gadget rack' main frame.  And set my great new 3D printer to getting a home ready for the boards when they arrive.
It took a couple tries to get everything fitting the way I want them, but well worth the effort.  That is the thing I really love about using a 3D printer, the ability to make something that fits your project exactly, not just something you had to cobble up to make things kind of fit.

When I assembled the board I decided to mount the 'gadget' header connector on the side by the Rotary Encoder flush with the board instead of vertical like the other side.  This makes it easier to use the encoder, and allows any 'gadget' to be plugged in on either side without having to wire them up for a specific side.  

One thing I found was that the only I2C LCD display I had on hand was only a 8 x 1 display.  It worked for the initial test but have a couple 16x2 on order.  Now to get started on putting together the ESP32 version and then building a couple 'gadgets' to check them out with.

Monday, August 6, 2018

SI5351 Signal Generator Test Gadget

I have been spending way too much time playing with the new 3D printer, so have to get back to some electronics.  Since the next CWTD.ORG episode is coming up, I decided to build another 'Test Gadget'.  This time it is a Signal Generator based on the SI5351 clock generator.  I had purchased a couple Chinese versions of the Adafruit 5351 module when I was working on the 'Sweeperino Jr. ' and wanted to see how  well they worked.  


This time I decided to mount the board vertical and only use half of the connections.  Since the module only uses power and the I2C bus this made construction very easy.  And, only using one set of connector pins makes connecting the board much easier.  And also left plenty of room to mount an AD8307 log detector, so I can later use it as a SNA or Wattmeter.

For the software I decided to use some in-line code instead of one of the libraries that are available.  I grabbed the SI5351 code from the uBITX by Jerry , KE7ER , and only had to make a couple minor changes to get it to work as a 3 channel signal generator.  This was just removing a couple things that are specific to the uBITX. This code limits the frequency range from .5 to  just over 100 MHz., but that covers everything I am interested in.  The range can be lowered by a changing a value if desired, but you will have to change that value back to get the higher range again.

The use of a Joystick makes frequency selection very easy.  A horizontal movement changes the increment, while a vertical movement increments or decrements the frequency.  A test of the increment value being changed, sets the color/background of the frequency display for that column.  This makes frequency changes very fast.  A short press on the Joystick button toggles through the three channels and a long press brings you back to the main menu. The code is mainly contained in a while loop , with a couple support functions to 
display the frequency, or display frequency being edited.

 boolean   siggen = true;
 while (siggen) {
    ReadJoyStick();
    if (jstickH < 0) {
      increment = increment * 10;
      if (increment > 10000000) increment = 10000000;
      jstick = false;
    }
    if (jstickH > 0) {
      increment = increment / 10;
      if (increment < 1)increment = 1;
      jstick = false;
    }
    if (jstickV > 0) {
      if (freq + increment > 99999999)
        freq = 99999999;
      else freq = freq + increment;
      freqChn[si5351_ActiveChn ] = freq ;
      si5351bx_setfreq(si5351_ActiveChn,  freq );
      jstick = false;
    }
    if (jstickV < 0) {
      if (freq - increment < 0)
        freq = 0;
      else freq = freq - increment;
      freqChn[si5351_ActiveChn ] = freq ;
      si5351bx_setfreq(si5351_ActiveChn, freq );
      jstick = false;
    }
    if (jstickSW == ShortPress) {
      jstick = false;
      freqChn[si5351_ActiveChn ] = freq ;
      si5351_ActiveChn ++;
      if ( si5351_ActiveChn > 2)si5351_ActiveChn = 0;
      freq = freqChn[si5351_ActiveChn ];
      DrawSigGenScreen();
    }
    if (jstickSW == LongPress) {
      jstick = false;
      siggen = false;
    }
    ypos = 60 + (si5351_ActiveChn * 38);
    tft.setCursor(80, ypos - 10);
    edit_Freq(freq);
    jstick = false;

  }

With the signal generator working, next I want to add an 8307 log amplifier to the board.  I have several circuit boards left from a stand alone AD8307 power meter I did for an article in QQ.  I plan on cutting just the isolated power meter circuit out of this board and attaching it to the test gadget board.  Should be a very easy way to add  power meter functionality to the test gadget.  I will probably write software for use as a Wattmeter, with  a 40 dB. tap to get from the milliwatt range up to around the 100 watts. Also thinking about building a simple high impedance probe to use for in-circuit testing.
After that I can use the nice 320x240 display for a SNA.

Friday, July 20, 2018

A new 3D printer- getting back to the uBITX

Since I had not followed my own advise after I got my first 3D printer.  Who doesn't need another hobby!  
I had planned on building a larger printer for some of the projects I have planned.  For this printer I ordered a set of motors and electronics through one of the Chinese suppliers.  After waiting more than the estimated time for delivery, I contacted the seller and received a full refund.  That left me with the decision, order another set from a different supplier or look for a completed printer the size I wanted in a reasonable price range. 


After watching a YouTube video by my favorite 'Cyborg', Naomi Wu building the new Creality 'Ender 3' 3D printer.  I checked several other videos that showed the assembly and operation of this printer.  Reviews were mostly very positive, and it had the specifications I was looking for.  From a e-mail flyer I found that Gearbest had them on sale for less than $210 including shipping, so I placed a order. Gearbest now has a warehouse in the US, it only took about a week and a half for it to arrive.

Since I had watched several videos on the assembly, it only took about a hour to get it put together and check the alignment.  The first print was the test file that came on the included SD card, the print quality was very nice.  After that I visited Thingiverse.com and grabbed some of the accessories such as a fan cover and accessory tray that have been created for the 'Ender 3'.  They all turned out quite well, even though I was playing with the slicer settings as I went along.

After I finished them, it was time to get back to what I wanted a larger printer for in the first place.  Printing a case for the uBITX, I modified my standard 'clam shell' case design for the size I desired and added a set of mounting posts for the uBITX circuit board.  Since I was still playing with some of the slicer settings, I printed the piece at a quite slow speed.  So after about 14 hours I had the bottom half of a case for my uBITX.  Print quality was fine for what I wanted for the case, but I can still tweek the settings to get even better results. And since this was printed with some generic brand filament I got for $12 a kilogram, I don't know how much that had to do with the minor finish issues I found.  The size of the case at 200 x 190 mm takes most of the 230 x 230 mm print area of the printer.  I am quite pleased with this printer, and do not think it would be a bad choice for those wanting to try 3D printing without investing a lot of money.






Friday, July 6, 2018

DC Voltmeter Test Gadget UPDATE 7/14/2018

Now that I have the basic display and menu routines working on the ESP32 Test Gadget main frame, it is time to build an actual 'Test Gadget'.  The  cwtd.org version started with a simple DC voltmeter, so that sounds like a good place for me to start.  I could use a simple Analog input pin on the ESP32 to use for the voltmeter, but I wanted more than one channel and also a higher input impedance .  This would require a input buffer amplifier on each channel along with some switching to provide several full scale ranges. 
I have several ADS1115 16 bit four channel ADC modules that I got to use to add additional analog inputs to a uBITX.  They are a very small module that uses I2C to communicate with the processor. This module is also available in a 12 bit version called the ADS1015, and there is a library from Adafruit.  They have the capability of being used as four single ended or two differential channels,and also have a programmable gain amplifier that can be used to set the input range.  Although they are listed as 16 bit input, one of the bits is used to indicate the sign if used in the differential mode.  Therefor the actual resolution is actually 15 bit.   
The programmable  amplifier has ranges that give +- .25 to +-6.25 volt full scale.  The multiplexer has built in protection diodes from each input to VCC, which limits the maximum signal to about .3 volt over  the VCC voltage.  Powering the module from 3.3 volts, this means I will need to use a voltage divider to raise the maximum voltage that can be measured.  Unlike the 10 K ohm input on the ESP32 or a Nano analog pins, the ADS1115 has an input impedance of several Meg ohms.  This means I can use a voltage divider that will give me an impedance in the Meg ohm range.   I have some 100K and 1 Meg. 1% resistors, so I will use them to give a 1.1 Meg. input divide by 11 voltage divider.  If I just wanted a digital readout, the resolution is good enough for better than 1mV. , but since I also wanted simulated analog meters I will use the programmable amplifier to get several ranges. With this divider and the programmable amplifier I can get full scale ranges of  a little over 5.5 , 11, and 22 volt ranges, with a maximum safe input voltage around 33 volts.

The first thing I did was to connect the module  to one set of the 'Test Gadget' connectors using a wireless breadboard.  I loaded a version of the Arduino 'I2C Scanner' and checked to see that the module was found and its base address.  After I verified that the I2C communications was working, I loaded one of the example programs that came with the Adafruit ADS1015 library. This just read each channel and output its value to the serial monitor.  The only issue I found so far was that there was a little DC off set from zero with the voltage divider, but it is only about 1 mV.  I will do a little more testing to see how consistant it is, but I can probably just add an offset in the software to correct for that.  If I can just do a simple fixed value, or have to add a 'Zero' option to the manu is still to be determained.

I already had the analog meter code written, so the next thing I started working on was a menu to allow me to change display type, number of channels,and range.  The use of a Joystick makes selecting and changing settings very easy.  A vertical  movement selects a different menu item, while a horizontal movement makes changes to the selected menu item.  Here is part of the menu code to show what I mean.

   if (jstickV ) {    // vertical movement selects menu item
        mnuDCVMSel += jstickV ;
        if ( mnuDCVMSel < 0)  mnuDCVMSel = 0;
        if (mnuDCVMSel >= mnuDCVMNum )  mnuDCVMSel = mnuDCVMNum;
        showDCVMMenuItems();
      }
     
   // horizontal movement makes changes to selected menu item    if (jstickH ) {
      // for values that toggle simple if statements are used   
      // change between analog and digital display of voltage
         if (mnuDCVMSel == 0) {  // select analog or digital 
          if (mnuDCVMItems[0] == " Analog     ")
            mnuDCVMItems[0] = " Digital    ";
          else mnuDCVMItems[0] = " Analog     ";
         showDCVMMenuItems();
         jstick = false;
        }
        // for multiple options I use a switch(value)- case to
        // make the selection
        if (mnuDCVMSel == 1) { // select number channels to read
          numChan += jstickH;
          if ( numChan > 4) numChan = 4;  // set limits on value
          if ( numChan < 1) numChan = 1;
          switch (numChan) {   // update menu item display
            case 1:
              mnuDCVMItems[1] = " Chan. = 1  ";
              break;
            case 2:
              mnuDCVMItems[1] = " Chan. = 2  ";
              break;
            case 3:
              mnuDCVMItems[1] = " Chan. = 3  ";
              break;
            case 4:
              mnuDCVMItems[1] = " Chan. = 4  ";
              break;
          }
          showDCVMMenuItems();
          jstick = false;
        }

 Similar code is used to select and modify any additional menu options.

In operation a 'ShortPress' on the Joystick switch brings up the menu, and after selections are completed another 'ShortPress' exits the menu and redraws the screen.  This looks similar  to a 'pop up' menu on a Windows or Linux system with out much of the overhead associated with a full menu system.   

After doing some playing around, I have decided I will not use the programmable gain amplifier for range selection.  A fixed gain will give me more resolution than I need for a 1 mV. display resolution. I will instead work on creating a auto range system for the 'Analog' style meter.  Hope to update soon.
UPDATE 7/14/2018

I wired up the small adc module on a 4x6 cm proto boar and made a quick 4 channel cable with test clips for normal use.  Everything works as expected, except for a little |DC offset from ground.  Since it was consistent across all channels, I decided to just take care of it in software.  If it would have been  significantly different for each channel I would have added a DC zero function to the pop-up menu.  I decided to have a digital display of the voltage along with the simulated analog meter.  Because of this I kept the manual scaling I had originally tried, maybe some  day I will write something to do auto scaling for each individual channel.
The picture shows the completed DCVM test gadget in 4 channel mode measuring the 3 voltages present on the headers used to connect the individual test gadgets.  I was running this off of the PC without the 12 volts connected for external power, so I kept the range down to 5 volts.