Adding power/swr meter to the TRX-DUO transceiver — part.1 — code investigation.

Normally in Red Pitaya we can use analog inputs 0 and 1 for DC output from SWR bridge without any changes in software.

Unfortunately that pins are not connected to FPGA in TRX-DUO.

So we have 2 options to get this values to the software:

  1. Solder that pins somehow to FPGA (unreal option for me, because that requires desoldering FPGA in my case, and last time when I was soldering BGA was 10 years ago with 50% success :))
  2. Add some additional ADC connected to i2c outputs.

My choice is 2 🙂

Let’s start to investigate. Sometimes it’s hard for me because i’m not a programmer and see the C code pretty rarely.

The main process that serves hermes protocol in Pavel Demin’s software is sdr-transceiver-hpsdr and it’s just a linux binary written in C and running under linux system on TRX-DUO.

Let’s do this work right on TRX-DUO.

Install build tools and vim:

# apk add build-base vim

Make SD card writalbe:

# rw

# cd /media/mmcblk0p1/apps/sdr_transceiver_hpsdr_122_88

# vim sdr-transceiver-hpsdr.c

Now we can find the part of code that sends integer values (value variable) from ADCs:

The first two values with header_offset 8 and 16 are forwarded power and reflected power in volts multiplied by 1000.

Let’s try to send some test data. Comment ADC values and add some constant:

And let’s build binary:

# gcc -O3 -march=armv7-a -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard -D_GNU_SOURCE sdr-transceiver-hpsdr.c -lm -lpthread

Then start server from new binary:

# ./a.out 2 1 2 2 1 2

I’ve added some debug to linhpsdr so I can see the values received from transceiver from my computer in console:

And in graphical interface when transmitting:

Now 30% of work is done.

I bought some ADS1015 and ADS1115 — it’s and ADCs with i2c interface. But I have Arduino Leonardo with me and I can write some simple sketch to make Arduino act as ADC with i2c interface.

Will do it next time.