Ganglion Hardware Connection to Raspberry Pi (SPI or UART)

Hi everyone!

I have been working with the Ganglion for a few months now and I'd like to connect it to my Raspberry Pi. However, I don't want to connect to it over bluetooth, which seems to be how most people are connecting the board to the pi. Instead, I'd like to use either an SPI or UART connection (preferably SPI) to connect the Simblee of the Ganglion to the Raspberry Pi's GPIO pins. The main reason for the hardware connection is to improve the sampling rate of the Ganglion (which is severely limited over bluetooth). I also have some other design ideas that require the hardware connection. 

In trying to do this, I have ran into an interesting snag. I was able to connect the Ganglion to my PC over UART via an FTDI cable and view serial output from the Ganglion on the PC (including raw voltage data). However, when I tried to connect the same pins (RX and TX) to the corresponding pins on the Raspberry Pi, something really strange happens. I'm not sure what is happening internally, but the Ganglion seems to fail to output data over the UART connection. Moreover, the blue light on the board starts flashing faintly when its connected to the Pi, even before I turn the Ganglion on. When I do turn the Ganglion on, the blue light starts out blinking, but, after a few seconds, the light stays on solid without any blinking. This strange light show does not occur when I connect the Ganglion to my PC computer via UART through an FTDI cable. 

My only guess is that output voltage of the GPIO pins on the Raspberry Pi is too high to be compatible with the Ganglion, which is overloading the Ganglion. However, this conclusion really doesn't make any sense, as the Raspberry Pi's GPIO pins output 3.3 volts and the Simblee operates at 3.3 volts. Likewise, my FTDI cable is 3.3 volts and the Ganglion works fine with it and my computer. 

Any thoughts as to why this might be happening? 

Please note that I currently have my Raspberry Pi powered via a wall outlet, but I am not allowing anyone to wear the electrodes while it is being powered in this way. Once I get the connection working, I will get a battery pack for my Pi so it can be used to collect voltage data. If there are any other details that I have left out that might be helpful, please let me know. 

Thanks!

Comments

  • Still working on this. Anyone have any thoughts? I will also post a follow-up if I learn anything new. 
  • wjcroftwjcroft Mount Shasta, CA
    edited December 2017
  • wjcroftwjcroft Mount Shasta, CA
    Regarding real-world Bluetooth 2.x SPP Serial Port Profile throughput figures.

    Found this benchmark of SPP throughput. The 'typical' 2 megabits/sec I mentioned earlier came from a Sparkfun Bluetooth tutorial, and may be based on other Bluetooth 2.x profiles than the SPP (such as audio output). The device below, a Laird BT900, is circa 2014, so may not reflect current technology speeds.
  • Oh yea you should make the PI a SPI slave and then use the WiFi sdk to mock a wifi board. that way you can send at what ever sample rate you want!


  • I apologize in advance for the long post. 

    Thank you pushtheworld and wjcroft for your responses. Although Bluetooth 2 with SPP or the wifi shield would definitely allow me to improve the sample rate, I'm trying to avoid wireless connections and achieve data transfer rates above those either solution will support. Connecting the Ganglion and the Pi through SPI seems like the most promising solution to me (its wired and could easily allow for 10+ megabit/sec transmission). However, there is a bit of a problem. The Ganglion (and Cyton) is an SPI master, and that cannot be changed. I also want to keep the Pi as an SPI master, because I might want to connect other SPI slaves to the Pi and Pi as slave is not well supported. So, I need to connect two SPI masters together, and I think I've come up with a solution. I would love to hear what you guys think of my idea, as you probably have much more experience with this hardware than I do. 

    So here it is: create an adapter between the SPI masters (Pi and Ganglion) through a shared slave (Arduino or SRAM). The basic idea is the Ganglion collects a sample, then it sends that sample over SPI to the slave device, where it is cached temporarily. As soon as its done transferring the sample, the Ganglion goes back to collecting the next sample for transfer as it normally would. Next, while the Ganglion is collecting its next sample, the Pi will retrieve the cached sample from the slave. Then the process just repeats over and over again. Of course, I have to create a special connection between the masters and the slave, so that it can be shared. The idea here is to multiplex all of the SPI lines with the slave-select on the Ganglion deciding who has control of the slave (I will use a clock-safe multiplexer for the clock signal connection). Additionally, the slave-select of the Ganglion will be connected to an input pin on the Pi and vice versa, so each master will be able to tell when the slave is available/busy. 

    Here is a link to the full circuit diagram for the adapter: https://drive.google.com/file/d/1q1wMEDxHZT5tjmJr6X8eLz0EkVTcRSqf/view?usp=sharing

    Here is a link to a functional diagram of what this should achieve: https://drive.google.com/file/d/1HC7eAoz9I1W6Wyx_aplSOViCgF6kz-cO/view?usp=sharing

    Let me know what you think!
  • bayesianbayesian Deutschland
    I don't own an openbci device yet, but if I get one, I too would prefer a non-wireless, higher data rate connection. For EEG the sample rate is mostly fine. For ECG or EMG, on four channels, I'd say the BLE streaming is limiting the usefulness.

    I'd say it should support UART, maybe only using software emulation with the data pins.

    But probably, the WIFI shield is the way to go. Paradoxically, it does have an accessible serial UART. In the docs it says it's for programming the wifi shield, but I guess it can be used from the arduino code. One would have to modify the firmware though. Then again, if you already have wifi going, why bother...
  • wjcroftwjcroft Mount Shasta, CA
    re: non-wireless. There is a thread on the forum here documenting a wired USB connection, using an optical USB isolator. This was done with the V1 firmware. But is actually easier now with the serial port switching capability of V3.x.

  • For those wanting to go the OpenBCI over UART route, these links may be helpful: 


    It can definitely provide a sampling rate improvement, but it has its limitations (see the second link for a description of those limitations). 
  • For anyone interested in OpenBCI over SPI (to a Pi or your favorite SPI master), I have started to implement the design that I posted in February, and I have successfully gotten my Ganglion to communicate with the Pi over SPI. I still need to work out some synchronization issues in the firmware. Once I do, I'll run some tests and let you guys know about the sampling rate that it can support. Preliminary results look good though, with transfer rates around 8mbps. 
  • wjcroftwjcroft Mount Shasta, CA
    @TylerC, hi.

    The maximum baud rate limitation is likely because the settable baud rates on both the PIC and the FTDI breakout need to match EXACTLY as the speed is upped. The application note here explains how that might be accomplished.


    Regards,

    William

  • bayesianbayesian Deutschland
    The FTDI route seems to be workable. Cost-wise you'd run to about half the cost of the wifi board. Less if you skip the USB isolator and power the raspberry pi and maybe the openbci from a battery or an USB powerbank.
  • edited March 2018
    Why not just do the board mode switch and send a ‘/1’ and outpt TX on 11 and RX on 12 on the Cyton? The Cyton can output up to 460800 out of the top serial port.

    The Ganglion outputs SPI for WiFi so just follow the WiFi master concepts and you’re done.
  • @pushtheworld, I want to ask you a qestion. in fact, the AuxData is x,y,z, if we use D11 for AuxData's z, D18 for x,D17 is for y, so how can we write the mark to instream by D12 or D13 ? In fact, I want to many marks.Thank you very much.
Sign In or Register to comment.