airspy / airspyone_firmware

AirSpy Firmware
http://airspy.com
GNU General Public License v2.0
152 stars 49 forks source link

Arbitrary sample rate support #15

Closed commthu closed 8 years ago

commthu commented 8 years ago

I need arbitrary sample rate, your sample rate is so limited for our applications

bvernoux commented 8 years ago

It is very hard (need lot of tests and experimentation) to do arbitrary sample rate and draw back is acquisitions will be less clean than 10MSPS (which is the best we can have). It is why in official firmware we do not want to add tons of sample rate which are not clean. For your case you need a custom firmware, then you need to define which sample rates are mandatory.

commthu commented 8 years ago

Now, I am using hackrf in our product, which has arbitrary sample rate. I require three extra sample rates 26M/3 7,680,000 9,830,400

if you have the above three sample rate, our product will use airspy, we can sell at least 100 per year.

bvernoux commented 8 years ago

It is not simple to have such sample rate with exact frequency what is your tolerance for those frequency (how many Hz) ?

commthu commented 8 years ago

7,680,000=1.92M * 4 9,830,400 = 19.2K * 512 Is it very difficult? Can you borrow the idea from the hackrf one. It can set to arbitrary sample rate.

bvernoux commented 8 years ago

AirSpy hardware is totally different vs HackRF hardware (especially the ADC part and tuner part) I do not understand why you are comparing them (the only common part is Si5351C and we are not using it like in HackRF because we have other constraints).

The main problem is when configuring the SI5351C to something multiple of what you want at end like 7,680,000 then the challenge is to produce in LPC with the same base clock an USB frequency of 480MHz for the USB HS (with exact frequency ...) it is possible for one sample rate or multiple sample rate with simple common divisor (like 2, 4, 8 ...) Also it is not possible today to reconfigure USB HS when you change sample rate (because USB will require a new USB enumeration until we find a hint to avoid that in a clean manner) so when you check your 3 sample rates they have not lot of thing in common like simple divisor ... And so the solution is not easy and really need more than just a configuration of SI5351C (at end it requires some tuning/change to avoid some potential spurs because of the differents clocks especially when you have 12bits ADC vs 8 or 7bits on other SDR).

commthu commented 8 years ago

understand! it seems very difficult to achieve the required sample rates.

2015-11-27 1:56 GMT+08:00 Benjamin Vernoux notifications@github.com:

AirSpy hardware is totally different vs HackRF hardware (especially the ADC part and tuner part) I do not understand why you are comparing them (the only common part is Si5351C and we are not using it like in HackRF because we have other constraints).

The main problem is when configuring the SI5351C to something multiple of what you want at end like 7,680,000 then the challenge is to produce in LPC with the same base clock an USB frequency of 480MHz for the USB HS (with exact frequency ...) it is possible for one sample rate or multiple sample rate with simple common divisor (like 2, 4, 8 ...) Also it is not possible today to reconfigure USB HS when you change sample rate (because USB will require a new USB enumeration until we find a hint to avoid that in a clean manner) so when you check your 3 sample rates they have not lot of thing in common like simple divisor ... And so the solution is not easy and really need more than just a configuration of SI5351C (at end it requires some tuning/change to avoid some potential spurs because of the differents clocks especially when you have 12bits ADC vs 8 or 7bits on other SDR).

On 26 November 2015 at 02:15, commthu notifications@github.com wrote:

7,680,000=1.92M * 4 9,830,400 = 19.2K * 512 Is it very difficult? Can you borrow the idea from the hackrf one. It can set to arbitrary sample rate.

— Reply to this email directly or view it on GitHub https://github.com/airspy/firmware/issues/15#issuecomment-159772579.

— Reply to this email directly or view it on GitHub https://github.com/airspy/firmware/issues/15#issuecomment-159969533.

bvernoux commented 8 years ago

I'm working on a new firmware unified with only one configuration file (per type of board) with different expansion points to do things like that (example custom multiple sample rates ...)

commthu commented 8 years ago

very good i am expecting

发自我的 iPhone

在 2016年2月9日,04:31,Benjamin Vernoux notifications@github.com 写道:

I'm working on a new firmware unified with only one configuration file (per type of board) with different expansion points to do things like that (example custom multiple sample rates ...)

— Reply to this email directly or view it on GitHub.

bvernoux commented 8 years ago

See https://github.com/airspy/firmware/commit/4a268e29c430c8e393d0a44434410abb80af7895 To have this new feature

commthu commented 8 years ago

when can you provide the firmware to custom multiple sample rates?

2016-02-13 18:28 GMT+08:00 Benjamin Vernoux notifications@github.com:

See 4a268e2 https://github.com/airspy/firmware/commit/4a268e29c430c8e393d0a44434410abb80af7895 To have this new feature

— Reply to this email directly or view it on GitHub https://github.com/airspy/firmware/issues/15#issuecomment-183640035.

bvernoux commented 8 years ago

The firmware have the ability to add easily custom sample rates. but the problem is the same as before (except now all configurations are located in one file) and you need to customize the file https://github.com/airspy/firmware/blob/master/common/airspy_nos_conf.c and add you own custom sample rate (I doubt you can add the 3 sample rates you want as they do not have simple common divisor like described before...).

andresv commented 8 years ago

I have only seen garbage with Rpi2, Odroid C1 and OrangePi 2 plus using 2.5 MSPS sample rate. 10 MSPS is fine, however these boards cannot keep up with such a high speed. So I was thinking of trying some more different samplerates to see if they differ from crappy 2.5 MSPS.

These are basically copy-pasted from 2.5MSPS configuration and I would like verify if they are correct before doing something stupid.

Is this correct for 2MSPS?

  /*
    airspy_sys_samplerate_t airspy_m4_conf
  */
  {
    /* PLL0AUDIO */
    0x00000000, // uint32_t pll0audio_mdiv;
    0x00000000, // uint32_t pll0audio_npdiv;
    0x00000000, // uint32_t pll0audio_ctrl_flags; DirectI=PLL0AUDIO_CTRL_FLAG_DIRECT_I or/and DirectO=PLL0AUDIO_CTRL_FLAG_DIRECT_O */
    /* IDIVB not used set it to 0 */
    3, // uint8_t adchs_idivb; /* 0 to 15 (0 means direct connection GP_CLKIN to ADCHS_CLK) */
    { 0, 0, 0 } /* uint8_t padding[3] */
  },
  /* airspy_m0_conf_t airspy_m0_conf */
  {
    1000000, // Freq 4MHz => 2MHz IQ => IF Freq = 1.00MHz (r820t_if_freq)
    0, // uint8_t r820t_bw;
    0, // uint8_t padding0;
    0 // uint16_t padding1;
  }
}

And I guess this should work for 1MSPS

  /*
    airspy_sys_samplerate_t airspy_m4_conf
  */
  {
    /* PLL0AUDIO */
    0x00000000, // uint32_t pll0audio_mdiv;
    0x00000000, // uint32_t pll0audio_npdiv;
    0x00000000, // uint32_t pll0audio_ctrl_flags; DirectI=PLL0AUDIO_CTRL_FLAG_DIRECT_I or/and DirectO=PLL0AUDIO_CTRL_FLAG_DIRECT_O */
    /* IDIVB not used set it to 0 */
    3, // uint8_t adchs_idivb; /* 0 to 15 (0 means direct connection GP_CLKIN to ADCHS_CLK) */
    { 0, 0, 0 } /* uint8_t padding[3] */
  },
  /* airspy_m0_conf_t airspy_m0_conf */
  {
    500000, // Freq 2MHz => 1MHz IQ => IF Freq = 0.50MHz (r820t_if_freq)
    0, // uint8_t r820t_bw;
    0, // uint8_t padding0;
    0 // uint16_t padding1;
  }
}

What about adchs_idivb, I can see that it is different in 2.5 and 10 configuration.

touil commented 8 years ago

The other half of the configuration you dismissed is very important. And no, the narrowest IF filter is about 1.5MHz with 500kHz offset near DC. It's not just about the sampling frequency. How about optimizing your DSP? We have proven that a RPi2 can not only stream 10MSPS but also do some useful work right at that sample rate.

andresv commented 8 years ago

I get only ca 4MSPS IQ datarate.

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.1.13-v7+ #826 SMP PREEMPT Fri Nov 13 20:19:03 GMT 2015 armv7l GNU/Linux

pi@raspberrypi:~ $ airspy_info
airspy_lib_version: 1.0.7

Found AirSpy board 1
Board ID Number: 0 (AIRSPY)
Firmware Version: AirSpy NOS v1.0.0-rc5-0-g648c14f 2015-05-20
Part ID Number: 0x6906002B 0x00000030
Serial Number: 0x406464C8234C734B
Supported sample rates:
    10.000000 MSPS
    2.500000 MSPS
Close board 1
pi@raspberrypi:~ $ airspy_lib_version
AirSpy lib version: 1.0.7

pi@raspberrypi:~ $ airspy_rx -f 435 -a 0 -r /dev/null
Device Serial Number: 0x406464C8234C734B
Stop with Ctrl-C
Streaming at 10.00 MSPS
Streaming at  8.62 MSPS
Streaming at  7.51 MSPS
Streaming at  6.62 MSPS
Streaming at  5.91 MSPS
Streaming at  5.35 MSPS
Streaming at  4.89 MSPS
Streaming at  4.53 MSPS
Streaming at  4.24 MSPS
Streaming at  4.01 MSPS
Streaming at  3.82 MSPS
Streaming at  3.66 MSPS
Streaming at  3.54 MSPS
Streaming at  3.44 MSPS
Streaming at  3.36 MSPS
Streaming at  3.36 MSPS
Streaming at  3.30 MSPS
Streaming at  3.25 MSPS
Streaming at  3.21 MSPS
^CCaught signal 2

User cancel, exiting...
Total time: 19.5387 s
Average speed 4.5809 MSPS IQ
done
touil commented 8 years ago

This issue looks more like user error than an actual issue. Use the raw 20MSPS stream and do the DSP properly. To test the streaming in embedded boards use: airspy_rx -p 1 -t 4 -r /dev/null

andresv commented 8 years ago

Hmm, it does not like packing.

pi@raspberrypi:~ $ airspy_rx -p 1 -t 4 -r /dev/null
Device Serial Number: 0x406464C8234C734B
airspy_set_packing() failed: AIRSPY_ERROR_LIBUSB (-1000)

I will check if my Airspy is running the latest firmware.

What is the data format with raw 20 MSPS stream?

touil commented 8 years ago

16bit int. You should update your firmware. Check the release page.

andresv commented 8 years ago

Updated to newest firmware and indeed this command produced constant 20MSPS. As I understand this is not IQ data so I cannot use it directly with my DSP functions.

touil commented 8 years ago

Riddle: What's the difference between DSP devs and Database devs?

sdrsemisharp commented 7 years ago

touil: When you stated the "other half of the configuration" was missed, were you referring to something other than the adchs_idivb that the poster failed to change in the posted code?

In my version, I replaced the 2.5 MSPS with 1 MSPS (set idivb to 9, IF freq to 500000). Data is streaming at 1 MSPS, but the spectrum is lopsided, perhaps a filter offset you mentioned in the comment.

Are the filter details available somewhere? Or am I missing another required change?

Thank you!

ON5HB commented 4 years ago

Is there any view on more sample-rates? As I really need 2048KSPS, 1024KSPS, 512KSPS. The reason for this is the use of websdr.org software, I have a driver that works with it, but I can not do anything with 2.5/3/5/6/10 MSPS as the software won't accept it. At the moment I'm usings SDRplay receivers, but I really want to replace them with Airspy as the SDRplay has weird (too small) filters.

Please consider some extra samplerates, it would solve so much problems for us.

Thanks.

Bas - ON5HB.

touil commented 4 years ago

Use the existing 4096 KSPS and decimate or resample. The SDR developers are supposed to be big boys who don't need spoon feeding.

ON5HB commented 4 years ago

Is of no use, as with multiple receivers it will overload the system. I use 3~4 receivers most of them 2048KSPS, to resample them all or decimate won't work. I really need lower sampling-rates.

touil commented 4 years ago

If I can do it without overhead, you also can do it. FYI. The hardware outputs 20MSPS and we process it in real time in the user mode library. Maybe you never noticed because it's fast enough. PS: Don't move to the hardware what you can do cheaply in software.

ON5HB commented 4 years ago

The software we use samples for 512 users at the same time, over a spectrum of about 6~8MHz. We convert everything to 8bit unsinged to supply the websdr.org software. I really need lower sampling-rates. If I set 1 receiver to 4MSPS all other will stop working and the one in question won't work properly. This is what I run: http://heppen.be:8091 I can not edit the software nor change it, the developer of the software won't change it. So we are stuck to what we can do. Ergo convert receivers that can supply the correct sampling-speed.

touil commented 4 years ago

I really need lower sampling-rates.

I think you need this book instead: https://www.amazon.fr/Understanding-Digital-Signal-Processing-United/dp/0137027419

touil commented 4 years ago

Have a look on GQRX DSP. There are some contributions from us to make it work in a RPi2. You can get some inspiration from there about efficient decimation.

ON5HB commented 4 years ago

You do know that in Belgium most speak Dutch do you? Also, we can't modify or change the application. That is a 1 user application, you really do not get the websdr.org concept do you? It handles 512 users at the same time in realtime.

touil commented 4 years ago

The only concept I get now is that someone is insisting on me doing his DSP homework.

ON5HB commented 4 years ago

No I do not want anybody to do homework, I build my own software, but I need proper sampling-speeds else it overloads and such receivers are useless to me. This needs to be done in firmware so the ADC outputs a lower rate.

touil commented 4 years ago

This needs to be done in firmware so the ADC outputs a lower rate.

You seem to be extremely proficient in designing SDRs. I invite you to try your idea in the firmware and push a PR. We will eventually merge it to the master if it works.

If, however, you discover that your concept doesn't work because you overlooked some hardware detail (which is very likely), I invite you to set the sample rate to 4096000 then use a 63 taps half band decimating filter.

ON5HB commented 4 years ago

Simple question, can the ADC output 2048KSPS or not? That is the only thing I want to know. If it can't the hardware is useless for me. I can not alter the application as it's not opensource. You seem keen on insulting me rather then answering my question. For me the samplerate needs to be the same as the RTL-dongle, so I can convert the output of the receiver to 8bit. I can not change the application nor put filters etc at it as it becomes far to slow. Again, can the Airspy output 2048 or not? If not, then there is no point going on.

touil commented 4 years ago

Simple question, can the ADC output 2048KSPS or not?

Yes.

That is the only thing I want to know.

Your loss.

Here's the filter optimized for your need. The most I can do for a lazy copy/paster. Half of the coefficients are zero and the center one is 0.5. If you are clever enough that's half of the calculations removed from your routine.

-0.000019807021255009 0.000000000000000000 0.000072339630463061 0.000000000000000000 -0.000195423626885880 0.000000000000000000 0.000442521177664431 0.000000000000000000 -0.000890846530289826 0.000000000000000000 0.001645039531616506 0.000000000000000000 -0.002841516323911096 0.000000000000000000 0.004655059705552502 0.000000000000000000 -0.007312392886000524 0.000000000000000000 0.011123384212266113 0.000000000000000000 -0.016555583162317176 0.000000000000000000 0.024421686696801372 0.000000000000000000 -0.036405357262517028 0.000000000000000000 0.056867554105228563 0.000000000000000000 -0.101893231388885650 0.000000000000000000 0.316883636060110940 0.500000000000000000 0.316883636060110940 0.000000000000000000 -0.101893231388885650 0.000000000000000000 0.056867554105228563 0.000000000000000000 -0.036405357262517028 0.000000000000000000 0.024421686696801372 0.000000000000000000 -0.016555583162317176 0.000000000000000000 0.011123384212266113 0.000000000000000000 -0.007312392886000524 0.000000000000000000 0.004655059705552502 0.000000000000000000 -0.002841516323911096 0.000000000000000000 0.001645039531616506 0.000000000000000000 -0.000890846530289826 0.000000000000000000 0.000442521177664431 0.000000000000000000 -0.000195423626885880 0.000000000000000000 0.000072339630463061 0.000000000000000000 -0.000019807021255009

ON5HB commented 4 years ago

So how do I make it output 2048, if I tell it to do so it tells me the samplerate is wrong. If I check the rates, it gives 3 and 6 MSPS. So how do I tell it to do it? What command is needed?

Nice, where do you put that stuff? I'm not a programmer like you.

touil commented 4 years ago

Check my answers above. Good luck!

ON5HB commented 4 years ago

I see a bunch of numbers, to do what and where? Do you put that in the firmware?

touil commented 4 years ago

Nice, where do you put that stuff? I'm not a programmer like you.

If you are not a programmer, please stop making noise on a programmers area. There are forums for that.

ON5HB commented 4 years ago

You really need to learn some manors sir. I simply asked a question if there where new sample-rates coming. That doesn't mean you have to be real prick!

touil commented 4 years ago

This is not a user support forum. This is a programmers collaboration tool. Everything else should go to either the forums, mailing list, or mail support. No exceptions. Thanks.

ON5HB commented 4 years ago

Clear, time to sell the device and not recommend Airspy to anybody, there are far more flexible devices on the market. Lesson learned.

touil commented 4 years ago

There are many WebSDR servers using Airspies out there. Maybe you should ask their owners how they did the trick. They will probably point to the same solution I proposed (they asked me and proposed the same).

ON5HB commented 4 years ago

Name me 1 websdr.org websdr that is running your device, just 1 is enough. You clearly do not know what you talking about. Else you would have checked, but you didn't. Check here: www.websdr.org then see what it is.

Spyserver and OpenWebRX are a joke, don't point me to those...they are NOT what we are doing.

touil commented 4 years ago

How about the most famous one? https://eshail.batc.org.uk/nb/ The QO-100 WebSDR running on an Airspy R2.

touil commented 4 years ago

I think at this point you should have some decency and go do your homework.

ON5HB commented 4 years ago

He uses just 512KSPS as spectrum with an i7, yeah you beaten me.....I use 6MSPS realtime, we tried with GNU-companion and it crashes, all the time. He uses a lot of CPU-power to down-sample...that is really what we all want to do.

touil commented 4 years ago

If you take a breath and open your eyes, you could probably figure out how to modify this script:

https://github.com/BritishAmateurTelevisionClub/eshail-ghy-nb-resample-airspy

ON5HB commented 4 years ago

I have used that tool from OpenWebRX, after you pipe it, that will work for a few KSPS but not for 2MSPS, also it gives a huge delay. There are other ways, you got me there, but not if you use multiple receivers.

touil commented 4 years ago

but not for 2MSPS

They are already using 2.5 MSPS => 512 KSPS. Maybe you just need 2.5 MSPS => 2.048 MSPS ?

ON5HB commented 4 years ago

I need plain 2048, from the device, so I can convert it. If lower are possible too it would be the max. At the moment we use devices for 512KSPS that output 2048 but we decimate in software. That takes a lot of CPU-power. With 1 receiver, it's all no problem, but if you want to serve loads of bands, it can't be done. If there would be firmware that makes the Airspy output 2048 as option (or better 1024 and 512 also) then it will be a bestseller at websdr.org

ON5HB commented 4 years ago

The SDRplay outputs 2048 or higher, that is a problem when we just need 512KSPS...as it puts us down on bandwidth we can process.