The As Built Circuit
A builder's group in the G-QRP Club provided me this circuit and it has worked like a charm. This group took my Sudden Transceiver design and moved it to 17M and added the actual S Meter sense circuitry. The Zener Diode is in the loop to limit the Voltage input to the Arduino.
The following is the call function in the code for the S Meter. The code below creates the Bar Graph. But there is a lot more besides the moving bar. The adcval also has to be listed as one of the variables.
There is no technical reason or knowledge base for the formula. I just noodled my way through the math knowing it had to be a log function and some of the other factors are there, so you get a reasonable bar length to display.
void CheckSM(){
adcval = analogRead(A6); //S meter routine
val= 15*log((adcval-200)/20);
display.fillRect(58,87, val, 2, YELLOW);
delay(20);
}
The 58 and 57 are the starting location (pixel) on the Color TFT screen, The val is the S Meter Value (based on hocus pocus) and the 2 is the height of the Bar and YELLOW is the Bar Color. (Magic Decoder Ring stuff.)
Here is some of the Code to put the S Meter graphics on the screen complete with Tick marks and markings for S9.
display.setTextSize(1);
display.setTextColor(GREEN);
display.setCursor(6,83);
display.println("S Meter");
display.setCursor(118,67);
display.print("S9");
display.drawRect(56,79,95,15,RED);
display.fillRect(57, 86, 93,4, BLACK);
display.setTextColor(RED);
for(int i = 0; i < 8; i++) { // A Trick to add "Tick Marks" to the S Meter
display.fillRect(60 + 10* i,80,1,5,WHITE);}
display.setTextColor(GREEN);
display.setCursor(6,83);
display.println("S Meter");
display.setCursor(118,67);
display.print("S9");
display.drawRect(56,79,95,15,RED);
display.fillRect(57, 86, 93,4, BLACK);
display.setTextColor(RED);
for(int i = 0; i < 8; i++) { // A Trick to add "Tick Marks" to the S Meter
display.fillRect(60 + 10* i,80,1,5,WHITE);}
The collecting file for the adcval
int adcval = A6; // Analog Pin A6 for the S Meter function.
You also have to designate in the Pin Mode that A6 is an INPUT.
Undoubtedly some genuine "software weenie" has the correct formula. But this does display, and strong signals hit S9.
This same S Meter Circuit is installed in the Peashooter SSB Transceiver. The Color TFT in that radio is less than 1 inch square.
You will note the G-QRP guys removed some of my extra Gingerbread on the display and cleaned up the array of info. One cool thing I came up with is simulated LEDs in Green to show what is active. In the G-QRP display I immediately know the lower "B" VFO is active. In my code I had some thoughts about cross band operating so the smaller display of frequencies with small green dots is to show which band you are transmitting on.
Always Ahead of the Curve!
73's
Pete N6QW