Improving BITalino time stamps

Functionality, Add-ons, etc.
AuthorOfTheSurf
Posts: 5
Joined: Tue Jan 27, 2015 4:26 pm

Improving BITalino time stamps

Postby AuthorOfTheSurf » Sun Feb 08, 2015 5:40 am

The project I am doing requires precision in the matter of when the bitalino data readings occur. The datestamp inside the outputted bitalino .txt file is only accurate to the nearest second. It is possible to improve the precision of this time stamp to milliseconds? This would allow me to know the datetime of every sample when I run on 1000hz mode.

BITalino
Site Admin
Posts: 554
Joined: Tue Aug 27, 2013 3:47 pm

Re: Improving BITalino time stamps

Postby BITalino » Sun Feb 08, 2015 8:14 am

Hi there,

Not sure we've understood correctly... you'd like to have a time stamp from an RTC? As you've surely seen, the BITalino firmware sends a 4-bit sequence number in every data packet; this is accurate to the millisecond and the clock providing the interrupts to the MCU is a crystal resonator (very precise).

As such, provided that you count the number of received packets you'll be able to determine the relative time elapsed since the first packet generated at the device. A precise defence to the absolute time is harder to get without an RTC on the device, due to the Bluetooth channel latency.

Nevertheless, a BITalino firmware is available on GitHub, and we've recently launched a basic data sheet for the MCU; one option is for you to change the firmware and/or protocol to your desired behaviour.
https://github.com/BITalinoWorld/firmware-bitalino
http://bitalino.com/datasheets/MCU_Block_Datasheet.pdf

Best regards,
The BITalino Team

AuthorOfTheSurf wrote:The project I am doing requires precision in the matter of when the bitalino data readings occur. The datestamp inside the outputted bitalino .txt file is only accurate to the nearest second. It is possible to improve the precision of this time stamp to milliseconds? This would allow me to know the datetime of every sample when I run on 1000hz mode.

AuthorOfTheSurf
Posts: 5
Joined: Tue Jan 27, 2015 4:26 pm

Re: Improving BITalino time stamps

Postby AuthorOfTheSurf » Mon Feb 09, 2015 9:11 pm

The work i've been doing so far has been on the .txt data files that Open Signals puts out when I stop recording. They look like

Code: Select all

# JSON Text File Format
# {"SamplingResolution": "10", "SampledChannels": [1], "SamplingFrequency": "1000", "ColumnLabels": ["SeqN", "Digital0", "Digital1", "Digital2", "Digital3", "EMG"], "AcquiringDevice": "98:D3:31:XX:XX:XX", "Version": "111", "StartDateTime": "2015-2-2 10:30:2"}
# EndOfHeader
0   1   1   1   1   467   
1   1   1   1   1   467   
2   1   1   1   1   472   
3   1   1   1   1   476   

The date time I am referring to is the "StartDateTime" field that you see in there. The way you are talking about things makes it seem like there is an alternate format for this data that the BITalino can produce.

What do I need to do to see/use this format that has the more detailed date times? Do I need to install the firmware you linked? What is different in the firmware from the software my BITalino Plugged was shipped with?

BITalino
Site Admin
Posts: 554
Joined: Tue Aug 27, 2013 3:47 pm

Re: Improving BITalino time stamps

Postby BITalino » Mon Feb 09, 2015 11:35 pm

Hi,

We thought you were working at the MCU / firmware level. From the file, you can use the time listed in the "StartDateTime" (the header is in JSON format, which unravels directly into dictionaries in most mainstream languages, thus facilitating the programatic access to it), and the add 1 millisecond per line (@1000Hz).

Each line corresponds to a sample, which is accurate and spaced by 1 millisecond (@1000Hz). Unless you detect a gap in the first column (the normal behaviour is 0-15 repeatedly), the time computed from the "StartDateTime" offset will be accurate.

Our suggestion in the previous reply was for a way of having each sample marked with a date/time similar that found in "StartDateTime", but generated at the device. Honestly it may not be needed, but we can provide additional information on that (although it requires external hardware and MCU programming skills).

Best regards,
The BITalino Team

AuthorOfTheSurf
Posts: 5
Joined: Tue Jan 27, 2015 4:26 pm

Re: Improving BITalino time stamps

Postby AuthorOfTheSurf » Tue Feb 10, 2015 2:16 am

Is the StartDateTime field accurate to milliseconds? This would be the case if BITalino recordings only started at the nearest second. If not, then that means that I cannot know with accuracy when the data lines occurred. I am familiar with what you are talking about regarding knowing when a line occurred by treating it as an offset. I also understand the parsing of the StartDateTime field into a datetime in a language (I'm using Python here).

So basically, I want to know if can I treat

Code: Select all

"StartDateTime": "2015-2-2 10:30:2"

as

Code: Select all

"StartDateTime": "2015-2-2 10:30:2.000"

So that I may know that line 3 occured at 10:30:2.002, and know that line 1000 occurred at 10:30:3.000 and so on.

I agree that I do not need the date stamped on each line, nor do I want to monkey with low-level hardware stuff unnecessarily, I just need to confirm the precision of the StartDateTime field.

BITalino
Site Admin
Posts: 554
Joined: Tue Aug 27, 2013 3:47 pm

Re: Improving BITalino time stamps

Postby BITalino » Tue Feb 10, 2015 8:27 am

Got it now... that's not accurate to the millisecond; thanks for the suggestion, which should be included in the new release (to be launched) later this month or in March at most.

For the time being, you should be able to change the behaviour of your existing OpenSignals installation by going to the folder, and editing the file 'code/writefile.py' on Line 241 to format the 'StartDateTime' header field according to your preference.

Best regards,
The BITalino Team

AuthorOfTheSurf
Posts: 5
Joined: Tue Jan 27, 2015 4:26 pm

Re: Improving BITalino time stamps

Postby AuthorOfTheSurf » Fri Feb 13, 2015 3:21 am

Hey, thanks for staying with me on this one. I was able to make the change to get the millisecond precision.

Code: Select all

dict['StartDateTime'] = date.isoformat(" ")
>>> "2015-02-12 19:08:11.789000"


One note is that the `code/` folder doesn't exist on the Linux version of OpenSignals, only Windows.

BITalino
Site Admin
Posts: 554
Joined: Tue Aug 27, 2013 3:47 pm

Re: Improving BITalino time stamps

Postby BITalino » Fri Feb 13, 2015 9:16 am

Hi there,

Great to hear that you've managed to get everything setup to your preference.

Indeed we have assumed you'd be using the Windows version... sorry for that ;)

Best regards,
The BITalino Team


Return to “Features”