[beagleboard] Re: BBB Libpruio Analog Data
16 bit = 2 byte! Parsing the buffer in JavaScript code: const val = new Uint16Array(Buffer); // val.length = 1 (2 channels x 5000 samples) // output raw data: integer from 0 (=0V) to 4095 (=1V8) console.log(val[0], val[1]); // first samples AIN-1, AIN-2 console.log(val[2], val[3]); // second samples AIN-1, AIN-2 ... // output voltage: foating point from 0.0 V to 1.8 V const f = 1.8 / 4095; console.log(f*val[0], f*val[1]); // first samples AIN-1, AIN-2 console.log(f*val[2], f*val[3]); // second samples AIN-1, AIN-2 ... -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/37dbce3e-7e07-4299-be5c-e67ea2250a50n%40googlegroups.com.
[beagleboard] Re: BBB Libpruio Analog Data
Hello TJF, Thank you for the explanation that is very useful! With parsing the file, I'm doing that in Node-Red reading in the file as a binary buffer, but for some reason the buffer is 4x the number of sampling points I set. Like let's say I tell the script to sample the analog inputs 5000 times, the file will come back with 2 when I read it into Node-Red (I'd expect 1 points since I'm using 2 analog inputs). What could be the cause? Thanks! On Wednesday, March 10, 2021 at 2:26:30 PM UTC-5 TJF wrote: > Hi! > > ritesh...@gmail.com schrieb am Dienstag, 9. März 2021 um 21:15:01 UTC+1: > >> Specifically, they are collecting the data using Ring Buffer mode and >> saving it to a text file to be processed further for some feature >> extraction and further analysis. >> >> What I'm trying to understand is this: how does Ring Buffer sampling >> actually work? As in, if I'm reading data using two analog inputs and >> saving it to a text file, what order are the values in? How do I parse them >> into meaningful sensor values? I've attached the C code I'm working with, >> and greatly appreciate any help or pointers! >> > > Your code doesn't save to a text file. Instead it saves the raw data to a > binary file. The unshifted values (0-4095) are stored as 16-bit (unsigned > short) binary numbers in the order as captured, like > > AIN-1, AIN-2, AIN-1, AIN-2, AIN-1, AIN-2, AIN-1, AIN-2, ... > > In order to parse the file, just read it into a buffer and access that > buffer by a unsigned short pointer variable. 0 (null) means 0V, 4095 means > 1V8. So multiply the unsigned shorts by the factor 1.8/4095 to get the > voltage as a real value. > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/c5efd6f1-2dd7-48ee-a693-182a8710f539n%40googlegroups.com.
[beagleboard] Re: BBB Libpruio Analog Data
Hi! ritesh...@gmail.com schrieb am Dienstag, 9. März 2021 um 21:15:01 UTC+1: > Specifically, they are collecting the data using Ring Buffer mode and > saving it to a text file to be processed further for some feature > extraction and further analysis. > > What I'm trying to understand is this: how does Ring Buffer sampling > actually work? As in, if I'm reading data using two analog inputs and > saving it to a text file, what order are the values in? How do I parse them > into meaningful sensor values? I've attached the C code I'm working with, > and greatly appreciate any help or pointers! > Your code doesn't save to a text file. Instead it saves the raw data to a binary file. The unshifted values (0-4095) are stored as 16-bit (unsigned short) binary numbers in the order as captured, like AIN-1, AIN-2, AIN-1, AIN-2, AIN-1, AIN-2, AIN-1, AIN-2, ... In order to parse the file, just read it into a buffer and access that buffer by a unsigned short pointer variable. 0 (null) means 0V, 4095 means 1V8. So multiply the unsigned shorts by the factor 1.8/4095 to get the voltage as a real value. -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/fd15170d-98ce-430a-8d20-34a63fe212b5n%40googlegroups.com.