Comments (2)
Hello,
Please keep in mind that the branch you are using, with the modified Python bindings is still under development/review, so some things might slightly change until it is merged to master.
The getSamplesRawInterleaved(10000) will return 4*nb_samples elements in the Python list. In order to get samples faster, we don't copy all the samples into a list, we just return bytes. One sample on one channel for AnalogIn is represented on 2 bytes. That's why you have 40000 instead of 20000. The samples are indeed interleaved, so you will see one sample from CHANNEL_1, then one sample from CHANNEL_2. The difference is that a sample corresponds to 2 elements in the list.
Let's take an example:
Run:
samples = getSamplesRawInterleaved(10)
samples.tolist()
will return something like this
[243, 255, 2, 0, 246, 255, 2, 0, 244, 255, 2, 0, 246, 255, 2, 0, 244, 255, 2, 0, 244, 255, 1, 0, 243, 255, 0, 0, 245, 255, 3, 0, 245, 255, 2, 0, 245, 255, 2, 0]
and samples.tobytes()
will return
b'\xf3\xff\x02\x00\xf6\xff\x02\x00\xf4\xff\x02\x00\xf6\xff\x02\x00\xf4\xff\x02\x00\xf4\xff\x01\x00\xf3\xff\x00\x00\xf5\xff\x03\x00\xf5\xff\x02\x00\xf5\xff\x02\x00'
[243, 255] correspond to the first sample on CHANNEL_1
[2, 0] correspond to the first sample on CHANNEL_2
In order to convert all the samples you can use the following chunk of Python code:
import struct
#..enable channels, acquire samples
samples = samples.tobytes()
count = int(len(samples)/2)
value_list = struct.unpack('h'*count, samples) #'h' is the format for short
value_list will be similar to the following: (-13, 2, -10, 2, -12, 2, -10, 2, -12, 2, -12, 1, -13, 0, -11, 3, -11, 2, -11, 2)
Next thing is to convert it into Volts. In Python, for AnalogIn() you have 2 exposed methods: convertRawToVolts(channel, raw) and convertVoltsToRaw(channel, voltage).
Running convertRawToVolts(0, value_list[0]) (in the case we described above) should get you the Volts value that you need.
Regarding your questions about the formula parameters: filterCompensation changes if you modify the sample rate, some of the coefficients change if you recalibrate the board, and one might change if you modify the RANGE of the AnalogIn.
For the multiprocessing part: You can open up a context in the second process (without doing any calibration, or modifying any attributes in it) and just use it to run convertRawToVolts on the samples transfered from the first process.
The first process could run m2kOpen() (connect through USB), then calibrate the board, enable channels, set sample rates and run getSamples, then send those samples to the second process.
The second process could run m2kOpen("ip:192.168.2.1"), get a handler for the AnalogIn and just convert all the samples using convertRawToVolts(channel, raw). (The second process will know what values to use for the conversion coefficients).
We will add these explanations regarding new Python exposed methods to the documentation as soon as possible.
Did I manage to answer your questions? Please let me know if something is not clear.
Thank you,
-Alexandra
from libm2k.
These instructions were added to the libm2k Doxygen Documentation. ( https://analogdevicesinc.github.io/libm2k/#faq )
I think we can close this.
from libm2k.
Related Issues (20)
- A small detail HOT 1
- SPI Clock Rate HOT 1
- spi_write_and_read() func does not work in version 0.5 HOT 8
- libm2k Runtime Error in Raspbberry Pi HOT 9
- Modifying the status of unused DIO pins after configuring SPI or I2C interfaces in the python bindings. HOT 8
- libm2k spi_write_and_read() function getting stuck when called multiple times HOT 9
- libm2k spi functionality in python HOT 1
- Understanding the ADALM 2000 sample rate HOT 2
- Cannot build libm2k HOT 2
- discrete values of analog out sample rate not communicated HOT 1
- ADALM2000 dac push function cause reset
- Using 64-bit labview truncates 64-bit handle (address) to 32-bit HOT 2
- 'LIBM2K_ENABLE_LOG' error with MSVC
- Add compute calibration parameters without writing to the board API HOT 1
- Please add Python 3.11 support HOT 4
- How to set sampling frequencies <100k? HOT 5
- DLL load failed on Windows
- returns none when I try getAvailableSampleRates();
- M1 Mac platform not supported HOT 3
- Python examples + threading or so. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libm2k.