Panteltje's swr_pic page

Panteltje's swr_pic page

~

Here you find the listing for a PIC 16F690 to function as RF power and SWR meter, with RS232 interface.: swr-0.6.1.asm
Current version is swr-0.6.1.asm

The most recent version for a 4 lines x 20 character display (google HC200401C-VA.pdf, with controller S6A0069.pdf): swr-0.8.7.asm
This version additonally has battery voltage, battery current, and ampere-hours display, and a 20 character message area (via RS232) on line 4, also 'h' prints help.
Diagrams to follow later, but most info is in the asm source, old picture (without current) here: LCD_4x20_2.jpg

The following Linux bash script, when the serial port is initilalized, sends a message to the LCD, and beeps:
# text as arg1
echo -e "\0001$1\r" > /dev/ttyS1
# bell
echo -e "\0007" > /dev/ttyS1

Test setup:
swr_pic_test2.jpg
The little board on the left is the RS232 interface with a MAX232.
The trimpots on wires are the simulated input voltages.
The big board holds the PIC16F690 and an incarnation of the noppp programmer.

Display up close:
Note the 1k resistors in the data lines to avoid bus conflicts when experimenting, likely not needed in the final version.
swr_pic_close.jpg

IO:
There are 3 inputs, range 0-5V, power, forward, and reflected.
The PIC outputs to a 2 line character LCD display, and can also be read via RS232 by for example a PC.
There are 2 outputs, a SWR alarm (red LED, and can drive a small beeper too), and PWM for LCD backlight intensity control.
The range is 149 Watt for 5 V DC in, and SWR is calculated as the ratio between the 2 other analog inputs, and should work over a wide range.
The supply is the voltage reference for the PIC, perhaps use a LM317.
The PIC uses the internal oscillator.
The math is done in integer, some rounding takes place.
You can set the 'SWR alarm' from the PC, to say to 1.8, and the LED will come on and beeper will be activated if SWR >= 1.8.
The clock speed calibration, and LCD brightness (PWM) can also be set from the PC, and all settings are saved in EEPROM,
so you basically have to do that only once.
SWR, Power, and the settings for SWR alarm, clock calibration, as well as ADC steps, can all be read from the PC if need be.

Maybe later I will show the diagram of the whole thing, but this is still experimental here,
for now you will have to make do with this: swr_pic_diagram_img_0564.jpg
atm in the process of interfacing it to an existing Pan SWR power meter (with analog meters).
The PIC communicates with the PC at 19200 Baud, 8 bits no parity.

SWR is calculated as SWR = (Vfwd + Vrefl) / (Vfwd - Vrefl).
From this follows that the main requirement is that the signals Vforward and Vreflected are within the ADC 0 to 5V input range.
The absolute value is not that critical, but try to go for 5V max at 160 W for example.
Test shows that with very low voltage (low output power) the SWR is still displayed correctly.
Here is the intended input circuit for the power input, connected to the transmitter side of the SWR meter.
With a 50 Ohm load, and 150 W, then U^2 / 50 = 150, or U = sqrt(7500) = 86.6 Veff.
The peak value is sqrt(2) x 86.6 = 122.474 V.
The diode drops about .7 V, that leaves 121.77 V DC on the capacitor.
The output divider is 1/26, leaving 4.68 V on the PIC for 150W.
This is about 958 (of max 1023) ADC steps, the PIC asm math is based on this.
Some people may object to the loading on the transmitter by this circuit, causing distortion (harmonics),
in that case you can make a resistor divider, and place the diode behind that, and adapt the ASM math as now
the diode drop has more effect (especially at low power levels), and this effect is squared in the calculations.
Make sure you decouple the analog input pins of the PIC with say 100nF right at the pins, to avoid instability.
input.gif




Click here for some other programs I make available under the GPL.

Click here to send mail