-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
283ac59
commit 27f2e95
Showing
10 changed files
with
1,348 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ vignettes/*.pdf | |
.Renviron | ||
|
||
# pkgdown site | ||
docs/ | ||
#docs/ | ||
|
||
# translation temp files | ||
po/*~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Using Raspberry Pi Pico with sensor LSM303 | ||
|
||
- Download package [Adafruit](https://circuitpython.org/libraries) CircuitPython | ||
- Install Firmware Circuitpython ([Adafruit](https://circuitpython.org/libraries)) | ||
|
||
# RPi pico serial comm out | ||
|
||
File: *code.py* | ||
|
||
```python | ||
|
||
import time | ||
from math import atan2, degrees | ||
import board | ||
import digitalio | ||
import adafruit_lsm303_accel | ||
import adafruit_lsm303dlh_mag | ||
import busio | ||
|
||
# Initialize Board LED | ||
led = digitalio.DigitalInOut(board.LED) | ||
led.direction = digitalio.Direction.OUTPUT | ||
|
||
# Initialize I2C | ||
sda_pin = board.GP0 | ||
scl_pin = board.GP1 | ||
i2c = busio.I2C(scl_pin, sda_pin) | ||
|
||
# Initialize the accelerometer | ||
sensor = adafruit_lsm303_accel.LSM303_Accel(i2c) | ||
mag = adafruit_lsm303dlh_mag.LSM303DLH_Mag(i2c) | ||
|
||
# Initialize UART | ||
tx_pin_uart = board.GP4 | ||
rx_pin_uart = board.GP5 | ||
uart = busio.UART(tx=tx_pin_uart, rx=rx_pin_uart, baudrate=19200) | ||
|
||
def vector_2_degrees(x, y): | ||
angle = degrees(atan2(y, x)) | ||
if angle < 0: | ||
angle += 360 | ||
return angle | ||
|
||
def get_inclination(_sensor): | ||
x, y, z = _sensor.acceleration | ||
return vector_2_degrees(x, z), vector_2_degrees(y, z) | ||
|
||
def get_heading(mag): | ||
magnet_x, magnet_y, _= mag.magnetic | ||
return vector_2_degrees(magnet_x , magnet_y) | ||
|
||
|
||
led.value = True # LED on while transmitting | ||
while True: | ||
# Get inclination angles | ||
angle_xz, angle_yz = get_inclination(sensor) | ||
heading = get_heading(mag) | ||
|
||
# Format the message | ||
# message = "[{}, {}, {}]\r\n".format(angle_xz, angle_yz, heading) | ||
message = f'{angle_xz},{angle_yz},{heading}' | ||
print(message) | ||
# Send the message via UART | ||
uart.write(message.encode('utf-8')) | ||
|
||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
## [⬅️](../README.md) | ||
|
||
<!-- | ||
https://tutorialmarkdown.com/emojis | ||
--> | ||
|
||
# Driver UHD and GNURadio software installation | ||
|
||
This file provides instructions for installing the UHD (USRP Hardware Driver) and GNURadio software on a Windows x64 system. It includes links to the necessary drivers and packages from Ettus Research, as well as steps for setting up the environment variables required for the installation. This document is intended to guide users through the process of configuring their system to work with UHD and GNURadio on a Windows OS. | ||
|
||
## For Windows x64 | ||
|
||
Links UHD-USRP: | ||
|
||
- [Ettus UHD](https://files.ettus.com/binaries/uhd_stable/uhd_004.006.000.000-release/4.6.0.0/Windows-10-x64/) | ||
|
||
- Ettus USRP [Driver (Windows)](https://files.ettus.com/manual/page_transport.html#transport_usb_installwin) | ||
|
||
Set Drivers: | ||
|
||
|*On User variables > Path:*|Add path of package UHD| | ||
|-|-| | ||
|Variable name:| `Path`| | ||
|Variable value:| `C:\Program Files\UHD`| | ||
|
||
|*On System variables:*|Create path of Driver USRP| | ||
|-|-| | ||
|Variable name:| `UHD_IMAGES_DIR`| | ||
|Variable value:| `C:\Program Files\UHD\share\uhd\images`| | ||
|
||
<br> | ||
|
||
 | ||
|
||
- Copy the file "libusb-1.0.dll" to the path | ||
```C:\Windows\System32``` | ||
|
||
- Test the installation in CMD with USRP connected: | ||
|
||
``` | ||
>> uhd_find_devices | ||
``` | ||
 | ||
<br> | ||
# Using GNU Radio:<br> | ||
Download directly GNURadio [Radioconda](https://wiki.gnuradio.org/index.php/InstallingGR) (Recomended) and install package <i>radioconda.exe</i> | ||
## Installing packages whit conda using terminal | ||
*(Run CMD or PowerShell as administrator)* <br> | ||
Example: adding packages for use <i>uhd package</i> on <i> Jupiter Noteboook </i> for VS Code: | ||
``` | ||
>> cd C:\ProgramData\radioconda\Scripts | ||
>> conda.exe install ipykernel --update-deps | ||
``` | ||
- Modifying conda executables for convenience:<br> | ||
*(Only if we have other versions of python already installed)* | ||
|Change| To| | ||
|-|-| | ||
|`C:\ProgramData\radioconda\Scripts\conda.exe`|`C:\ProgramData\radioconda\Scripts\radioconda.exe`| | ||
|`C:\ProgramData\radioconda\Scripts\conda-script.py`|`C:\ProgramData\radioconda\Scripts\radioconda-script.py`| | ||
and <i>Add Environment variable</i> `C:\ProgramData\radioconda\Scripts` | ||
<!-- ## Linux Ubuntu 22 --> | ||
Documentation PySDR -API: | ||
- [PySDR: A Guide to SDR and DSP using Python](https://pysdr.org/content/usrp.html) | ||
# Example: Using UHD python API [🔝](#driver-uhd-and-gnuradio-software-installation) | ||
Example test for Rx: | ||
```python | ||
import uhd | ||
import numpy as np | ||
usrp = uhd.usrp.MultiUSRP() | ||
# Model: B200 | ||
# serial number: 31BA1B2 | ||
num_samps = 10000 # number of samples received | ||
center_freq = 100e6 # Hz | ||
sample_rate = 1e6 # Hz | ||
gain = 50 # dB | ||
usrp.set_rx_rate(sample_rate, 0) | ||
usrp.set_rx_freq(uhd.libpyuhd.types.tune_request(center_freq), 0) | ||
usrp.set_rx_gain(gain, 0) | ||
# Set up the stream and receive buffer | ||
st_args = uhd.usrp.StreamArgs("fc32", "sc16") | ||
st_args.channels = [0] | ||
metadata = uhd.types.RXMetadata() | ||
streamer = usrp.get_rx_stream(st_args) | ||
recv_buffer = np.zeros((1, 1000), dtype=np.complex64) | ||
# Start Stream | ||
stream_cmd = uhd.types.StreamCMD(uhd.types.StreamMode.start_cont) | ||
stream_cmd.stream_now = True | ||
streamer.issue_stream_cmd(stream_cmd) | ||
# Receive Samples | ||
samples = np.zeros(num_samps, dtype=np.complex64) | ||
for i in range(num_samps//1000): | ||
streamer.recv(recv_buffer, metadata) | ||
samples[i*1000:(i+1)*1000] = recv_buffer[0] | ||
# Stop Stream | ||
stream_cmd = uhd.types.StreamCMD(uhd.types.StreamMode.stop_cont) | ||
streamer.issue_stream_cmd(stream_cmd) | ||
print(len(samples)) | ||
print(samples[0:10]) | ||
``` | ||
|
||
## UHD error [🔝](#driver-uhd-and-gnuradio-software-installation) | ||
|
||
- [UHD utility function rx_samples_to_file incorrectly errors out for "RX channel out of range"](https://github.com/EttusResearch/uhd/issues/723) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.