-
Notifications
You must be signed in to change notification settings - Fork 2
Revision History
Pictures and descriptions are also at https://k7mdl2.wixsite.com/k7mdl/rf-wattmeter-on-psoc5lp and https://k7mdl2.wixsite.com/k7mdl/arduino-rf-remote-wattmeter
Key Changes: (Chronological order so newest is at end)
May 2020 - Placed the desktop window in the upper right corner of screen on app open. Plan to create a config file to remember placement position later. Changed the name of pyRFPowerMeter.py removing the Version number in the name.
Added more serial port error handling. For example, if USB is unplugged, the comms the ON/OFF button turns off and red and shuts down the serial thread. When problem is fixed turn on again and it will gracefully resume. Also added startup error in case specified port is not there. Offers a list of USB ports. Also you can now run without any serial port (has limited use but good for the curious without a meter. The network thread is now decoupled from the On/Off button and is always running.
Using network data and heartbeat from WSJTX to implement a failover on data source form Band and Radio ID. Color and ID name changes to UI fields show data source changed. Using the WSJTX heartbeat message to timeout the network sourced data. Applied factory A/D correction library functions or A/D non-linearity on the Arduino (ESP32 CPU).
Sped up the sample rate in the Arduino and in the GUI update rate for faster meter response. (PSoC has no averaging applied, not required.) Bug fix - Scale on wattmeter should return to the last used scale however the scale is incremented after a reset and the needle does not know it so is pegged out until you hit the scale button (local or remote) which syncs things back up. Fix tries to make the scale stay put as it was last. Awaits further testing - still an open issue as of 5/7
Created RF Wattmeter.ino as a headless version of Arduino code tested on the M5Stack. Most of the screen draws are removed. As of 5/8/2020 it can take remote commands to edit any of the 20 calibration values. The Python app is updated to send some test commands using the previous scale, speed and SWR buttons. The previous scale button now dumps the meter's current cal values (Cal table). Changed to a multibyte command message format similar to the meter data power level out messages. Changed the sequence number (2nd field) to now be a msg_type field to enable future expansion of common categories and for more protection against random data looking like a legit message. Noticed just recently a new behavior in using the Arduino IDE serial monitor to manually send command bytes, it now causes the CPU to reboot. Commands sent via the Python app have no problem. Possibly a difference in handling different terminating characters, TBI.
Created RF_Nano_Headless.ino derived from the headless M5Stack version in RF_Wattmeter.ino as the headless version tested on an Arduino Nano, all M5Stack dependencies for screen and buttons and ADC are removed, now using solely remote commands. Added remote commands for Meter CPU reset, Reset EEPROM to default values, turn on and off serial power level output messages. Assigned the greyed out buttons in the Desktop UI to temporary commands to test these. 3.4G = CPU reset. 5.7G followed by 10G will erase EEPROM byte 0. Next reboot will force EEPROM to be reloaded from default values. Use the 3.4G button to do that or hit the CPU reset button. Other commands issued before the reboot is done will normally abort the EEPROM overwrite since they cause an EEPROM write to store current values thus setting EPROM byte 0 back to 'G', so no EEPROM overwrite will occur on next reboot.
Also in this version the desktop UI handles a serial hang when CPU is reset (Catches a serial decode error condition) Now supports multiple meter monitoring. Can accept a new MeterID on the UI app command line as the 2nd argument. You can now run multiple instances of the UI app as long as you match each instance to the correct serial port and Meter ID. The meter ID is hard coded into the meter code. WSJTX messages are broadcast with no filtering done by the app at this point. If not using multicast (as with JTAlert rebroadcasts) then the first instance to start will grab the connection and the 2nd will not hear the broadcasts.
Have nearly completed porting the Nano_Headless version over to Cypress Semiconductor PSoc5LP which is similar cost and size but far higher AD specs with multiple reference voltage level options and programmable hardware digital and analog blocks for signal conditioning and more I/O for controlling things. Looking at embedding these meters in my new high power RF amplifier builds, implement sequencing and fault trips, temp monitoring, remote bypass/operate commands and remote monitoring. I will probably add back some sort of screen for local status on the amp, but will be set up to be easily used or not. Could also just use a few LEDs. See my Multiband LO project for a good example. Updated RF_Power_Meter.ini to have the complete remote command set and new serial message protocol merged from the Nano_Headless version. Not compatible with V1.01 or V1.00.
Deleted Remote_Wattmeter Arduino code. A headless M5stack version is not useful now that a Nano and PSoC version is working.
5/27/202 - The headless version was successfully ported to a Cypress Semiconductors PSoC5LP CY8CL-059 dev module (~$10 each) with instrumentation quality AD converters for lower noise and higher accuracy in close to the same form factor as the Nano. fast conversion with up to 20 bits resolutions, uses an configurable Analog Mux on a DeltagSigma AD converter component with op amps in front for gain scaling and buffering. The VRef is more flexible as well.
5/28/2020 - After initial calibration testing on the PSoC version, the speed and stability of the PSoC is much better than the other platforms. Using 20 bit resolution, reduced the averaging to 1 ADC sample feeding the smoothing function now only 2 deep. Increased the serial data output rate to take advantage of the rapid stable readings. Now remote meter response is at final value in 2 serial port updates, far faster than before, just short of instantaneous, limited by the serial data output interval. The PSoC files are what is contained in a "minimal archive" meaning you can drop the set of files as organized into your PSoC Creator 4.2+ folder area and you can open it and it should be complete and compile and run no problem (once you set your target CPU correctly in the IDE). 2 USB ports are used, one for the programmer connection during development (has full hardware debugger), the other is the onboard micro USB connector which all application messaging take place on (USB Serial port).
5/31/2020 - Fixed problem not reading EEPROM back into memory (EEPROM code is quite different then on the Arduino), tuned the ADC area a bit, 0 fudge factors used now, cal values are almost same as the printed coupler cal chart now. Added SSD1306 controller based OLED driver code in prep for testing a 1" OLED display intended for embedding into a high power RF amplifier. Far happier with the PSoC ADC performance so switching to it for the handheld 10GHz version and the RF amp embedded version. Need to expand the desktop app to make calibration easier such as just using a slider control or +/= buttons to dial in the desired power level target and not worry about the actual values.
6/10/2020 - Updated some of the M5Stack code with changes from the PSoC code. Changed the Fwd ADC to an external 16-bit ADS1100 unit from M5Stack and tested very stable. Need to buy or build a Grove cable Tee and convert the Ref port ADC to a 2nd ADS1100 unit. As an alternative I have a pair of ADS1115 4 channel I2C ADC PCBs ($4 each) for testing. It is a near cousin and should also work well. This is interesting for embedding in something like an RF amp to measure temp, HV, 12V and current as well as Fwd and Ref power. This is in the M5Stack code only right now. The PSoC internal ADC is even higher resolution and just as good in a smaller PCB size using the KitProg board if desired. 6/10/2020 - Reassigned some I/O pins on the PSoC5LP design to match the available pins on the KitProg programming break-off board. Same chip with fewer available I/O pins. These are usually broken off after development is done and collected in a jar. They are 1" square and very capable. They require you add a bootloader component and configure it, select the different CPU device and upload the same code. Very easy. You develop and debug on the main module then use a bootloader utility to upload to a KitProg with bootloader in it.
6/10/2020 - Add support for a 2.4" Nextion intelligent display. Still support the OLED. Put all display code in #ifdef statements to select either/none/both displays. Have 3 pages. The main status page now showing Current, temp, HV voltage, 12V. Numbers turn red when they exceed a max threshold. The thresholds can be set by the 3rd page with sliders for each. Also the meter ID and manual band change is there. The 2nd page has 2 manual sliders to fine tune the Ref and Fwd coupler cal. The auto cal method developed days later then this is a better approach, but changing coupler values can still get close and works when you cannot generate a steady RF carrier to measure. Remote commands added to set slope and offset for each port (Fwd and Ref) as detector boards can be different. This is set for the active band. The current band is displayed. A Save Config button commits changes to EEPROM on both config pages. This is currently in the PSoC5LP version.
6/15/2020 - Added 2 different auto cal mechanisms. The first one takes a serial commands with a target power level in Watts. It then loops adjusting the coupling factor number to get the power value to match. This worked OK but does nothing to improve the slope and offset. While in the adjustment loop the desktop app Cal button turns red. This is triggered by new output messages 161 (in progress) and 160 (finish). The ADC voltage is displayed in these messages when you need to see the raw voltage measured. This is currently in the PSoC5LP version.
6/16/2020 - Added a better auto cal method. This calculates offset and slope based on 2 measurements. ADC voltage measurements are taken on serial command and mapped to a supplied power level (in Watts). High power is measured first. If the low power is hit without a valid high power reading made, it skips any changes. A carrier is applied, the command is sent with power level value. Then the power lowered and 2nd command is sent with that low value in watts. For example 100W and 10W. The CPU then does the math to determine slope and offset. You enter the coupler + attenuator values for each band beforehand and this method does not alter them like the methods before did. The advantages are: Accounts better for detector variations in frequency response, offset and slope parameters. The slope inversion, if any, is now automatically figured, as is any offset, if any. It does require a known accurate RF carrier be applied at 2 levels, preferably at the high and low ends of the range. Supplying best guess numbers before cal will save some calc time but it is still fast. There is a limit of 100 measurements per cal attempt to prevent an endless loop. No manual voltage measurement or super accurate attenuator/coupler numbers required. This is currently in the PSoC5LP version only. With separate slope and offset for each port on each band, the Cal Table structure was expanded to store them per band along with the coupling factor and attenuator already there. The EEPROM functions had to be updated to match. For a CPU that has not seen these changes you need to set a #define RESET_EEPROM to force an overwrite of the EEPROM to the new structure or you could get hangs from weird values read back from the EEPROM since the cal table structures are completely changed to support the auto cal slope and offset storage.
6/19/2020 - Completed GUI startup screen to set Com port and MeterID values. 2 list boxes are presented with an OK button. For MeterID the default is the value named in the source file. It will be overridden by cmd line arg or the GUI input. Serial Port will show only USB serial ports available and default to the first one, if any. Hit OK button will accept the defaults or any list box selections made. You can start the GUI app without a serial connection, just cannot do much. The WSJTX part can be seen to work, and later will be able to go into the config edit screens and config file read and save features when written. Also when the new auto-cal is active, the Cal button will turn red. During this time you want to leave the power level steady until measurement is completed and stored in EEPROM. Only takes a few seconds.
6/25/2020 - More progress on the desktop app Config screen windowing and all buttons now work as intended except for the color changing part during calibration. Added support for a 3.5" Nextion display, adding new dBm fields, arranged things to better fit the larger display area, added a new graphing screen for Fwd, Ref, and SWR. The 2.4" display should continue to work, nearly all the work is in the display side code. The host is writing some new fields for dBm on the main page and power/SWR on the new page that will kick back serial error messages from the display. Plan to add the same pages into the 2.4" version later. The display code for both Nextion and OLED is easily included or not with #ifdef for each display type. The PSoC is the most current version code since it is a more capable IDE with hardware level debugging and ability to enable bootloader (or not) to utilize the Kitprog snap-off programming boards. Periodically I merge most features into the Arduino time permitting. One way to use the Nextion display is to package the display separate of the CPU/detector box and connect with a 4 wire cable with +5V, GND, Serial TX and RX. Baud rate can be changed to suit length of cable.
6/28/2020 - Built new RF Wattmeter box using the 3.5" display, a full PSoC5LP module (main and KitProg boards), 5V regulator, a 4 port USB hub module (a Raspberry Pi Zero Hat) with onboard USB-UART converter, and a 10GHz Dual RF Detector (ADL5519). The ADL 5519 is really 2 AD8318 single detectors like used in this project but are on the same silicon so comparisons between forward and reflected measurements will be more accurate. It has a wider linear range up to 8GHz, 10GHz is less linear but usable with cal. A shared VRef and common temp (and temp correction) make it more accurate as well between channels. It has comparators off the VOut lines creating terminals OutP and OutN. These are positive and inverted levels that are equivalent to Return Loss. The temp port can be read and further temp correction can be applied for greater accuracy still. The only changes needed were: a. Added mux and demux to switch the Nextion display serial lines between the CPU UART and the USB hub UART. This enables uploading new files to the Nextion display from the PC without touching any physical switches or wires. A 1-bit wide control register flips the switch on command from a remote serial command. Normally the display will be connected to the CPU UART. Keeping the program on the main PSoC CPU device (vs using the KitProg) enables development without needing manual resets for bootloader operation like required with a KitProg board. 2 USB ports are required, one for programming/debugging, one for the CPU normal USB serial output. A 3rd USB is required for the Nextion display updates. That is why the compact 4 port hub module with onboard UART is so useful. This also achieves my goal of remote development such as in a Remote Desktop Session. The TX to the USB UART is set as a SIO pin with VRef at Vdd/2 (2.5V) to suit the 3.3V RX input on the USB board since Raspberry Pi GPIO is 3.3V. The Nextion is 3.3V on the serial lines but tolerates 5V input on RxD. It is now working good with remote switch commands. b. New remote command for the UART switching. c. Now reading temperature from the detector board Temp output pin. This is not the same as a RF amplifier heat sink temp as originally envisioned and displayed on the Nextion screen but is potentially useful for calibration corrections. d. Not using using the voltage divider inputs yet so those still have dummy values.
6/29/2020 - Changed SWR graph scale to be more accurate with more vertical axis labels. Added vertical line separator on the power graph each time the scale button is pressed to separate the scale data visually. ADL5519 results were nearly the same as the dual 8318s, just a recalibration needed. Results were very close to spec sheet values. Being a single board, construction and accuracy are both improved, slightly higher cost. My source is from SV1AFN.com in Greece. I will be ordering a couple more. It took the postal service 6 weeks to get it here last time. It sat for weeks at various locations.
6/30/2020 - Completed Desktop app Config page. Button layout done with on screen calibration instructions. 2 text entry boxes provided to specify the hi and lo power levels to be measured. Apply carrier at each power level, then hit measure button to calculate the slope and intercept. Previous Host commands altered a bit to separate the measure from the calculate actions. To commit, use the "Save to Meter" button to write values to EEPROM. Future additions would be saving last screen positions and upload and download complete cal tables from a file.
7/1/2020 - Now shows the ADC voltages captured during Cal. Calculate (Fwd or Ref) buttons are disabled until both a hi and lo reading are taken since the Config window was opened. After that you can just reread either one, the calculation uses the last saved values. Went through a complete calibration on both forward and reflected on 6 bands 50-1296MHz and the resulting slope and offset numbers are tightly grouped and close to the ADL5519 spec sheet. Will probably extend the Config UI to accept power level input in either dBm or Watts for convenience. Note the desktop app Fwd and Ref do nothing at this time. You can edit the script to plug in any command-value pair you like for testing. This about wraps up this phase of work and will create a V1.2 release package soon.
7/1/2020 - Added choice of dBm or Watts for calibration power levels. Displays the measured ADC voltages for each power level. New commands added for dBm measurement levels. Renumbered the related cal commands. Desktop and PSoC versions only have these so far. M5Stack will work standalone and most serial commands from the desktop app should work but it is not fully up to date with the latest latest PSoC changes so expect some issues.
7/1/2020 - Release V2 created. There is more to do but they are in niche corners and significant new areas like wireless control.
7/25/2020 - V2.1 uploaded. New screens added to the Nextion (2.4" only so far). Will merge these into the 3.5" a bit later. a. ADC Cal like the desktop app config page has b. Reworked Nextion serial port handling to deal with missed events better, serial port Nextion code memcpy bounds checking that caused power on hangs. c. Added quick band change pop up page when you press the band label on the Main screen. d. Faster band switching times any screen/headless config. Was saving all EEPROMN on band change, now only state vars. e. No change to headless, OLED or Arduino in this batch of changes. Completed the 5 RF Wattmeter build. 2nd with a 4 port hub+UART converter., 3rd with PSoC.
7/27/2020 - V2.2 uploaded. For the PSoC version only, added support for N1MM + logger program's OTRSP serial protocol AUX commands (only). The Protocol was developed mainly for controlling SO2R stations but includes AUX command which is a 4 bit BCD value (0-15). This is a very small bit of code and can be applied to a Arduino Nano for standalone use or with the Wattmeter code. My Arduino versions are not at the same feature level as the PSoC5 code though.
8/1/2020 - Band Decoder, PTT, and CW keying using OTRSP serial protocol added to support PC based antenna or transverter selection from programs such as N1MM+, Logger32, etc. This is the Aux message set code that is a subset of the SO2R full set of commands. No queries, just outputs. The band decoded is used to set the Wattmeter band (thus the cal table). The screen has a new indicator for transceiver mode showing RX, TX (PTT) and CW. With this info decoded you can choose to bring some buffered I\O out to the back panel as either BCD or parallel. WSJT-X still operates to set the band if configured to do so on the desktop, so 2 possible sources of band info for auto selection. You could add I/O inputs for BCD, serial or analog input from a radio.
This feature assumes the 4 port hub and USB UART port is used. There are no wiring changes to make this work on the serial port side, it is all handled by using more digital mux ports and an additional UART component on the PSoC programmable hardware side. The 2nd UART is connected to the USB UART Converter except when it is used to upload to the Nextion display. 4 GPIO pins wires will need to be added to Port 0 pins to connect to your device(s).
This simple feature is valuable for a few reasons - since the serial port is processed on the host CPU directly, it can get band information from the N1MM for instant band change loading the correct cal values and displaying the band on the LCD. This is a bonus for radios that have no native transverter support. It does not rely only on manual or WSJT-X UDP info. One could stop there and not use the Aux IO pins.
For device control the BCD value is passed on to 4 GPIO pins on Port 0 to be used to select transverter and/or antennas. The N1MM Configurer->Antennas tab has 16 "Antenna" slots. Enter the data here to match the BCD code you per band presented on the newly added 4 AUX pins of the CPU. These are Port 0 bits 4, 5, 6, 7. You should use a buffer driver before those wires leave your wattmeter box.
To configure the serial port in N1MM you need to assign the serial port to use. The Configurer->Hardware tab assign the USB UART converter port number, Check Other/CW box, then click Set button. Choose OTRSP in the Two Radio Protocol list box. Hit Enter to exit. If you have your codes lined up right it should should just work slick.
----> Important <-----
In N1MM Entry Window there is usually a Band Panel shown on the left. Right Click on the white callsign entry window to see a pop up menu and choose the Change Band Panel Display... item. Select valid bands here. By default it may not match your system's bands. You need to configure the Band display to only show valid bands. Clicking on any invalid band causes the radio to reject the change causing N1MM to send out a 00 on the AUX port alternating with a valid band (but maybe wrong) number and so on. This results in software confusion on the N1MM side. Band changes on the radio mostly stop working, and the AUX IO stops working. This may need more debugging. It is easily avoided by not having invalid bands available to click.
Future revisions are likely soon to expand this to include adjustable BCD code offsets that may be needed in practice after some feedback arrives. Hopefully the config flexibility in N1MM will cover it. A consideration here is that if your wattmeter bands are #0 for HF, #1 for 6M, working up to #10 for 10GHz, then how do you handle the HF bands? The downstream device may require #0 for both HF and the 50MHz bands for example. Will cross that road next I am sure.
In this version you cannot cause a band change by using the Wattmeter pop up band selection screen -- yet. Maybe the OTRSP protocol can send band change info back to N1MM, or the Desktop app can bridge the info to N1MM via a network command. More research is required. This is a very big bonus for radios without transverter support. Bot only do you see what band you are on locally now (even if they all use the same IF frequency) you can just reach up and tap the touch screen to change transverter bands. All in a low cost, low part count, off the shelf component DIY box.
11/6/2020 - V2.3 Uploaded to master branch. Added LoRa to remote the Nextion screen wirelessly, removed SWR display spikes during TX On/OFF transients, updated 3.5" Screen update to match 2.4" screen with band decoder changes, enabled Voltage readings for embedded use in high power RF amplifier.
-
Wirelessly connect the Nextion display over LoRa radio at 915MHz permitting true remote operation by inserting the LoRa transceivers in the serial line connecting the Nextion to the PSoC5 CPU. When enabled by a #define, the CPU side will watch the LoRa module for flow control and slow down the screen updates. It is also now operating at 9600baud. When it was wired the Nextion library assumed fast 100% response. When wireless, there is up to 0.6sec observed delay and the screen refresh data was overwhelming the data link capacity. The code was changed to only update fields that have changed and only send updates for the correct pages, something that was not always happening before, generating ignored error messages. All status messages are now turned off so the Command Finished function just returns a 1 (completed OK) status. The current page number is now generated in the Event listener function since every event contains the page number, there is no need to continuously ask to verify what page you are one to permit updates to it. The LoRA module is configured at startup and the main screen update function refresh timer is slowed down.
-
Fully supports embedding a compact version based on the KitProg programming board that comes attached (and can be separated) with every PSoC5LP dev board into a high power RF amplifier. I mounted it behind the front panel with a small OLED display. It measures forward and reverse power from a ADL5519 detector and calculates SWR. A 0-4V DAC buffered voltage is output proportional to SWR range of 1-5 to provide a Hi SWR signal for the amplifier control board (A W6PQL Ultimate Amplifier Control Board). It also now actually 28 and 12 volts in the amplifier via voltage dividers. The temperature is the detector board temp, optionally can be used for cal correction.
-
The SWR calculation was improved to remove occasional spikes during the transition from Tx to Rx or Rx to Tx due to the timing of the ADC reads during the rising or falling power level. This was seen on occasion on the display before but became a real problem when I started using the SWR value to generate the High SWR trip voltage for the amplifier, yielding false trips (SWR lockout) and requiring manual amplifier power resets to enable the amplifier again. Not good when you operate remote 3,000 miles away half the year.
-
Additional Band Decoder functionality was added assigning pins to the BCD input and several output pins. Like my Multiband LO, the input and output can be any pattern you like for each band so BCD is not a requirement. 6 input lines are configured in case a straight-on parallel input is needed. This is limited to 6 pins as I started to run out of available I/O pins. I plan to make an extension board with current measuring and SPI bus or I2C I/O expansion with right angle PCB board edge connectors for reduced wiring inside the case. The input I/O will set the active band (from input lines or OTRSP messages) and the output I/O patterns are assigned by band will follow the band choice. I broke out some I/O pins and labeled them as Antenna selection vs generic band output as some devices will need a different pattern per band assignment, or even the same pattern for multiple bands like antenna relays switching several amps onto a common feedline for a multiband LPDA antenna. Some sort of buffer driver is usually needed. CW and PTT is also received and passed through providing the opportunity to process the PTT in case Tx_Inhibit or a delay is ever required.
11/25/2020 - V2.3 update includes new serial output message type 171 added containing HV (28V for example), 12V, current and Temp voltages. The desktop app was updated to parse and display these messages. Some unused buttons were retired to make room for the new fields. The Desktop app config screen and CPU now can calibrate these new values. SWR voltage output added for embedded RF amplifier usage. Drawings updated and some Wiki pages updated. Still need to build a Nextion screen to cal these new values.
12/1/2020 - V2.4 adds files for new port from PSoC5 to Teensy 4.1 Arduino IDE. More details to come. Mostly working though and working through full testing and cleanup. Band decoder and OLED not working yet. Hangs on Nextion Graphing screen, should be a quick fix.