How to practically increase sample rate?

edited May 2017 in Wifi Shield
[original new thread title: "How to practically increase sample rate with Bluetooth transmission (bypassing the OBCI Dongle)?"]

----

Hello everyone,
I already red some discussions touching the topic of increasing the sample rate while streaming the data to a PC over bluetooth (I have a Cyton and I use it for sEMG acquisition for research purposes), but I was not able to really figure out which exactly is the best/simplest solution, so I hope to help also other people in the community with this post, that could clarify the topic.

As far as I have understood, if I want to change the sample rate from 250 SPS to 1000 SPS, first I should modify in the library the file OpenBCI_32_Daisy.cpp, according with the following discussion: http://openbci.com/forum/index.php?p=/discussion/614/change-sampling-rate-frequency .
Then, in order to obtain also the stream of the data to a PC at such frequency (1000 SPS), it seems to be necessary to bypass the OBCI Dongle, for example establishing a connection to another bluetooth 2.0 receiver. I have two questions about this point: 1) am I right? , 2) how to practically do that? Can someone explain the steps to do that?

Finally, in general, if someone could clarify all the steps to increase the sample rate (and the bluetooth streaming) to 1000 SPS could be great for me and my research.

Thank you in advance for your time,
Roberto

Comments

  • wjcroftwjcroft Mount Shasta, CA
    Bonzo, hi.

    I've moved your thread from General Discussion to this Category on the Wifi Shield. Please see the other post in this Category,


    That shield is currently undergoing beta testing with a group of testers. It's possible you may be able to join that group. I'm mentioning AJ @pushtheworld, in case he might have an update.

    There are some earlier posts in the forum regarding Bluetooth breakout boards (HC-01, etc.) and wired usb. These are older approaches and do not have the benefit of the latest firmware, which AJ has developed. But you can use the Advanced Search box in the right column of the forum here to search if you are interested in the history.

    Regards,

    William

  • edited May 2017

    @Bonzo you can change the sample rate using the wifi shield with just a simple command. i.e. i did the hard work for you in modifying the code to work at higher rates.

    https://github.com/OpenBCI/OpenBCI_32bit_Library/tree/dev-3.0.0

    This code is still in beta but is working well and if you are located in the US, we have one wifi shield left for a beta tester.

  • Thank you very much wjcroft and pushtheworld for your kind interest.

    Unfortunately I am located in Europe, Italy.

    So, if I got it, uploading the code you linked from github will make the OBCI board working at 1000 SPS? or do I have to use it with the wifi shield?

    Thank you again for your help.

    Roberto
  • @Bonzo

    Hey! Yes you will have to wait till the wifi shield goes on sale next month or so.

    You could also use the external serialport to get 8 channels at 1000Hz using that same code. Are you interested in that?
  • Yes, I am absolutely interested in 8 channels at 1 kHz.
    What do you mean exactly with "use external serial port [...] using that same code"?
    Thanks.
  • Hey @Bonzo, right now all my energy is on finishing the docs for openbci wifi shield which will safely do 1kHz. I will make an example of how to use the external serialport shortly after I finish these docs. I spent some time looking at using the Serial1 for the Wifi shield but unfortunately, it was ultimately too slow because it could never break 480200 baud which as you can do the math is only 500Hz. For some reason, that serialport went down at any higher baud. Please stay tuned for the when the wifi shield goes on sale!
  • I have tried to update the baudrate of the radio "device" and "host" and the sample rate of the "pic", but for some reason it doesn't work: once the radio host and device are "flashed", it is not possible to communicate with the OPBCI board to upgrade the pic firmware (error "target not found" all the time). So now I came back to the original firmware. (If someone have tips about this operation, it is more than welcome).

    Thank you all for your kind interest and answers.
  • @bonzo ;

    Were you able to verify the radio communication system was up using the GUI?

  • Yes I used the GUI to verify the communication, and the response from the GUI was negative.
  • Ok so your radios were not on the same channel is the best answer to your problem. Did you hit Autoscan to fix the problem?
  • Autoscan didn't work: "Error connecting to the serial port". I don't think the problem is the wrong channel, because when I go back to the baud rate value of 115200, then it works again. I would say that radios are not able to communicate at higher baud rates.

    Could I be right?
  • Until you have firmware version two working properly, run everything at 115200 baud. The system MUST report "Success: System is Up$$$" in that radio config box in the GUI in order for you to have a shot at programming the Pic32.

    Does that make sense?
  • edited May 2017
    @pushtheworld

    Yes, actually I could try to first reprogram the Pic32 communicating at 115200 baud. Anyway, I was following the "correct" procedure as suggested in the guidelines:

    1. reprogram the device radio
    2. reprogram the host radio
    3. reprogram the Pic32

    If I first reprogram the Pic (that is, change sample rate to 1 kHz and board's baud rate to 460800) then, if the radios don't work at higher baud rates (as I'm suspecting), there is the possibility that I will not be able anymore to reprogram the Pic and reestablish the communication with the board.

    I am not sure if I am right, but I am "scared" to permanently "lose" the communication with the board. Could be possible?


  • edited May 2017
    1. No there is no permanent way to lose comms
    2. Do NOT set or change the pic baud rate on Serial0
    3. Do NOT set the sample rate yet, leave at 250
  • Ok, maybe I have no very clear ideas (I am absolutely not an expert), so I apologize in advance if I am wrong with very basic concepts.

    As far as I was able to understand:

    Since my goal is to reach 8 channels at 1kHz, if I don't change the baud rate and I don't change the sample rate...  how I can realize that?

    For my knowledge, it is not clear the meaning of "set or change the pic baud rate on Serial0 ". The changes that I was trying to do were (without good results):

    1. increase the baud rate in "OpenBCI_Radios_Definitions.h" (setting "#define OPENBCI_BAUD_RATE_DEFAULT 115200" to "#define OPENBCI_BAUD_RATE_DEFAULT 460800")
    2. reprogram the device radio and then the host radio
    3. increase sample rate in "OpenBCI_32bit_Library.cpp" (that is setting "WREG(CONFIG1,0xB6,BOARD_ADS);" to "WREG(CONFIG1,0xB4,BOARD_ADS);")
    4. increase the baud rate in "OpenBCI_32bit_Library_Definitions" (that is setting "#define OPENBCI_BAUD_RATE 115200" to "#define OPENBCI_BAUD_RATE 460800")
    5. reprogram the Pic32 (...failing)

    Is there something with sense in what I was trying to do? In case, could you clarify some concepts?
    Thank you very much.
  • edited May 2017
    Toally get you are new and i tried the same things you did when i first got started! However they all failed, do not change the default baud rate from 115200 because the RFDuino Device on board is expecting 115200, and no, you cannot change the RfDuino to anything above 115200 because it prevents the successful transmission of data. The bottle neck here is that the RFDuino device cannot accept grater then 115200. Does this concept make sense?

    Next concept: using Serial1 with an optoisolator hardwired tp your laptop will support a higher sample rate. This can lead to shock if you hooked up wires incorrectly so no one recommends this. Thats why the wifi shield is a big deal.... it uses SPI instead of UART which is much faster and allows for a much greater then 1kHz
  • edited May 2017
    Ok, I got it! Thank you!

    Another possibility should be to connect the Serial 1 of the board to an external bluetooth module, do you know (or do you have) any tutorial on how to hw&sw implement such solution? (something with more information than this: http://openbci.com/community/openbci-with-android-as-graduation-project/).
  • Hey all,

    Sorry for the delay! I have been working so hard on the wifi shield that I have not been on the forum!

    We have 200 OpenBCI Wifi Shields in production right now! We are about two weeks into production so we should have boards back in two weeks. 

    The OpenBCI Wifi shield features will be locked down on June 30th. You can see what I'm working on here: https://github.com/OpenBCI/OpenBCI_WIFI/issues

    I've really been having a lot of fun with this project! Working with marion and cloudbrain to have direct to cloudbrain capability. That's going over the MQTT protocol

    I'm all about these http requests to get information from the OpenBCI board! You can see all the specs for the HTTP REST Api Server that runs on the OpenBCI Wifi Shield https://app.swaggerhub.com/apis/pushtheworld/openbci-wifi-server/1.1.0

    You can GET information like the number of channels (4, 8, 16), connection health status for TCP and MQTT protocols, if you're like me and just want to stream you can now call from any web browser, phone, computer, pretty much anything with an internet connection, to start streaming.

    You can POST information such as board commands like "z011Z" to run impedance tests on channel 1, or POST to establish a new MQTT or TCP (and soon WEBSOCKETS!!) connection and start streaming data.

    We are getting great sample rates with the RAW mode, where the wifi shield sends raw byte stream data over TCP in the same 33byte format as the standard OpenBCI stream protocol for the Cyton. We were able to hook the wifi shield in raw mode up to our node_js driver in about 30 minutes, just by calling the processBytes call from the tcp on data event! It was awesome! In JSON, which is a still work in progress mode we are working through the final implementations and test results will be out soon. In JSON format, we follow LSL stream protocols, for example {"timestamp":12349292929, "data":[992922.3, 392923.0, 29393.0, 233294.0]} it's really fun! For this one we wrote a patch into the Cyton/Ganglion source code to send the channel gains to the Wifi shield right before we started streaming. Using our well-tested protocols for message passing between micro controllers, we were able to start converting the channel data to doubles with the correct scale factors, always. The timestamps come from NTP, or the Network Time Protocol. We are working on more validation but we are optimistic we will be able to get NTP with beyond acceptable precision. 

    The features are really coming together nice! There are a couple more I'll talk about soon! Expect shields soon! Will be on sale for less than $150 for sure! Ok I'm getting back to work! Time to write tests!

    See the code:

  • @pushtheworld that's great! :-))

    Does "great sample rates" mean at least 1 kHz? Will the sample rate be settable by command?

    Thank you for your precious work!
  • edited June 2017
    At @Bonzo

    Yes, sample rates of at least 1 kHz, settable through software! Note this only works with the wifi shield.

    Check out the new commands on the learning pages Firmware v3.0.0 New Commands.

    Please see the OpenBCI 32bit Cyton Library v3.0.0-beta2 release notes for an updated list of new features, enhancements, and breaking changes from a firmware programming perspective (NOT SDK breaking changes)

    Are there any other questions I can answer?

    Thanks!
  • Thank you @pushtheworld !

    How will be communicated the day the wifi shields will be on sale? Is there a possibility to pre-order?
  • Hey @bonzo sign up for the newsletter and unfortunately we are not doing pre-orders.
Sign In or Register to comment.