Creating my own panadapter

  • 1
  • Question
  • Updated 3 years ago
Ok, I'm starting to step off into the deep end of the pool now. :-)
The Flexlib api has a lot of info for creating a panadapter and waterfall.
What I want to do in my program is create my own panadapter/waterfall
(panadapter first) on a separate form which I can call up from my main form.
I "thought" I could just put a Picturebox control on the second form and call it
from the main form (button) and using GDI+ do a DrawLine and somehow translate
info from Flexlib to set the points along the line as it continuously updated. I know it's not
that simple, but, all I can find for reference online suggests generating the points using the
results of an FFT, from a raw data source. That seems a bit complicated and most likely,
over my head. Do I have to actually process the streaming data and do the FFT? Or can
I grab the info from Flexlib and feed it to my C# program?
   I hope this is not too simple of a question and I'm just missing something that should be
easy using the api.
james
WD5GWY
 
Photo of James Whiteway

James Whiteway

  • 877 Posts
  • 193 Reply Likes

Posted 3 years ago

  • 1
Photo of Mark Erbaugh

Mark Erbaugh

  • 384 Posts
  • 34 Reply Likes
I believe the panadapter data is in the form you need, the FFT
Photo of James Whiteway

James Whiteway

  • 877 Posts
  • 193 Reply Likes
Looks like I will either have to do a LOT more studying or my program will have a very simple interface minus the Panafall ! I guess I could call it  S(kinny)SDR !!! (minus the cool extras!)
Thanks Mark for the info.
james
WD5GWY
(Edited)
Photo of Stu Phillips - K6TU

Stu Phillips - K6TU, Elmer

  • 642 Posts
  • 256 Reply Likes
James,

The data from the radio has already been processed using an FFT and mapped to the parameters of your pan adaptor before its is sent to you.

A pan adaptor is a grid of x by y pixels with 0,0 being top left and x,y bottom right.

The data in the pan adaptor is a series of frequency "bins" from an FFT with one bin for each pixel along the x axis.  The value for the bin is the y pixel value representing the strength of the signal. You can set the gain mapping for the y axis with the commands/properties of the pan adaptor via FlexLib.

So to display the pan adaptor, you need to create a path of points representing the signal value using the x,y data pairs and then have it drawn graphically.  The pan adaptor data is sent as a series of frames where you can control the frame rate in frames per second - again with a property of the pan adaptor.

Waterfall data is sent to you as an array of values that is wider than the pan adaptor data - the data contains a header telling you the frequency of the first "bin" of data and the number of bins.  Each 16 bit value has to be mapped to a color pixel (24 bits - 8 for each of RGB) by the receiving client.  The waterfall is scrolled down by one line as each new update is sent to your client.

Hopefully this is enough to get you going - I can't help you directly with how to program this using FlexLib as I don't use it but instead have a native Objective C version of the same functionality that I use for Mac OS X and Apple iOS applications.  This library does essentially the same as FlexLib but in Objective C rather than C#.

Stu K6TU
Photo of James Whiteway

James Whiteway

  • 877 Posts
  • 193 Reply Likes
Thank you Stu! That does help. Not saying I "get" all of it yet. But, your explanation is much clearer than some I have found online. I'm sure I'll be posting more questions as I go along. I really would like to learn this stuff, even if for no other reason than to learn something new.
james
WD5GWY
 
Photo of Walt - KZ1F

Walt - KZ1F

  • 3040 Posts
  • 643 Reply Likes
William did not do a core library, he just used the raw data. You also have to experiment and try to glean things out. I am not trying to make it sound scary bad but it isn't designed to be a tutorial. Some people are just mucking with this for their own head, sure, have at it. Some people are doing this for income. It is not realistic to expect someone who went through the effort to figure this out to have a commercial product are apt to tell others how they, too, can write the code. Stu is selling what he did for iPad, I am selling the portable version when the rest of the UI controls are done. I don't know who else has a commercial interest in this, perhaps Enzo, others who are simply lurking, The difference between Williams approach (and perhaps Enzo's) is I made the decision early on not to give periodic updates of what mine looks like. It will debut when it is ready for sale.  Somewhere, there really is a line between 'nothing secret about that' and 'yeah there really is something secret about that".  What I meant by small bytes (bites) is get the version as of yesterday down to the bare minimum number of statements necessary to do that function, no superfluous code where you can't explain it's purpose. From what you showed yesterday, easily 3/4 of it was not even relevant. Acquiring a radio, acquiring a panadapter, and acquiring a slice receiver should take maybe a dozen statements. Once you get to that point, make little changes that if they don't work, you can back out. But, whatever you do, do not do wholesale cut and pastes. That is a really good way to get hopelessly lost.  I took a quick look at what William told you, yeah, that's how to do it. I would have explained it, differently but what he said was spot on correct. But you have to know how to do graphic programming.

If you aren't familiar with doing graphical development, take a detour and write a small app to draw a circle, draw a star, a square, a rectangle. That will tell you how to do the spectrum analyser. Then write a small program to do a moving marque as in ticker tape displays in Fidelity offices or Schwab offices. That will tell you how to do waterfalls. It will point you in the correct direction anyway. I am not trying to be cute here but we all know the saying about giving someone a fish vs. teaching them to fish.

Out of curiosity, what is your day job? Oh, and you are correct, you are letting this get to you. Take Sunday off, there has to be a contest someone on this planet. Oh, wait...take next week off, work dx on 17.
(Edited)
Photo of James Whiteway

James Whiteway

  • 877 Posts
  • 193 Reply Likes
You'll like this Walt, I am a truck driver. ( I can just imagine what you're thinking now, NO WONDER he's so dense!) As for the suggestions you mentioned, I have done those sort of programs in the past. (using Visual Basic and some C# and in the distant past, Basic and C & C++)  I have written Hex Editors, database programs and several other types of applications. Some for fun and others for profit.
   I will figure this one out as well. I wasn't asking for a tutorial, hand holding or anything like that. Even if it might appear that way to you and others. I was looking for direction as to what Values from Flexlib api do I need to apply to drawing a panadapter and eventually, panafall. I just do not see what the api is sending and from what portion of the api. I know I need X & Y coordinates for each bin in each packet. But, I cannot find where those values are given, much less how they are worded. I don't know how else I can explain what I'm asking other than what I have already done.
  And as for taking Sunday off,,,,,,,,I'm leaving for Oklahoma this evening and then heading to Arkansas and from there to Arizona and back to the Dallas, Fort Worth area all by Friday.
   So, if you wish to give up on this old truck driver who seems to ask for the keys to someone's kingdom, it's not a problem. One, because I WILL figure it out. Two, because I know I can. (I'm just not as quick at "getting" things at 64 as I was at 30)
james
WD5GWY
 
Photo of Walt - KZ1F

Walt - KZ1F

  • 3040 Posts
  • 643 Reply Likes
I didn't think that. When I've taught I usually get around to asking the students abt where they are coming from. I've always tried to not give my student the answer. I try to help them figure it out for themselves as that, alone, is what builds self confidence.
Once you have a panadapter you need a way to digest the data asynchronously. Just as with the onRadioAdded, and onPanadapterAdded look in panadapter. cs for what other information it is able to send. You are building on what you've already done. C# is not that old so you were not using it in the distant path, I'm guessing around 2005 if not more recently. I did not see graphical programs listed, learn how to do canvas drawing, stars, squares, circles
(Edited)
Photo of Stu Phillips - K6TU

Stu Phillips - K6TU, Elmer

  • 642 Posts
  • 256 Reply Likes
James,

I've written up more details on the pan adaptor and waterfall in the following post:

https://community.flexradio.com/flexradio/topics/generating-a-pan-adaptor-and-waterfall-display

I put it into its own thread so hopefully its easier for folks to find in the future.

Hopefully this will help and doubtless prompt more questions :-)

Ask away!
Stu K6TU
Photo of James Whiteway

James Whiteway

  • 877 Posts
  • 193 Reply Likes
Oh yes it will help. And you're right, I'm sure I'll have more questions! :-)
Photo of William Hemmingsen

William Hemmingsen

  • 573 Posts
  • 278 Reply Likes
James think of the panadapter as plotting a chart.  When you create the panadaper programmatically you set a Xpixels and Ypixels value.   You want to set the panadapter size base on your window size, or some scale of it. Now lets take a simple example:

Program window size - 100x20 pixels

display pan set 0x40000000 x=100 y=20

The radio will send an array of values between 0-20.  These values are Y.  The position of value (Bin) is X.  So lets take these values from a single packet and place them in an array.  You should end up with an Array that has a length of 100 and contains values between 0-20.  The lower the the value the higher the signal strength. 

The index of the array is the X value, and the value at that index is Y.  Now you jut need to plot those values on the screen. You will plot from 0,0 which is the upper left corner of the window. 

Now you just need to create a for loop to draw lines

drawline from index,array[index] to index+1,array[index+1]
increment index and repeat till index = array length-1 (99 in this example)

Clear window
read next packet and do it again.

I hope this makes since.

William
Photo of James Whiteway

James Whiteway

  • 877 Posts
  • 193 Reply Likes
William, thank you for your help. If I understand you correctly, I should be able to draw the display directly on a form or picturebox using the values from an Array, instead of using the MS Chart control or something similar.
 Should the display be updated from the Panadapter Property Changed event? Or is the data coming from another event that I need to subscribe to? I guess I'm asking where do the packets originate from? All I can see in Panadapter.cs in the Flexlib api, are commands to the radio (or that's what it looks like to me)  that request a panadapter and set the window size for the panadapter. I'm sure I'm overlooking something. But, what I cannot tell !
I just may be biting off more than I can chew for now. At one time, (years ago) I could actually figure this out. I'm beginning to think my age is showing! :-)
And on top of all that, I let a lot of time lapse since I last seriously did any real programming. (and it shows with my snail like progress) I could kick myself for letting that happen.
Ok, enough whining!
james
WD5GWY
Photo of James Whiteway

James Whiteway

  • 877 Posts
  • 193 Reply Likes
Thanks Walt. I'll give it a look.
james
WD5GWY
Photo of James Whiteway

James Whiteway

  • 877 Posts
  • 193 Reply Likes
Since I FINALLY got my app to control my radio independent of SSDR, I am now getting Packet info for the Panadapter! Not saying I'm ready to actually build a panadapter, but, before I finally found the issue (actually, there were many issues) I could not receive a Packet Count from the radio because my application was not the GUI client. So, the radio would not send that info to me!
james
WD5GWY
Photo of Walt - KZ1F

Walt - KZ1F

  • 3040 Posts
  • 643 Reply Likes
That is very good. My advice still stands, take small bytes (hehe) at a time. Now, before you do anything else, gracefully shut everything down. Don't 'pull the plug' so to speak, shut everything down gracefully.

Step 3) Center the panadapter on 10.0 MHz. Until you can see it that won't mean much but do that. THEN

Step 4) create a Slice Receiver set to AM at 10.00 MHz. If all goes well, you should hear WWV through your speakers and/or headphones. NEXT display the panadapter which will show you WWV smack in the middle of the display.

BTW...good job! (again, for every line of code, be able to explain why it exists and what it does, not supposed to do but does).
(Edited)
Photo of James Whiteway

James Whiteway

  • 877 Posts
  • 193 Reply Likes
Thank you. Yes, I spend a lot of extra time commenting my code. When I find something that works, it is noted and that which causes problems, removed.
I'll definitely take your advice and do it one byte at a time!
james
WD5GWY
 

Photo of James Whiteway

James Whiteway

  • 877 Posts
  • 193 Reply Likes
For all those wondering,,,,,,,,,,,I'm getting data now! Drawing from a "live event" is fun! And a bit of a pain getting "right". But, things are getting better!
(dang DrawLine requires some hoops to jump thru)
Thanks Eric for all of your guidance. Not to mention patience.
james
WD5GWY