Translate

Tuesday, January 14, 2025

Using the Hex Editor to Look at IQ Files

In a previous post, we've talked about how to modify a native Perseus IQ file so it might be used in the SDR# receiver program. This was accomplished by viewing the Perseus file in a hexadecimal editor to check the file's sample rate, center frequency, and start time, then renaming the file into the HDSDR file naming format which SDR# will accept.

Knowledge of the basic hexadecimal counting system is beneficial, almost necessary, if you are going to dive into file modification using a hex editor. Get used to counting by 16s. 0123456789ABCDEF, then 10.

0A=10
0B=11
0C=12
0D=13
0E=14
0F=15
10=16
1F=31
20=32
2F=47
30=48
3F=63
40=64

HxD is our chosen hex editor. It is fine freeware software with no ads and has been around for a long time. It works great in any version of Windows.

HxD Hex Editor

Base 16 is known as hexadecimal or count by 16 versus count by 10. HxD, or any other hex editor, will show a file in hexadecimal notation, including the offsets into the file, so the conversion to decimal may just confuse. Best to get familiar with hex notation and counting. I'll show you the equivalents on the screenshots.

The left column in HxD is the offset into the file, in hexadecimal. Imagine the next 16 bytes as 4 columns, each column being 4 bytes. Count the column starting points like this: 0, 4, 8 ,C.


-OFFSET-   -----------------------DATA-----------------------
           0  1  2  3   4  5  6  7   8  9  A  B   C  D  E  F
           -----------  -----------  -----------  -----------
00000000   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
00000010   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00
00000020   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00


Now, let's go to a sample native Perseus file, named P_20101111_2200z_630-1430.wav. We open it into the HxD editor. Reference the screenshots at the bottom of this post.

The following fields are of interest:

  • Sample Rate is at x18 (4 bytes)
  • Center Frequency is at x2C (4 bytes)
  • Timestamp is at x34 (4 bytes)

4 byte fields are 32 bits in length, each byte containing 8 bits. It's called a WORD in programming parlance.

  • x18 offset is decimal offset 24 (16+8)
  • x2C offset is decimal offset 44 (32+12)
  • x34 offset is decimal offset 52 (48+4)

Looking at the screenshots below:

     1. The sample rate is 1000000 (in decimal) (right column)

     2. The center frequency is 1030000 (in decimal, in cycles or Hz) (right column)

     3. The timestamp is as depicted in the right column. In the main body, in hex, it's the epoch integer number dating the number of seconds from Jan 1, 1970 at 00:00:00 UTC.

You can change any of these values in the right column. They will automatically be converted, and the proper hex values will appear in the main display.

Caveats--

     1. In the file itself, the timestamp value can obviously be changed to anything you want. We will use the date/time value in the file renaming process.

     2. Leave the center frequency and the sample rate alone, as these must remain accurate to what's in the file. We will use the center frequency information in the file renaming process.

Once changed and you are finished, be sure to save the file (the FILE menu item).

File Renaming

In renaming the Perseus file to, for example:

HDSDR_20101111_215900z_1030kHz_RF.wav

   -->2010 is the year of course.

   -->1111 is the date, (NOV 11). Month, day order.

   -->In our example rename, 215900 is the rough time from the timestamp field. If you look in the timestamp field of the native Perseus file you'll see that the actual start time is 21:59:06 seconds. You could change the file name start time to 215906z if you like.

   -->1030kHz is the center frequency of course. Shown as 1030000 in HxD.

   -->"RF" is HDSDR's way of file naming, the RF indicating that the file is an IQ file.

Once the native Perseus file is renamed into HDSDR's naming format, SDR# should be able to open the file and use it. Even though the Perseus file's sample rate is 1000000 (1,000,000 ksps), SDR# will read it and process it at this rate, though SDR# cannot produce IQ files at this sample rate.

Hoping this helps all using the hex editor to identify sample rates, center frequency, and timestamps in Perseus files.

Screenshots

Click any image for the bigger picture.

Sample Rate--


Center Frequency--


Timestamp--


Thursday, January 2, 2025

2022-2024 Pattern Maps Patch

Apologies. There is a bug which has surfaced in the 2022 and 2024 Pattern Maps Start file. The two files affected are RDMW-Start-v3.7.6.html (2024) and RDMW-Start-v3.7.4.html (2022).

Microsoft's early November 2024 updates to its MS Edge browser have caused a bug to surface in the 2024 RDMW Pattern Map start file. It also affects the 2022 RDMW Pattern Map start file. The bug causes the lower half of the start page to disappear below the "Select Timeframe" selection box, making channel selection impossible. The two files affected are RDMW-Start-v3.7.6.html (2024) and RDMW-Start-v3.7.4.html (2022).

The bug has been identified and corrected, and a replacement start file is available for each version. The bug was caused by an unclosed <select> tag.

The fix to your map set is simple:

1. Download an unzip the included RDMW patch file.

2. In Windows Explorer go to your unpacked pattern map folder (the folder where you unzipped your downloaded 2024 or 2022 pattern map set).

3. For RDMW 2024 (if you own this one)-->

     -replace the RDMW-Start-3.7.6.html file with patched version RDMW-Start-3.7.6.1

4. For RDMW 2022 (if you own this one)-->

     -replace the RDMW-Start-3.7.4.html file with patched version RDMW-Start-3.7.4.1

Click on the new start file and your pattern map set should now start normally. Once verified as working correctly, delete the old start file(s).

Get the patch at the link below:

https://www.mediafire.com/file/ee0aydqmm5kugi3/2022-2024_pattern_maps_patch.zip/file


Thursday, November 21, 2024

Altering The Timestamp In Perseus IQ .WAV Files

Three or four years ago I got into SDR receivers. I don't own a Perseus, but I do own and use an Airspy HF+ Discovery, an SDRPlay RSP1a, and an SDRPlay RSPdx.

Perseus IQ .WAV files can be found on the internet or compatible ones can be created by several SDR receiver programs. One of those programs is the HDSDR program. Even if you don't own a Perseus receiver (the hardware), you can use the free Perseus demo (version 5) to play the .WAV files.

Perseus V5 demo from MicroTelecom

These IQ files are fairly typical .WAV riff files. Within the file header is a special field which specifies the date/time of the recording. The Perseus receiver software picks this up and uses it in its display of the recording.

Occasionally someone has the need to change the time of the recording, possibly because their computer clock was off when the recording was made. This can be easily done if you don't mind some byte twiddling in a hex editor.

Altering The Timestamp (2 ways)

Both methods require a manual procedure, one easy and one a little more detailed. I've tested both and they work.

The starting date/time timestamp field is contained within the Perseus .WAV file header. It's found at hexadecimal location x34 and is 4 bytes long. It is the Epoch time for the start date/time. Epoch time is the number of seconds since January 1, 1970 at midnight AM: 00:00:00 GMT. No ending timestamp seems to be used, rather they use the actual length of the audio file to calculate the end time.

We must change this 4 byte starting timestamp field at location x34. That would be bytes 34, 35, 36, and 37.

There are two methods to change this timestamp. Follow along, looking at the screenshot below.

Method 1, the easier method. You need:

1. The freeware hex editor program HxD. HxD is a nice freeware one for Windows that I use.

https://mh-nexus.de/en/hxd/

Start your hex editor HxD and open the Perseus .WAV file. With your mouse, select the 4 bytes starting at hex location x34 (34,35,36,37). In the lower right panel look for the item named "time_t (32 bit)". You will see that HxD has converted the 4 byte value at hex x34 and displayed the date/time conversion in plain text right there.

Each of the items in the right panel can be modified. Here's how to modify the date/time item:

Only after selecting the 4 bytes starting at hex location x34, make your changes to the date/time in the "time_t (32 bit)" item, then press ENTER. HxD will calculate the 32 bit Epoch time value and replace the one at location x34.

Save the file. HxD will also save a backup of the old file for backup purposes.

You are done except for renaming the file, see below after Method 2.

Method 2, the harder geek method. You need:

1. The freeware hex editor program HxD. HxD is a nice freeware one for Windows that I use.

https://mh-nexus.de/en/hxd/

2. Access to an Epoch timestamp converter (available online).

https://www.epochconverter.com

3. Access to a decimal to hexadecimal converter or a programmer's decimal-hexadecimal calculator.

https://www.rapidtables.com/convert/number/decimal-to-hex.html

Start your hex editor HxD and open the Perseus .WAV file. With your mouse, select the 4 bytes starting at hex location x34 (34,35,36,37). In the lower right panel look for the item named "time_t (32 bit)". You will see that HxD has converted the 4 byte value at hex x34 and displayed the date/time conversion in plain text right there.

Write down your new start date and time. Go to the Epoch timestamp converter site (or another if you prefer) and enter the date/time you have chosen. Convert that date/time to the new Epoch time. You will get a big number. For example, for 11-21-2024 0450 GMT (NOV 21, 2024 @ 04:50:00 GMT), the Epoch time is 1732164600.

Again, one Epoch time converter site is: https://www.epochconverter.com

Now, we must convert this number to a 4 byte (8 digit) hexadecimal value.

Go to the hexadecimal converter site and in the decimal field type the Epoch time number. In our example it was "1732164600" for 11-21-2024 0450 GMT.

Using our example, you will get the hexadecimal value: 673EBBF8

The Perseus .WAV file requires this value to be in what programmers call "little-endian format", that is, low value to high value. The value above is in "big-endian format", or high to low value.

We simply need to mirror the hexadecimal number we have. Mirror 673EBBF8, getting F8BB3E67.

We now need to plug in our example number F8BB3E67 into the .WAV file at hex location x34.

Back in your hex editor HxD, set your cursor at hex location x34 (left click just to the left of the location x34 byte itself) and type the new value, F8BB3E67, into the main hex display replacing the 4 bytes starting at hex location x34.

Save the file. HxD will also save a backup of the old file for backup purposes.

Renaming The File

It's not necessary for the Perseus SDR receiver software, but to maintain clarity, rename the .WAV file to the new start time. And since you know the length of the file in minutes, also add the new end time too.

If you have multiple .WAV files, i.e., when a time period is longer than 15 minutes, be sure to change the start time in each file (_001, _002, _003, etc).

That's it. If I get some time at some point, I'll code up a little program to do all this automatically.


Wednesday, September 11, 2024

Modding Experiments With The YouLoop

The Outstanding Passive Loop Antenna by Airspy

Airspy, the maker of the HF+ Discovery SDR receiver, also makes the YouLoop, the passive, so-called "2-turn" mobius loop sold for use especially with Airspy's SDR receiver lineup.

I bought a YouLoop three or so years ago when I bought my Discovery, tried it for a short time, and put it away, not fully realizing its potential. Sometimes, as in real life, there's more just under the surface than what meets the eye at first. If you don't give a second look, you might miss it. For starters, you have to get your mindset pointed in the right direction, that is, towards ultra-low noise floors and signal-to-noise ratio improvement. Don't stay focused on S-meter readings and brute signal strength. The YouLoop is perfectly matched to present an ultra-low noise floor with maximized signal pickup, and particularly for the mediumwave band.

Factory stock YouLoop

From the factory, the YouLoop has a circumference of 2 meters, comprised of two, one meter sections joined at both the top and bottom, presenting a diameter of 0.64 meters, or 25.2 inches. The top ends are joined through a simple crossover network, interchanging the coax shield with the inner conductor. At the bottom we have a tiny voltage balun to match the loop's low impedance and provide additional noise suppression and isolation. A low noise, highly sensitive receiver is required to get the best out of the YouLoop, to wit, the HF+ Discovery, which has a noise floor on the order of -142 dBm and a minimum discernable signal (MDS) sensitivity of -140 dBm (0.02 uV / 50 ohms at 15 MHz). That is an extremely faint signal. The YouLoop will work minimally with the SDRPlay RSP series of receivers, but they lack the low noise floor and sensitivity to get full value from it. A preamp might help there, mounted right at the loop itself.

In the mediumwave band, the stock YouLoop's sensitivity falls off gradually below 1000 KHz. It was evident that a slightly larger loop might help with this. In attempts to correct this I've done experiments by adding to the length of the YouLoop, first adding two short 1/2 meter lengths of RG-402 (one per side), then two 1 meter lengths in a similar fashion. The 1/2 meter lengths increase the total circumference to 3 meters, the 1 meter lengths increase it to 4 meters. In order to add to the existing YouLoop coax, you will need to purchase two coax pigtails of the same type (RG-402) and two female SMA unions, both readily available from Amazon.

SMA unions and RG-402 pigtails

Let's Do Some Testing

Testing was performed with both extension modifications, comparing each to the stock 2 meter loop while noting the signal strength and the signal-to-noise ratio differences. The standard 6 ft. coax feeder was used between the SDR and the YouLoop and the SDR was connected to the computer through a 15 ft, high quality shielded USB cable to get it as far away from digital hash as possible.

Two distant stations were used as reference and checked during mid-daytime hours, CHLO-530 KHz, Brampton, Ontario (1 KW) at 195 km distance and WWKB-1520 KHz, Buffalo, NY (50 KW) at 111 km distance. Both put in readable but not overly strong signals at these distances.

Results were very interesting, and somewhat surprising, indeed. See the table just below. SNR values are measured to include the carrier + the sidebands.

Freq     Stock 2-meter YouLoop         3-meter YouLoop                4-meter YouLoop   
-----------------------------------------------------------------------------------------------------------------------
 530     -84dB (snr=30, nf=-114)    -76dB (snr=30, nf=-106)     -68dB (snr=31, nf=-99) 
1520    -85dB (snr=37, nf=-122)    -85dB (snr=38, nf=-123)     -83dB (snr=39, nf=-122) 

        *signal strength values in dBFS (dB Full Scale)
        *snr = signal-to-noise ratio, in dB
        *nf = background noise floor, in dBFS

Signal strengths at 530 KHz improved by about 8 dB when the loop circumference was extended from 2 to 3 meters. A 16 dB improvement (530 KHz again) was seen when the loop was extended to 4 meters. To my surprise, signal strengths at the high end of the band (1520 KHz) remained essentially the same for all three loops, rising only about 3 dB (half an S-unit) with the 4 meter loop. The 2 and 3 meter loops produced identical signal strengths at 1520 KHz.

Perhaps more surprising, the SNR, or signal-to-noise ratio of both stations did not vary more than 1-3 dB across all three loop lengths at each frequency. At 530 KHz, all three loops realized an SNR of 30-31 dB. At 1520 KHz, the SNR hovered between 37-39 dB. The relatively unchanging SNR is significant and will allow us to choose the best length loop for our receiving purposes.

The last phase of the testing was null depth. Null depth did not change across all three loops. Differences were undetectable from the original product. I am able to get 23-26 dB null differential across the MW band on semi-local, low angle (60 miles distant) groundwave signals.

So which loop would be the best choice for mediumwave?

The 4 meter loop had only a small gain change over the original 2 meter version at the high end of the band, some 3 dB, but realized about 16 dB gain at the low end. The 4 meter loop seems the logical choice. However, our noise floor at 530 KHz rises from -114 dBm (original YouLoop) to -99 dBm, an increase of 15 dB too! The new -99 dBm noise floor is the equivalent of S-5 on the S-meter. The original YouLoop's noise floor at -114 dBm is about S-2 and much quieter, and with the same SNR and same copyability.

3 meter YouLoop with added pigtails

The 3 meter loop had virtually no gain change over the original 2 meter version at the high end of the band but showed about 8 dB gain at the low end. This time our noise floor at 530 KHz rises from -114 dBm (original YouLoop) to -106 dBm, an increase of 8 dB too! The new -106 dBm noise floor is the equivalent of S-3.5. The original YouLoop, still at -114 dBm (S-2) and still quieter, has the same SNR and same copyability.

The 3 meter loop, the one with the two 1/2 meter extensions, may be the best compromise here. We get signal gain, as it raises signal levels at the low end of the band by about 8 dB. Our noise floor is kept in check at the low end as well, rising only to -106 dB, near a one microvolt signal. The larger 4 meter loop sets the noise floor too high at -99 dB, possibly masking very weak signals at the microvolt level (-107 dBm).

The YouLoop at 3 meters circumference starts to become a little unwieldy indoors, but can be arranged in a vertical oval so that it can be rotated a little easier and not hit other objects in a room. Arrange it in a 24 inch wide by 48 inch tall configuration. Little difference was seen in its nulling ability or signal degradation when configured in this shape.

Conclusions

Extending our original YouLoop to 3 and 4 meters increased our signal levels, but the background noise levels increased by the same amount. Kicking in the preamp on SDR# would accomplish the same thing, amplifying the signal and noise the same amount. The HF+ Discovery has a 15 dB preamp.

The HF+ Discovery's published sensitivity is -110 dBm for 6 dB signal-to-noise ratio. That is a signal some 6 dB, or one "S" unit above the noise. You're going to have to do a bit better than that, however, in that you need a better SNR than 6 dB to extract meaningful audio out of a signal. 9-10 dB might give results, 12-15 dB even better. The signal must be modulated adequately too - low modulation levels will require a higher SNR to make sense of. We can hear a 1 microvolt signal (-107 dBm) if our background noise is enough below that, our bandwidth just right, and our signal is modulated properly.

You need to get the signal strengths up there, closing in on the -107 dBm level to copy audio from signals. In that signal range, it would be best to have a base noise level of not much more than about -115 dBm actual measured noise level.

Note again, we also have the preamp at our disposal. A low noise preamp can make up the difference we need in signal strength. Remember, though, generally the background noise will be amplified equally with the signal. Not to worry if it brings our signal up to a listenable level. Example: Rising out of a -120 dBm noise floor we have a -110 dBm signal we are struggling to get copyable audio out of. Kick in the preamp and we raise that -110 dBm signal to -95 dBm, even though our noise floor is also raised to -105 dBm. The signal is now copyable.

Bonus Test

While I was at it, I put together a tiny 1 meter circumference loop using the two 1/2 meter pigtails. It is the size of a pie plate. One would think this would be so small a loop as to be totally ineffective. Not so.

Here are the test results for that YouLoop configuration as compared to the factory YouLoop:

Freq     Stock 2-meter YouLoop     tiny 1-meter YouLoop !!
------------------------------------------------------------------------------------
 530     -84dB (snr=30, nf=-114)    -97dB (snr=27, nf=-124)
1520    -85dB (snr=37, nf=-122)    -89dB (snr=35, nf=-124)

Signals were lower but adequate, and signal-to-noise levels were in the same ballpark of the other loops. Surprising, even a tiny YouLoop is effective!

Some Low Noise And Signal Improvement Tips

1. Position the YouLoop as far away from your computer and monitor as possible. Monitors in particular are terrible electrical hash generators.

2. Position the SDR itself as far away as possible from your computer for the same reasons.

3. To keep the SDR as far away as possible from your computer, you will need a long USB cable. The USB 2.0 standard allows for cable lengths of up to about 15 ft. You MUST use a good quality, properly shielded USB cable. Stay away from the latest rage, the cotton-covered USB cable. The ones I've tried have inadequate shielding and let all kinds of trash in. I've had great luck with the Monoprice line of cables, available on Amazon. If you attempt to run farther than 15 ft., be aware that you may incur data transmission loss. Your SDR will suddenly drop out of "Play" and into "stop" mode. It may not even start. Trust me, I've tried it. They do make USB amplifiers. I haven't tried them or know if they'd even work.

4. The YouLoop works best when the connecting coax to your SDR is the shortest length possible. Operated passively (without a preamp), you will not get good results or maybe even any results by feeding it with 50 ft. of coax and placing it out in the yard. Try to keep the coax feed under 12 ft. Three to six ft. of coax is optimum. SDRs, like the HF+ Discovery, can also be directly connected to the YouLoop feed point for outstanding results.

5. Used indoors, place the YouLoop next to a window for maximum signal pickup. This really does make a difference.

6. Don't be sloppy with the circle or oval you form. Make a wooden form in the shape of a cross if you like, and fasten the loop to it, ensuring the coax lies in a flat plane. This will maximize the loop's balance and nulling abilities on mediumwave. A child's plastic Hula Hoop also makes a wonderful circular form and can be used in pairs for bigger loop sizes.