Re: Help with VSWR readout in PiHPSDR Raspberry PI.

271 views
Skip to first unread message

Samuel Lourenço

unread,
Oct 15, 2025, 2:57:25 PMOct 15
to Duane's Mind, Radioberry
Can you upload "radioberry.h"? I see a bunch of silly errors that
should be easy to solve.

Kind regards, Samuel Lourenço

On Mon, 13 Oct 2025 at 18:49, Duane's Mind <duane...@gmail.com> wrote:
>
> Hi,
>
> I've edited the necessary files needed but when I recompile I get errors. Photo attached
> Is there maybe a version of PiHPSDR that works with the VSWR readout ready to go?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups "Radioberry" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to radioberry+...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/radioberry/76bb7044-0a5b-4562-9f65-352045a342bcn%40googlegroups.com.

Duane's Mind

unread,
Oct 17, 2025, 11:33:42 AMOct 17
to Radioberry
Hello Samual, thanks for the reply

Here are the 4 files that I edited manually. At least I think it's correct!
It took me a while to figure out how to recompile the firmware but I think I manged to do it in the end. 
Sorry my Linux knowledge is very limited but I'll try anyway.
I seem to have some sort of SWR and FWD reading in piHPSDR now but it's not showing real readings.
I wouldn't know how to callobrate it any further to match real readings or if my files are correct.

Many thanks


radioberry.c
radioberry.h
measure.c
measure.h

Ricardo Suarez

unread,
Oct 17, 2025, 11:53:50 AMOct 17
to radio...@googlegroups.com

Hello, Duane

As in the pm sended two days ago, the calibration is done in pihpsdr program menu, at PA tab

*************

The meter is calibrated from PA menu, you can set the bridge gain band by band, also the SWR

In https://apache-labs.com/public/storage/download_file/1756364890_1021_piHPSDR-Manual-3.pdf, at page 73, item 8.2 you can see how to.

*************

Regards

Rick LU9DA

Duane's Mind

unread,
Oct 17, 2025, 12:04:20 PMOct 17
to Radioberry
Hi Ricardo,

Thanks I did try out the PA Menu with out much success. The readings are just nowhere near to what they should be. 
I also tried the VSWR-Monitor software but I suppose this also needs to be calibrated?

Regards

pa3gsb

unread,
Oct 17, 2025, 12:24:30 PMOct 17
to Radioberry
Samuel

I tried to compile; also got your errors.

i solved it by adding  the variables in the radioberry.h

int pa_fwd = 0;
int pa_temp = 0;
int pa_current = 0;
int pa_ref = 0;
int pa_temp_ok = 1;

I did not look into what you are planning todo just making it compilable.

73 Johan
PA3GSB

Op vrijdag 17 oktober 2025 om 17:33:42 UTC+2 schreef duane...@gmail.com:

Duane's Mind

unread,
Oct 17, 2025, 2:06:35 PMOct 17
to Radioberry
Hello Paul,

Thanks, yes those lines work.

I'm trying to get the Power and SWR to show properly in PiHPSDR.
I managed to try edit the 4 files needed manually. Whether I added in the necessary information properly or not I'm not 100% sure.
I built your VSWR circuit from Github but I'm struggling to show any accurate PWR/SWR readings.

The VSWR software on your Github does it need calobrating to also show proper readings from the your VSWR circuit?

Thanks

Samuel Lourenço

unread,
Oct 17, 2025, 4:00:34 PMOct 17
to pa3gsb, Radioberry
Hi Johan,

I think you might be answering to the wrong person. I've never tried
to compile the source code. However, the errors that Duane was getting
seemed to point to some variables not being declared. It seemed
obvious to me.

Kind regards, Samuel Lourenço
> To view this discussion visit https://groups.google.com/d/msgid/radioberry/74629cfe-1473-49de-8fbe-b1058a3505c3n%40googlegroups.com.

Yado-san

unread,
Oct 18, 2025, 8:20:06 AMOct 18
to Radioberry
Hi  Duane,

Nice try!
As no specific are provided, it is difficult to say, but the following may be of help

_Is there a proportional relationship between PA output and Vfwd values using only the SWR bridge? (and 3.3V or below)
_What is the maximum output power of the PA?
_If the same power is applied to both Forward and Reflected, does Vref = Vfwd?

_Radioberry is recognised by pihpsdr as HermesLite2 (PA=5W).
_As  Ricardo  mentioned, calibration is possible via the PA menu of the pihpsdr.

_If the SWR bridge characteristics or PA output differ a lot, it will be more accurate to adjust constant2,rconstant2 bellow.

 pihpsdr/src : https://github.com/dl1ycf/pihpsdr/blob/master/src/transmitter.c

 static gboolean tx_update_display(gpointer data) {
:
    case DEVICE_HERMES_LITE:
    case DEVICE_HERMES_LITE2:
    case NEW_DEVICE_HERMES_LITE:
    case NEW_DEVICE_HERMES_LITE2:
      //
      // These values are a fit to the "HL2FilterE3" data in Quisk.
      // No difference in the Fwd and Rev formula.
      //
      constant1 = 3.3;
      constant2 = 1.52;
      rconstant2 = 1.52;
      rev_cal_offset = -34;
      fwd_cal_offset = -34;
      break;

    v1 = ((double)fwd_power / 4095.0) * constant1;
    tx->fwd = (v1 * v1) / constant2;
    v1 = ((double)rev_power / 4095.0) * constant1;
    tx->rev = (v1 * v1) / rconstant2;
:
 }

GL.
Yado-san, jg1twp

Duane's Mind

unread,
Oct 24, 2025, 10:28:21 AMOct 24
to Radioberry
Thanks for the reply Yado-san,

I got the SWR reading to show more or less accurate now in PiHPSDR but Power(watts) is not showing.
Adjusting the values in the PA tab just messes with the SWR reading and doesn't give any proper power reading.

Also temperature now shows at 275 C.

I'm using a 10 watt PA connected to my radioberry.
I have built the VSWR module from PA3GSB Github: https://github.com/pa3gsb/vswr/tree/master

This transmitter.c file is that from the Radioberry driver install process?

I understand Constant1 is the 3.3v reference voltage. Where do I get the other values from?

I did also install the VSWR-Monitor software also from PA3GSB and transmitting it shows the correct Power out but not so accurate SWR.
I get values for AIN0 (rev) and AIN3 (FWD). With these values I can use to edit the transmitter.c file?
If I understand correctly these values are used to calculate the value/4095x3.3V.

Many thanks



Yado-san

unread,
Oct 25, 2025, 12:09:50 AMOct 25
to Radioberry
Hi  Duane,

As the Vfwd/Vrev ADC input voltage and pihpsdr display values are not specified, this is an guess, but..
Using Johan's VSWR circuit and the 275C display indicates that ADC access is working. (because ADC_AIN1= +3V3)
As ADC_AIN2=GND, I believe the PA current value during transmission is 0.0A.

_ Connecting a temperature sensor and current monitor IC to the VSWR circuit  would enable display of PA temperature and PA current values.

adc_preamp.png
fyi:
  Radioberry-2.x/SBC/rpi-4/device_driver/firmware/radioberry.c
 ($ git clone  --depth=1 https://github.com/pa3gsb/Radioberry-2.x )
 
 radioberry.c
 :
  static void *rb_measure_thread(void *arg) {
// temperature == (((T*.01)+.5)/3.26)*4096   if pa temperature > 50C (=1256) switch pa off! 
 :


_ transmitter.c is the latest pihpsdr source code.
  https://github.com/dl1ycf/pihpsdr/blob/master/src/transmitter.c
 ( $ git clone https://github.com/dl1ycf/pihpsdr.git )

Looking at the transmitter.c program, it can be seen that with HermèsLite2(+N2ADR_LPF and SWRbride), 5W is displayed when AIN3 (Vfwd) is approximately 2.8V. (code bellow)

From this equation, measuring the Vfwd(VIN3) value at 10W you can calculate constant2 backwards.
Similarly, rconstant2 can be calculated from Vrev(AIN2). As it is the same circuit, constant2 = rconstant2.

pihpsdr/src/transmitter.c
:
line 622 -

    case DEVICE_HERMES_LITE:
    case DEVICE_HERMES_LITE2:
    case NEW_DEVICE_HERMES_LITE:
    case NEW_DEVICE_HERMES_LITE2:
      //
      // These values are a fit to the "HL2FilterE3" data in Quisk.
      // No difference in the Fwd and Rev formula.
      //
      constant1 = 3.3;
      constant2 = 1.52;
      rconstant2 = 1.52;
      rev_cal_offset = -34;
      fwd_cal_offset = -34;
      break;
    }
:
    v1 = ((double)fwd_power / 4095.0) * constant1;
    tx->fwd = (v1 * v1) / constant2;
    v1 = ((double)rev_power / 4095.0) * constant1;
    tx->rev = (v1 * v1) / rconstant2;
:

_ If pihpsdr was installed using pihpsdr_install.sh then see,

Hope help, Yado-san


Duane's Mind

unread,
Oct 26, 2025, 10:25:36 AMOct 26
to Radioberry
Many thanks for the extra info.

I did tweak the settings a bit in the transmitter.c file and now I have something that's more accurate. Not 100% but close enough!

I also tried another SWR Bridge and this has given me a much better SWR and Power reading across the whole HF band.
With the new SWR Bridge I'm able to Calibrate the watt meter in the PA Setting now.
I'm not to sure why the one I made from PA3GSB Github doesn't give me good readings. It might be something with the way I wound the 2 cores.

My next step will be to add the LDMOS Temperature sensor onto AIN1 and probably stick it on the Radioberry heatsink or PA heatsink.

One other question I was playing with this VSWR meter software that Johan made which I think is very nice. https://github.com/pa3gsb/vswr/tree/master/software
I can get the Watts to show accurately but SWR reading doesn't move, always 1.1.
Maybe you have some ideas on what I can maybe change?

Regards,

Duane

Yado-san

unread,
Oct 26, 2025, 11:12:21 AMOct 26
to Radioberry
Wow great! :)

Care must be paid to the winding of the SWR bridge.
Do you happen to reverse Vfwd and Vrev?
In My 30W-PA SWR bridge circuit, I made up Vfwd/Vrev the wrong way round.

To be sure, should ask Johan, but looking at the programme, if they are reversed, swr becomes negative, and swr is setting swr=1.
If they were reversed, swapping the connections of Ain0 and Ain3 should fix it.

vswr_code.png
GL, Yado-san.

Duane's Mind

unread,
Oct 29, 2025, 6:29:56 AMOct 29
to Radioberry
Ok let me try reverse the FWD and REV and see what it does.

With regards to the windings it might be the direction of the winding. Maybe one core needs to be wound in the clockwise direction and other CCW.
I have a piece of RG58 cable going through the middle of the cores.
After cutting off the braid on one side and leaving the other side grounded it improved on the readings. Maybe I should just have a piece of wire going through the cores rather with no braid.

I do get better results with the other tandem match bridge though
SWR Bridge.jpg

SNAIL

unread,
Oct 30, 2025, 12:13:41 AMOct 30
to Radioberry
You can unsolder one coil and flip it 180 degrees on RG cable.  Circuit diagram of the SWR-bridge
Dot marks coil winding begins relatively to RG cable.

Duane's Mind

unread,
Oct 30, 2025, 9:20:13 AMOct 30
to Radioberry
Thanks,

I'll flip the winding on one of these cores and test again.
On the schematic I didn't see any dots so I just wound the coils all in the same direction

Screenshot 2025-10-30 141752.png

SNAIL

unread,
Nov 1, 2025, 2:56:01 AMNov 1
to Radioberry
Hi Duane and Radioberry. You can check and calibrate VSWR meter with two pot resistors providing voltage to VSWR inputs. Use this formula to calculate SWR 

SWR= 𝑉𝑓+𝑉𝑟 /𝑉𝑓−𝑉𝑟. So, if you set V𝑓  = 2 volt, V𝑟 = 1 volt SWR = 3/1 =3 Changing potential on resistors you can check is calculation right. Of course, voltmeter accuracy is the key, but it will work.
Screenshot 2025-10-30 141752.png

SNAIL

unread,
Nov 11, 2025, 3:57:22 PMNov 11
to Radioberry
Duane, do you have any success with VSWR meter? 

Duane's Mind

unread,
Nov 12, 2025, 3:31:33 AMNov 12
to Radioberry
Hi,

Yes, thanks I've had some good success with the SWR and Power readings now
The Power reading is very accurate but SWR is a tiny bit out. Might need a bit more tweaking either in the software or even components on the PCB.

I haven't implemented the variable resistor yet but my plan is to design a new PCB board with it in.
At the moment I've used half of Johan's VSWR bridge circuit with a Binocular core VSWR bridge. This is going to better for my Radioberry project as this binocular core has a lower profile as well.

I've also been experimenting with the VSWR Monitor software, I could never get the SWR to show correctly. I've now added a setting in the software for REV calibration and now it works quite well.
VSWR-Monitor software doesn't work on Pi5 though!

Also I've programmed up a little Arduino board with that VSWR Monitor software

So for my radioberry project I will have a seperate OLED display for VSWR readings as well as the PiHPSDR VSWR reading

Regards,

Duane
VSWR-Monitor.png
Arduino2.png
Arduino1.png
SWR_Setting.jpg
SWR_Modue.jpg

SNAIL

unread,
Nov 12, 2025, 10:56:12 AMNov 12
to Radioberry
Thanks for the quick response. It really helped me decide what to do next, whether to try installing it or using a separate module. I'll be using the same 60 dBm board and an Arduino to measure power and VSWR.
I still haven't figured out how it works in Radioberry, as I only see transistor current and temperature measurements. It's completely unclear for me how the SWR measurement works in the PIHPSDR. Perhaps I'll install an ATU 100 antenna tuner and mount the tuner display on the front panel.
IMG20250710091813[1].jpg

Duane's Mind

unread,
Nov 13, 2025, 3:05:51 AMNov 13
to Radioberry
If I was building a nice large enclosure similar to yours, then I would probably build the ATU-100 inside and mount the OLED on the faceplate.
I'm busy building something a bit more portable so no ATU. The little arduino for VSWR measurment is also an nice option.
I've also seen the VSWR bridge on Aliexpress: SWR-Bridge

Paulh002

unread,
Nov 13, 2025, 3:12:59 AMNov 13
to Duane's Mind, Radioberry
DJ0ABR has published also an interresting swr bridge inclusive pcb design
https://www.dj0abr.de/english/technik/dds/epwrswrV2.htm

--
You received this message because you are subscribed to the Google Groups "Radioberry" group.
To unsubscribe from this group and stop receiving emails from it, send an email to radioberry+...@googlegroups.com.

SNAIL

unread,
Dec 12, 2025, 2:05:38 PM (4 days ago) Dec 12
to Radioberry
Interesting VSWR calibration idea to get more accurate readings. I'm waiting for PCB arrival PA3GSB design will play with it and post. It will be one extra PCB can mail it to you Diane's Minds if you want.
Reply all
Reply to author
Forward
0 new messages