
The power meter screen will use my standard simulated analog meter with the scale changing with the range selection. The Peak reading during the time window will be displayed, along with the Average power over the entire time period. I also display the current range and time window.
The software for this is a basic While loop. It first uses the millis() function to get the start time then checks current time before each time through the loop. It exits the loop when the selected window time is reached. During each pass through the loop it checks for a higher peak reading and updates a sum and counter that are used to compute the average, I also store the last reading. I compare the current reading with the previous to determine if I should redraw the needle and print current value. This helps a lot with eliminating a flicker on the meter.
UPDATE 2/17/19
tft.setTextColor( BLACK, WHITE);
while ((millis() - startTime) < pmWindowTimes[pmWindow]) { // sample for window
adc = analogRead(pmADCpin); // get reading
average = average + adc; // add readings to compute average
if (adc > peak) peak = adc; // check if a new peak reading
count++; // increment count for computing average
pmDB = ADC2dBm(adc); // calculate dB value times 10
if ((abs(lastAdc - adc)) > 4) { // limit change size to reduce jitter
// erase old needle and draw in new position
tft.fillRect(DB_MTR_X + 2, DB_MTR_Y + 30, DB_MTR_W - 4, DB_MTR_H - 40, WHITE);
if (pmRange == 0) { // dBm direct input
plotNeedle(DB_MTR_X, DB_MTR_Y, DB_MTR_W, DB_MTR_H, adc, 3300, BLACK);
lastAdc = adc; // save last reading for comparrison
}
else { // Watts using 40 dB tap
pmWatt = dBm2Watt( pmDB); // convert dbm reading to watts
pmWatt = int( pmWatt * (1000 / pmRangeVal[pmRange])); // prescale
if (pmWatt > 1000)pmWatt = 1050; // keep needle on meter face
plotNeedle(DB_MTR_X, DB_MTR_Y, DB_MTR_W, DB_MTR_H, pmWatt , 1080, BLACK);
lastWatt = pmWatt; // save last reading for comparrison
}
tft.setCursor(120, 150);
printPMValues( pmDB);
}
}
average = average / count; // compute average and print
pmAverage = ADC2dBm(average); // convert adc readings and store in global
pmPeak = ADC2dBm(peak);
Made some changes to the loop that updates the display to reduce some of the jitter I was seeing. Also took care of some minor issues, such as keeping the needle display on the meter if value goes over range. After a lot of playing around, I was able to come up with a single function to print the power value correctly scaled for whatever range is selected.
void printPMValues( float value) {
switch (pmRange) {
case 0: // value directly in dBm.
tft.print ( value / 10, 1);
tft.println (" dBm. ");
break;
case 1: // value in mWatt
value = dBm2Watt( value ); // convert from dBm to watts
tft.print (value * 1000, 0); // scale up for mw display
tft.println (" mWatt ");
break;
case 2: // value in Watts 2 decimal places
value = dBm2Watt( value ); // convert from dBm to watts
tft.print (value , 2);
tft.println (" Watt ");
break;
case 3: // value in Watts only one decimal place
value = dBm2Watt( value ); // convert from dBm to watts
tft.print ( value , 1);
tft.println (" Watt ");
break;
}
}
This function is used for the value displayed on the meter, and the Peak and Average values.
I did a manual calibration using a signal source and a fixed attenuator to determine the ADC counts per dB. Later I will add a calibration function and have the value stored in eeprom.
Next I have decided to reuse some of these functions and add a modulation monitor. This will display the power output on a simulated oscilloscope screen. I think I will have both a Rectified and a RF envelope display. This should help in setting Mic. gain levels to prevent distortion.
Hi DuWayne,
ReplyDeleteDid you make progress on the modulation monitor? And also do you sale some board of your power meter?
This comment has been removed by a blog administrator.
ReplyDeleteHow to Make an NFL deposit: A beginners guide to sportsbook
ReplyDeleteHow to make an NFL 광명 출장안마 deposit: 세종특별자치 출장샵 A beginners guide to sportsbook bonuses. Some sports betting sites allow you to deposit at 순천 출장안마 least 영천 출장샵 $10 into the 화성 출장마사지 site.