Skip to main content

Arduinos embedded within Homebrew Test Equipment ~ N6QW

More uses for the Arduino -- Test Equipment

There is always something on the bench! While I await some critical antenna parts still to come and a few parts I need for the two SSB transceivers, I thought I would turn my attention back to some investigations with the Arduino Nano coupled with TFT Color Displays.
 
I am amazed at how many sophisticated homebrew measuring devices  (many fitting in Altoids tins) are showing up in YouTube videos and on websites. Among these are Scalar Network Analyzers, Digital SWR Bridges, Audio Test Equipment and on and on.
 
In some of my own efforts I figured out how to add a moving bar S Meter to the bottom of a color display so that up until S9 the bar was one color and beyond S9 another color. Thinking that was pretty cool my attention turned to how would you add real time plots to a color display such as you might have in checking out a homebrew crystal filter (I know this is what a SNA does). But I wanted to see what makes things tick.
 
So my first thought was how to display a Sine Wave. We have two variables X and Y, where we can represent that y = sin(x). Fortunately the Arduino has built in math functions and so it is a simple matter to set a range of values for X and then have the Arduino calculate the Y values. Along the way we can add some axis' (ordinate and abscissa) and plot centerline.
 
As usual I thought all you needed to do was to set up the Arduino for the color display and write a couple of math equations and you are there. WRONG!!!!!! It took me nearly two days to figure out how to display a simple sine wave. You can see that below.
 
The problems I ran into was that I specified 320 points (width of the display)  for x starting at point x =14 so that it would fit within the axis. Well that netted multiple traces. By trial and error I found that if you only used  "x" at every 5 points that you got the plot below. Anything more or less gave a screwed up plot --Inexplicable is a really good word. Since the top of the display is considered y = 0 you must offset every value by + 120 (1/2 of 240 which is the number of vertical blocks) to place the plot in the middle of the screen. So then I thought this plot consists of rectangle data points, what does it take to "connect the dots" with lines. That never did work BUT I was able to create a plot similar to what you might see in a "two tone audio test" which is shown in the second photo. Below that is the sketch wherein I used Arduino 1.0.5 -- I do have 1.6.3 on a different machine.
 
So email me any thoughts or suggestions. If you know what you are doing, it is probably a pretty simple thing to homebrew your own test equipment --unfortunately I don't know what I am doing!!!!
 
Pete N6QW
 
 
 
 
This is the code I am using (it is OK to laugh).
 
 
/* From N6QW using the 240 X 320 TFT Color display
This is to test displating graphical information such as you would have with test instruments
*/
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <TFT_ILI9340.h>
#if defined(__SAM3X8E__)
#undef __FlashStringHelper::F(string_literal)
#define F(string_literal) string_literal
#endif
#define __CS 10
#define __DC 9
#define __RST 8
// Color definitions
#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0 
#define WHITE   0xFFFF
TFT_ILI9340 tft = TFT_ILI9340(__CS, __DC, __RST);
#include "Wire.h"
int val = 0;
int val1 = 0;
int x = 0;
int y = 0;
int old_val = 0;
int old_val1 = 0;
void setup() {
 
 
  tft.begin();
  #if defined(__MK20DX128__) || defined(__MK20DX256__)
  tft.setBitrate(24000000);
  #endif
        tft.fillScreen(0x07F0); // testing switching background colors
        tft.fillScreen(WHITE); // 0x07F0 = lt green, 0xF810 = rose, 0xF840 = rust, 0xF820 = orange
        tft.setRotation(1); // landsacape versus portrait
       
       
        tft.drawLine(14,0,14,230, BLACK); //X axiz
        tft.drawLine (14,230, 300, 230, BLACK); // Y axis
        tft.drawRect( 14, 118, 300, 2, GREEN); //centerline of plot & the 2 is the width of the rectangle --makes it look like a FAT line
   
 
}
void loop()
    
{   
 
 for(int x = 5; x <320; x++){ //sets the range of values to plot along the X axis
 
 
 double sine = sin(x);
   x = x + 5 ;
   y =50*sin(x);
   old_val = x ; // for connecting lines to the dots at this point doesn't work
   old_val1 = y  ; //for connecting lines to the dots at this point doesn't work
  
   //tft.drawRect(x,y +120,  5, 5, MAGENTA); // the y+120 puts the y values in the center of the screen null this out for two tone test pattern
 
   delay(10);
 tft.drawLine( x, y + 120,old_val , 120 -old_val1, BLACK); // two tone test null this out for sine wave
 
 
   }
  }
 
 


Popular posts from this blog

March 31, 2024. Happy Easter to those who celebrate this day.

What a great day to Binge on Chocolate and experience the pain of that filling that has been leaking.  I would be in that category with the leaking filling(s) had I not just spent an amount equivalent to one of the fancy new uptown appliance box transceivers on two filling repairs. Well at least I can binge on the Chocolate bunnies without fear of pain. Regrettably everything appears to have jumped in price including the price of parts. Well not so much the parts as the shipping costs.  That notably is seen in the eBay treasures. I spotted a nice heathkit DX-20 for about $50 and the shipping was $65. Likely it is a twofer with part being a way to in effect charge a higher price by inflating the shipping and in part by increased shipping costs. Shipping with insurance across the US was about $150 for this jewel and that was three years ago. 6AM on the Left Coast ~ 20M Easter Sunday! My only hope is the cost of Chocolate Bunnies remains steady although a pound of See's Candies f...

January 26, 2024. A simple CW Transceiver/Transmitter

Cruise through the lower part of the ham bands bands and what do you hear? Well, FT-8 and CW. Often you will not hear any SSB stations yet go to the lower part of the bands, and it is a cacophony (I love that word) of bad sounding signals and some high-speed keying. Fast is not so much of the issue as is bad, run together and jerky keying. But none the less our hobby started there.    So, you could crank down your ICOM 7300 and watch the waterfall on CW or you could homebrew a radio. Actually, to do CW right you need more thought up front than you do with a SSB transceiver. Often, I will state that a CW Transceiver is much more difficult to build than a simple SSB rig. I published two articles in QRP Quarterly on CW transceivers and all I got was a yawn so maybe history will repeat itself.  Yawn!   30M CW Transceiver with RIT!   Of interest is that the LO is a Varactor tuned LC oscillator using a NE602. Look closely at the RIT circuit which is only activated on ...

August 30, 2024. A PNP 20M SSB Transceiver

Shown below is the Block Diagram for the 20M PNP SSB Transceiver steered in the  Transmit Mode . The components shown in the dotted block are relay steered so that the block module is single pass and amplifies in a single direction. The Block diagram show steered in Transmit.  Essentially the steering process works so that the IF Module input follows the Balanced Modulator on Transmit and then the input side follows the Receive Mixer on Receive. All done with some relays and a bit of RG174U coax. For those who count things in detail, this block diagram is not unlike what was used for the PSSST Transceiver which can be found on my website . Yes, a warmed over P3ST only using PNP devices. TYGNYBNT. 73's Pete N6QW