Arduino bandcontroller is almost ready. Missing code for 12M band.

232 views
Skip to first unread message

Wim PE1PWR

unread,
Sep 1, 2024, 8:58:51 AM9/1/24
to Radioberry
On my Github you can find a easy code for Arduino Nano for band control Radioberry.
Its working now accept 12M band. Hopes some one can put a code in Pihpsdr for control 12M. 12M is the same code as 10 and 6M band. https://github.com/PE1PWR/Automatic-Band-Controller-Radioberry/blob/main/README.md
The Arduino use I2C connection 0x21.
Wim
PE1PWR
73

pa3gsb

unread,
Sep 2, 2024, 5:57:59 AM9/2/24
to Radioberry
Wim,

I assume you are using the radioberry firmware.

Please lookinto the code below.

It is possible to configure the band switching in a SDR.  If you are not using this the firmware is making the decision for you.

So using the radioberry components you have 2 choices use an SDR which is able to configure the bandswiching or modify these hard coded switching boundaries.

Hope this helps

73 Johan
PA3GSB

static inline void handleALEX(char* buffer)
{

if (i2c_alex & ((buffer[523] & 0xFE) == 0x12) || ((buffer[11] & 0xFE) == 0x12)) {

if (((buffer[525] & 0x40) == 0x40) ? 1 : 0) {
i2c_alex_data = ((buffer[526] & 0x8F) << 8) | (buffer[527] & 0xFF);
} else if ((((buffer[13] & 0x40) == 0x40) ? 1 : 0)) {
i2c_alex_data = ((buffer[14] & 0x8F) << 8) | (buffer[15] & 0xFF);
}
else {
//firmware does determine the filter.
uint16_t hpf = 0, lpf = 0;

if (currentfreq < 1416000) hpf = 0x20; /* bypass */
else if (currentfreq < 6500000) hpf = 0x10; /* 1.5 MHz HPF */
else if (currentfreq < 9500000) hpf = 0x08; /* 6.5 MHz HPF */
else if (currentfreq < 13000000) hpf = 0x04; /* 9.5 MHz HPF */
else if (currentfreq < 20000000) hpf = 0x01; /* 13 MHz HPF */
else hpf = 0x02; /* 20 MHz HPF */

if (currentfreq > 32000000) lpf = 0x10; /* bypass */
else if (currentfreq > 22000000) lpf = 0x20; /* 12/10 meters */
else if (currentfreq > 15000000) lpf = 0x40; /* 17/15 meters */
else if (currentfreq > 8000000) lpf = 0x01; /* 30/20 meters */
else if (currentfreq > 4500000) lpf = 0x02; /* 60/40 meters */
else if (currentfreq > 2400000) lpf = 0x04; /* 80 meters */
else lpf = 0x08; /* 160 meters */

i2c_alex_data = hpf << 8 | lpf;
}
}
if (i2c_alex)
{
if (i2c_data != i2c_alex_data)
{
fprintf(stderr, "Set Alex data to output = %d \n", i2c_alex_data);
i2c_data = i2c_alex_data;
unsigned char ldata[3];
ldata[0] = 0x02;
ldata[1] = ((i2c_alex_data >> 8) & 0xFF);
ldata[2] = (i2c_alex_data & 0xFF);
fprintf(stderr, "Set Alex data 0 = %x \n", ldata[0]);
fprintf(stderr, "Set Alex data 1 = %x \n", ldata[1]);
fprintf(stderr, "Set Alex data 2 = %x \n", ldata[2]);
if (write(fd_i2c_alex, ldata, 3) < 0)
fprintf(stderr, "Error %d writing Alex data\n", errno);
}
}
}





Op zondag 1 september 2024 om 14:58:51 UTC+2 schreef wcast...@gmail.com:

Wim PE1PWR

unread,
Sep 2, 2024, 12:18:32 PM9/2/24
to pa3gsb, Radioberry
Hi Johan.
Thanks for info.
I saw in the script that 12 and 10m are the same. Did you know how to split 12 and 10m.
They use the same 232 code.
I can't figure it out where this code is made from the band.c file.
Wim
PE1PWR
73s

Op 2 sep 2024, om 11:58, pa3gsb <pa3...@gmail.com> schreef:
--
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 on the web visit https://groups.google.com/d/msgid/radioberry/40a62693-f60c-431d-ad3f-b536b01c6ca5n%40googlegroups.com.

pa3gsb

unread,
Sep 2, 2024, 1:39:21 PM9/2/24
to Radioberry
Wim,

The protocol is clear.

You need to change the radioberry filter code. 

Hope this helps

Johan
PA3GSB

Screenshot 2024-09-02 193436.png

Op maandag 2 september 2024 om 18:18:32 UTC+2 schreef wcast...@gmail.com:

Wim PE1PWR

unread,
Sep 2, 2024, 2:48:26 PM9/2/24
to Radioberry

Hi Johan. 
I don't know exactly how to use this info.
Is there a way to see serial with IDE witch code band switch 12M is sending to the Nano.
Or is there an easy way to change the code 232 to another?
Wim 
PE1PWR
73
Op maandag 2 september 2024 om 19:39:21 UTC+2 schreef pa3gsb:

pa3gsb

unread,
Sep 2, 2024, 4:25:42 PM9/2/24
to Radioberry
Dag Wim,

Iam not sure which configuration you are using.

Very often the context of the issue people are reporting is not clear or described.

If you using your radioberry as a hat:

If you are starting radioberry in a command window it should be possible to the fprintf messages
like:
fprintf(stderr, "Set Alex data to output = %d \n", i2c_alex_data);

start a command window
sudo systemctl stop radioberry
sudo radioberry



if you are using the juice board:


you can intercept the message and can send it to an i2c device.

see code example like iam using the external PA which is connected via 

void getStreamAndSendPacket() {

if (read_stream(hpsdrdata) < 0) return; // fetching 1032 bytes of ethernet packet.
// the sdr data coming from the radioberry need to be enhanced with adddional information.
if (isAmplifierConnected()) {

you could use the protocol to find your data of interest and make a handler for it.

The juice board uses a gateware which implements the i2c bus (pin 15 and 16)


if you like to use the i2c of rpi you can switch to pin 17 and pin 18.

Hope this helps.

73 Johan
PA3GSB

Op maandag 2 september 2024 om 20:48:26 UTC+2 schreef wcast...@gmail.com:

Wim PE1PWR

unread,
Sep 3, 2024, 1:37:21 AM9/3/24
to pa3gsb, Radioberry
Hi Johan.
Thanks for your time and reply.
With this information I know better how things works.
I have three Radioberry cards incl a juice board so I can test both versions. I try the messages instructions and let you know if I can solve the last 12M code.
Wim
PE1PWR
73

Op 2 sep 2024, om 22:25, pa3gsb <pa3...@gmail.com> schreef:

Wim PE1PWR

unread,
Sep 3, 2024, 2:36:34 AM9/3/24
to Radioberry
Hi Johan,
This works fine Johan
I have got this results in CMD.

Set Alex data to output = 544
Set Alex data 0 = 2
Set Alex data 1 = 2
Set Alex data 2 = 20
 
For both bands 10M and 12M is the result the same.
This was a earlier conclusion I was told by this forum.
How can I change it so that 10 and 12M will give there own specific code from pihpsdr.
Hopes someone got a solution for it. 
I think personally its makes the Radioberry project more greater than it is when you can automatically band controlling by a Arduino Nano for a normal BPF and LPF.
I am using some old LPF boards from Icom. And also from Yaesu. And BPF from Hermes. 
For the last two bands 10 and 12M I can always use a switch to peddle between them. The rest works like charm.
For now thanks Johan for your great information.
Wim
PE1PWR
73
Op dinsdag 3 september 2024 om 06:37:21 UTC+1 schreef Wim PE1PWR:

pa3gsb

unread,
Sep 3, 2024, 3:43:30 AM9/3/24
to Radioberry
Hi Wim,

For the configuration using the radioberry as an hat :

The standard protocol does not give the possibility to change pihpsdr so you need to do the move the magic where you are able to control it.


in the filters.c you can find different 3 different implementations of controlling filter boards.

As you are using an arduino board i would advise you to use the following :

One of the filter boards is a very generic one. 
#define ADDR_FILTERS 0x22 /* Arduino filter board interface switcher address for VA2SAJ Generic Filter Switching Board*/

See the code ; it sends the mox state and the fequency ; based on the frequency which is sent to your arduino you can determine how to control your filter board; using a BCD coding or anycombination you like .

from filters.h

   if (i2c_filters_board & ((buffer[11] & 0x01) == 0x01 || (buffer[11] & 0x01) == 0x00)) {
        currentMox = ((buffer[11] & 0x01) == 0x01) ? 1 : 0;
        currentCW = cw;
        if (currentMox != previousMox || currentCW != previousCW) {
            previousMox = currentMox;
            previousCW = currentCW;
           
           
            unsigned char ldata[3];
            ldata[0] = 0x03;
            ldata[1] = ((buffer[11] & 0x01) == 0x01) ? 1 : 0;
            ldata[2] = currentCW;
            if (write(fd_i2c_filter, ldata, 3) < 0)

                fprintf(stderr, "Error %d writing Alex data\n", errno);
            fprintf(stderr, "PTT data 0 = %x \n", ldata[0]);
            fprintf(stderr, "PTT data 1 = %x \n", ldata[1]);
            fprintf(stderr, "PTT data 2 = %x \n", ldata[2]);
        }
    }
    //*************************************************
    //     Send Frenquency to filter companion
    //*************************************************
    if (i2c_filters_board & (buffer[523] & 0xFE) == 0x12) {

        if (currentfreq != previousfreq) {

            previousfreq = currentfreq;
            unsigned tempFreq = currentfreq;
            unsigned char ldata[9];
            ldata[0] = 0x04;
            ldata[1] = (tempFreq / 10000000U) % 10;
            ldata[2] = (tempFreq / 1000000U) % 10;
            ldata[3] = (tempFreq / 100000U) % 10;
            ldata[4] = (tempFreq / 10000U) % 10;
            ldata[5] = (tempFreq / 1000U) % 10;
            ldata[6] = (tempFreq / 100U) % 10;
            ldata[7] = (tempFreq / 10U) % 10;
            ldata[8] = (tempFreq / 1U) % 10;

            if (write(fd_i2c_filter, ldata, 9) < 0)
                fprintf(stderr, "Error %d setting frequency \n", errno);
            else
                fprintf(stderr, "Set Filters frequency to = %d \n", currentfreq);

        }
    }  
       
}



Furthermore you could look to the protocol of HL2 which can give you information


A real nice puzzle to crack.... but you will find a solution!

Hope this helps to get you on the right track.



73 Johan
PA3GSB


Op dinsdag 3 september 2024 om 08:36:34 UTC+2 schreef wcast...@gmail.com:

Wim PE1PWR

unread,
Sep 4, 2024, 1:32:17 PM9/4/24
to Radioberry
Hi Johan,
Again thanks for info.
For me personal its going to far to solved this issue by my own.
I go visit my radioclub Razzies at Zoetermeer next week PA2RDK will help me to clear this software issue.
PA2RDK is responsible for lots of invented Razzies projects. 
I let you know how things go. 
When its ready its open for everybody to find on Github.
Wim
PE1PWR
73s




Op dinsdag 3 september 2024 om 08:43:30 UTC+1 schreef pa3gsb:

pa3gsb

unread,
Sep 4, 2024, 2:41:00 PM9/4/24
to Radioberry
Hi Wim,

Nice you have someone who can be of help.

I think this sketch can give you also a push....


Sorry in dutch/nederlands:
In Oktobet geef ik een online  presentation (in het nederlands) voor het rfseminar. Wellicht leuk om mee te doen; je kunt je daarvoor aanmelden en krijg je vanzelf een uitnodiging.

Would be great if you indeed share your findings.

73 Johan
PA3GSB

Op woensdag 4 september 2024 om 19:32:17 UTC+2 schreef wcast...@gmail.com:
Reply all
Reply to author
Forward
0 new messages