Welcome to the new FlexRadio Community! Please review the new Community Rules and other important new Community information on the Message Board.
If you are having a problem, please check the Help Center for known solutions.
Need technical support from FlexRadio? It's as simple as Creating a HelpDesk ticket.

Creating my own panadapter

edited May 8 in SmartSDR API
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
 

Answers

  • Mark ErbaughMark Erbaugh Member
    edited February 17
    I believe the panadapter data is in the form you need, the FFT
  • edited May 2015
    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
  • Stu Phillips - K6TUStu Phillips - K6TU Member ✭✭
    edited May 8
    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
  • edited May 8
    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
     
  • Stu Phillips - K6TUStu Phillips - K6TU Member ✭✭
    edited August 2016
    RR and good luck!  Part of the challenge is getting the sequence of commands to the radio that initial the pan adaptor stream - post you questions here on the Community as there are others who have trod this path before :-)

    Stu K6TU
  • edited May 2015
    Stu, I hate to sound ignorant, but, what exactly is a "bin"? I've been pouring over Panadapter.cs in Flexlib and I can see "some" things that the api is passing to the radio, but, not sure what will be returned and can be plotted on a graph. (much less how to go about doing so) 
       I have a bunch more questions to ask. But, wording them in a way that makes sense to others, (and maybe even to me!) isn't easy. A lot of things to learn and not near enough time to work on it!
    james
    WD5GWY

    
  • W4WHLW4WHL Member
    edited July 2016
    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







  • edited November 2016
    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

  • W4WHLW4WHL Member
    edited July 2016
    James,

    I was just explaining how to draw the data,  But getting the data from the API, I can't answer.

    Since I do not use the API I can't answer the question "Where do you get the data?"  But I would start by looking at VitaFFTPacket.cs.  But someone here may have the answer.

    William



  • edited May 2015
    Thanks again William. I knew you were not actually using Flexlib and that you were working directly with the Vita data stream with Java. (and quite impressively too)
    The information you posted does help. And I will look closely at VitaFFTPacket.cs. I'm sure it will turn out to be easier than I currently think it is!
    Just a bit frustrated at myself for letting my knowledge of VB and C# languish as much as I have. But, I'm determined to get back to some semblance of programming competence!
      I'll keep plugging away at it when I get back home in a few days. ( I don't dare take a good laptop with me, I'd end up sitting too much doing programming and not getting down the road! Boss wouldn't like that! )    :-)
    james
    WD5GWY
      
    
  • edited June 2015
    Well, still banging my head on this one! I have done as William suggested and looked at VitaFFTPacket.cs, but, it is not clear what data it is returning to the client and the correct formatting needed to build an array for my panadapter display.
      I'm not asking anyone to do all the work for me, but, some hints in C Sharp or even VB, would be nice. I'm not even certain that the data can be accessed from Flexlib. I have tried just getting some feedback by getting the FFTpacketCount:
    _thisRadio.ActiveSlice.Panadapter.FFTPacketTotalCount
    but, this just returns a value of zero with SSDR running! So, I'm certain I am not looking in the right place.
    Maybe I should just take up knitting!!!!  :-)
    james
    WD5GWY


  • W4WHLW4WHL Member
    edited July 2016
    James,

    I think SSDR running is part of your problem.  FFT data is going to smartSDR not your program.  Only one GUI client can connect to the radio at once. 

    Your program will need to process the instructions in radio.cs before and streams will be sent to your program.  Mainly these 2:

    client gui
    client udpport 499x

    These commands will not work if SSDR is running.  Once these commands have been ran. you should start seeing stream data such as FFT, waterfall, audio, dax, etc

    If you don't run these commands, the radio thinks the client is non gui, and only metering, and control data is sent.  None of the GUI data.  And since only one gui device can be on at a time. SSDR must be shut down.

    William
  • edited June 2015
    William, that explains a lot, thank you! for some reason, I had thought Flexlib would allow more than one client to consume the stream data. Or at least, mirror it.
    I had read an earlier post where Eric told someone that two gui clients were not supported, but, would be possible in a later version of Flexlib api. That was for one of the earlier versions of Flexlib api. I guess they have not added that ability yet!
    Looks like I will need to start learning how to parse the Vita packets properly. (once i get initializing the the radio correct)
       Again, thanks for your patience William. It is greatly appreciated.
    james
    WD5GWY

  • Walt - KZ1FWalt - KZ1F Member
    edited November 2016
    What you need to do is google fft. The source for flexlibis not designed to be a tutorial.
  • Walt - KZ1FWalt - KZ1F Member
    edited November 2016
    While that is entirely correct in Williams case I do not believe it's correct in James case because William is directly capturing each packet as it flows James is going to have to capture the on data received event. James, find and read Eric's 'First Steps With Flexlib' post.
  • edited June 2015
    Thanks Walt. I'll give it a look.
    james
    WD5GWY

  • edited June 2015
    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

  • Walt - KZ1FWalt - KZ1F Member
    edited November 2016
    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 June 2015
    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
     
    
  • edited June 2015
    Just so you know, I understand that Flexlib is not a tutorial. I wasn't asking for that. Googling FFT does not tell me what values to look for and in what form the data packets are being sent from the radio via Flexlib.
    I can get a Total Packet count, and packet error count. But, I do not see anything, (yet) looking at Panadapter.cs that tells me what the dll (Flexlib) is returning to the client to use to draw the panadapter. Same thing with the Waterfall data.
    None of the comments or code in Panadapter.cs say anything that appears to me to say "return this X,Y value to the client" application to build an array or otherwise, to use to build the panadapter in the client. I can draw graphs all day long. But, without knowing what the source is sending and how it's arranged, I cannot assume anything. 
      Again, I'm not asking for handouts or tutorials. But, I would think that someone, with C# experience and has actually used the data coming from the radio to the client via Fliexlib, could say which values to look for and to capture to use in building the panadapter display. Surely, that's not a secret.
    james
    WD5GWY
     
  • Walt - KZ1FWalt - KZ1F Member
    edited November 2016
    James, many of the answers you want are available already on here. You're not even close to the deep end yet. And you are right Eric's code is not a tutorial. Someone with C# experience? You do realize that eliminates most of the people who have done this, right?
  • edited June 2015
    Walt, I guess I'm just a bit frustrated. I look and look at panadapter.cs and there is no clear (to me) naming convention that this value is for the X position and this value is for the Y position in order to draw the display. Under the Vita api, there is this:
    VitaWaterfallPacket.cs that has more info and shows values more in line with what I expect. But, I've been told that Flexlib api  is where I need to be looking for the data to build the display.
       You say the answers I want are available, and if you're referring to what William has done, and has explained to me, then I guess I need to go back and reread what he has stated. I was under the impression he was parsing the raw data packets similar to what Enzo has done with his controller project.
      I thought William was also having to do the FFT's to the raw data to get what he needed for his panafall display. Stu said that the FFT work is already done in Flexlib and I should be able to get the info I need directly from there.
    So, maybe I'm missing something here. ( forest/trees)
       As for the C# experience statement I made, I'm willing to bet someone( not just Flex developers themselves) have been able to build a panafall display via Flexlib using C#.  I wish I had asked Steve at HAMCOM Saturday about the panafall display. Instead, we discussed what I might or might not be doing wrong connecting to the radio independent of SSDR. (and he had a presentation to do at HAMCOM as well)
       james
    WD5GWY
     
    
  • Walt - KZ1FWalt - KZ1F Member
    edited November 2016
    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 June 2015
    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
     
  • Walt - KZ1FWalt - KZ1F Member
    edited November 2016
    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
  • Stu Phillips - K6TUStu Phillips - K6TU Member ✭✭
    edited August 2016
    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




  • edited June 2015
    Oh yes it will help. And you're right, I'm sure I'll have more questions! :-)
  • edited August 2015
    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
     
    

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.