Limedrv: Difference between revisions
LucasTeske (talk | contribs) No edit summary |
LucasTeske (talk | contribs) (Finished basic preview) |
||
Line 112: | Line 112: | ||
channel. | channel. | ||
SetCenterFrequency(106.3e6). // Set Center Frequency | SetCenterFrequency(106.3e6). // Set Center Frequency | ||
SetAntennaByName(limedrv.LNAW). | SetAntennaByName(limedrv.LNAW). // Set LNAW Port | ||
SetLPF(1.5e6). | SetLPF(1.5e6). // Set LPF to 1 MHz | ||
EnableLPF(). | EnableLPF(). // Enable the LPF | ||
SetGainNormalized(0.2). | SetGainNormalized(0.2). // Set gain to 0.2 in Normalized value (0 -> 1) | ||
SetDigitalLPF(500e3). // Set Digital LPF (GFIR) to 500kHz | SetDigitalLPF(500e3). // Set Digital LPF (GFIR) to 500kHz | ||
EnableDigitalLPF(). | EnableDigitalLPF(). // Enable Digital LPF (GFIR) | ||
Enable() | Enable() // Enable the RX Channel | ||
log.Println("Starting LimeSDR") | log.Println("Starting LimeSDR") | ||
Line 129: | Line 129: | ||
dev.Stop() | dev.Stop() | ||
} | } | ||
</pre> | |||
[[File:limedrv-receiving-data.png]] | |||
You can also enable MIMO (on supported devices) by just enabling the second channel: | |||
<pre> | |||
dev.RXChannels[limedrv.ChannelA]. | |||
SetCenterFrequency(106.3e6). // Set Center Frequency | |||
SetAntennaByName(limedrv.LNAW). // Set LNAW Port | |||
SetLPF(1.5e6). // Set LPF to 1 MHz | |||
EnableLPF(). // Enable the LPF | |||
SetGainNormalized(0.2). // Set gain to 0.2 in Normalized value (0 -> 1) | |||
SetDigitalLPF(500e3). // Set Digital LPF (GFIR) to 500kHz | |||
EnableDigitalLPF(). // Enable Digital LPF (GFIR) | |||
Enable() // Enable the RX Channel channel. | |||
dev.RXChannels[limedrv.ChannelB]. | |||
SetCenterFrequency(106.3e6). // Set Center Frequency | |||
SetAntennaByName(limedrv.LNAH). // Set LNAW Port | |||
SetLPF(1.5e6). // Set LPF to 1 MHz | |||
EnableLPF(). // Enable the LPF | |||
SetGainNormalized(0.2). // Set gain to 0.2 in Normalized value (0 -> 1) | |||
SetDigitalLPF(500e3). // Set Digital LPF (GFIR) to 500kHz | |||
EnableDigitalLPF(). // Enable Digital LPF (GFIR) | |||
Enable() // Enable the RX Channel | |||
</pre> | </pre> | ||
[[File:limedrv-mimo-mode.png]] | |||
== Transmitting Samples == | == Transmitting Samples == |
Latest revision as of 03:09, 3 January 2019
What is Limedrv
Limedrv is a libLimeSuite Golang wrapper. It is designed to be easy of use and to be very easily integrated with any type of DSP inside go.
Getting Started
From now on, this article assumes that you know how to setup your golang environment and can build simple hello world programs. If you don't know or never played with GoLang, please refer to: https://golang.org/doc/install
Enumerating Devices
The first thing we need to be able to enumerate all devices that are plugged in. For that, let's create simple program that prints out every lime device that it finds.
package main import ( "github.com/myriadrf/limedrv" "log" ) func main() { devices := limedrv.GetDevices() log.Printf("Found %d devices\n", len(devices)) for i, v := range devices { log.Printf("%d: %s\n", i, v.DeviceName) } }
Now we can try to open the device and list its capabilities:
package main import ( "github.com/myriadrf/limedrv" "log" ) func main() { devices := limedrv.GetDevices() log.Printf("Found %d devices\n", len(devices)) if len(devices) == 0 { log.Fatal("No devices found!") } d := devices[0] log.Printf("Opening %s\n", d.DeviceName) dev := limedrv.Open(d) // Open the selected device defer dev.Close() // Defer the close of the device log.Println(dev) }
Receiving Samples
Receiving data is also simple with limedrv:
package main import ( "github.com/myriadrf/limedrv" "log" ) var stop chan bool var receivedSamplesChunk = 0 func OnSamples(data []complex64, channel int, timestamp uint64) { log.Printf("Received %d samples on channel #%d with timestamp %d\n", len(data), channel, timestamp) receivedSamplesChunk++ if receivedSamplesChunk == 10 { stop <- true } } func main() { stop = make(chan bool) // Create Stop Channel devices := limedrv.GetDevices() log.Printf("Found %d devices\n", len(devices)) if len(devices) == 0 { log.Fatal("No devices found!") } d := devices[0] log.Printf("Opening %s\n", d.DeviceName) dev := limedrv.Open(d) // Open the selected device defer dev.Close() // Defer the close of the device dev.SetCallback(OnSamples) // Set Samples Callback dev.SetSampleRate(3e6, 4) // Set Sample Rate to 2 msps and 4x oversampling // Get RX Channel 0 (A) channel := dev.RXChannels[limedrv.ChannelA] channel. SetCenterFrequency(106.3e6). // Set Center Frequency SetAntennaByName(limedrv.LNAW). // Set LNAW Port SetLPF(1.5e6). // Set LPF to 1 MHz EnableLPF(). // Enable the LPF SetGainNormalized(0.2). // Set gain to 0.2 in Normalized value (0 -> 1) SetDigitalLPF(500e3). // Set Digital LPF (GFIR) to 500kHz EnableDigitalLPF(). // Enable Digital LPF (GFIR) Enable() // Enable the RX Channel log.Println("Starting LimeSDR") dev.Start() <-stop // Block main routine waiting for stop signal log.Println("Stopping LimeSDR") dev.Stop() }
You can also enable MIMO (on supported devices) by just enabling the second channel:
dev.RXChannels[limedrv.ChannelA]. SetCenterFrequency(106.3e6). // Set Center Frequency SetAntennaByName(limedrv.LNAW). // Set LNAW Port SetLPF(1.5e6). // Set LPF to 1 MHz EnableLPF(). // Enable the LPF SetGainNormalized(0.2). // Set gain to 0.2 in Normalized value (0 -> 1) SetDigitalLPF(500e3). // Set Digital LPF (GFIR) to 500kHz EnableDigitalLPF(). // Enable Digital LPF (GFIR) Enable() // Enable the RX Channel channel. dev.RXChannels[limedrv.ChannelB]. SetCenterFrequency(106.3e6). // Set Center Frequency SetAntennaByName(limedrv.LNAH). // Set LNAW Port SetLPF(1.5e6). // Set LPF to 1 MHz EnableLPF(). // Enable the LPF SetGainNormalized(0.2). // Set gain to 0.2 in Normalized value (0 -> 1) SetDigitalLPF(500e3). // Set Digital LPF (GFIR) to 500kHz EnableDigitalLPF(). // Enable Digital LPF (GFIR) Enable() // Enable the RX Channel
Transmitting Samples
Currently limedrv only supports RX. But TX support is planned.
|