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--


No comments: