Python / Wifi, setting Analog Board Mode shuts off Cyton

edited November 2018 in Wifi Shield
Hi,

First of all, its very cool that I can even mess with at home/cheap/open-source eeg headset -- thanks for your guys' efforts, documentation, forum answers, github code, software updates, hardware iterations, etc. I transitioned out of academics leaving behind any access to tools (I have a cog neurosci background doing EEG, fMRI, combined EEG/fMRI, neuroperformance assessment & training, ML algorithms, etc) but am motivated to hack together a consumer prototype. I initially came across systems ranging up to $50k (for a decent channel number and dry electrodes) before coming across your guys' kit. My expertise is more on the cognitive theory/physiological signal side than the CE/EECs side so its a godsend to be able to set something like this up at home.

I am attempting to build a BCI loop in Python using the WiFi shield (for those high sampling rates) + Cyton+Daisy (for the high channel count). 


1) Sending analog board mode turns off Cyton in python: I hooked up a photodiode that works reliably with OpenBCI GUI after I turn on the analog read in the GUI (which was cool -- confirmed my screen refresh rate using a flashing stim). However, whenever I use the python libraries to send an analog board mode code:

from openbci import wifi as bci
shield = bci.OpenBCIWiFi(ip_address = '192.168.4.1', log=True, high_speed=True)
shield.wifi_write('/2')  #analog mode

which returns:
Success: analog

but consistently and immediately turns off the Cyton board (D4 light) but leaves the Wifi shield on. Writing out other codes via Python doesn't do this (e.g.'v' for version check). Is there a different code or a reason the Python route would turn off the board everytime but the GUI doesn't? 

I tried looking through the OpenBCI code but it seems its using a "set_board_mode" function from the cyton library which I couldn't find in the github code for the GUI but did find in the OpenBCIInterface code. But that function looks like it sends a bytes-encoded '2' which is the same I think (I assume the '/' gets added somewhere else)? I'm just trying to find what the difference is or possible reasons the Python library auto-shuts off the Cyton to Wifi Shield connection while the GUI doesn't.

Without sending this analog-board-mode code, I've gotten the Python libraries to stream the aux channels (and the 16 main channels), but without the data from the photodoide (I assume because the board isn't in the right mode -- default mode streams empty values).



More of a question than an issue, but is there any updated recommends on the way this circuit is powered (vs the schematics in this photoresistor tutorial)? It seems to work so far using one giant battery through the WiFi shield but maybe you guys know a better way. I initially thought the Cyton card could be powering down from too much draw (??) when connected to this circuit but I get the same problems when I d/c this photoresistor circuit.

Also, while connected, the OpenBCI GUI works fine when it switches over to Analog mode. 


3) There's no WiFi --> LSL --> openVibe stream available. (Low priority)

Already covered in these threads, I assume it ended up being a more thorny problem than it first appears:

I spent a couple days trying to modify the serial port functions in the streaming LSL library but the functions from serial to wifi don't map that great (plus, I'm a hackish/fake programmer). Alternatively, I suppose a wifi/tcp/udp driver could be made for OpenVibe at some point? Its not the biggest priority for me since I plan to implement/re-implement everything in Python anyways but it would be nice for prototyping of BCI workflow loops.


Omar 

Comments

  • wjcroftwjcroft Mount Shasta, CA
    Omar, hi.

    re: #1. Thanks for your very thorough description of the (apparently Wifi Shield) issue. My hunch is that setting the analog mode over the wifi connection is having some odd shutdown effect with the Cyton mainboard interacting with the Wifi Shield code. (Rather than this being an issue with the OpenBCI_Python functionality.) Can you log your issue on this page, and point back to this thread?



    ---

    re: #2, the Community page you reference is powering the photodiode from the digital +3.3 V on the Cyton mainboard. This is fine, and 'should' have no effect on the Cyton. The 3.3V is generated from a voltage regulator connected to the battery. Actually if we compute the maximum current draw if the photodiode was hypothetically fully conducting (a short), E = IR, I = E/R, I = 3.3 V / 220 ohm = 15 milliamps. This seems excessive and I believe more current draw than is necessary. But then again, the diode has some resistance during operation, so this would be a worst case scenario.

    A 1K ohm resistor would draw 3 milliamps. A 5K ohm resistor, would only draw .6 milliamps. The resistor value does determine the sensitivity, so you can experiment with the value. A few milliamps current draw is nothing to worry about. Tens of milliamps would be a lot for what this circuit is doing.

    ---

    re #3, OpenBCI is definitely prioritizing LSL support in the future. As it supports connection to all research analysis apps. Can I ask you to log a separate issue on this on that same page above? You are asking specifically about Wifi support of LSL, so I believe that is the best location.

    Thanks again,

    William
  • Hi William,

    Thanks for the circuit explanation and its interaction with the Cyton board.

    Other two issues logged in GitHub.

    Much appreciated,

    Omar
  • techsupporttechsupport United States

    That's a very interesting problem. I will have to test this out myself when i get into the lab. I'll try this out tomorrow and get back to you here.

    AJ
  • @techsupport

    Thanks AJ. Lemme know if I can try/reproduce anything for clarity.
  • @Conor@pushtheworld@techsupport.

    Update: I ran all the codes a couple times (so I'm reasonably sure that I'm consistently getting these responses).
    Using this code:
        shield = bci.OpenBCIWiFi(sample_rate = 1000, ip_address = '192.168.4.1', log=True, high_speed=True)
    # --> send code here using shield.wifi_write('XX')  
        shield.start_streaming(printEEG)    
        shield.loop()

    Sending any of these codes work (they don't turn off the Cyton):
        shield.wifi_write('~2') #higher sample rate

        shield.wifi_write('V')  #gets version v3.1.0

        shield.wifi_write('/1') #default mode
        shield.wifi_write('/4') 
        shield.wifi_write('/5') #BLE mode

    Sending either of these codes DON'T work (they successfully change the mode, but immediately kill the D4 light on the WiFi Shield):
        shield.wifi_write('/2')  #analog mode
        shield.wifi_write('/3')  #digital mode


    (2) Also, is there any way to turn back on the Cyton (or the connection from the Wifi Shield to the Cyton) by sending serial codes to the WiFi Shield? Right now, I'm forced to manually power cycle the Wifi Shield to get the D4 light back on.

    Thanks,
    Omar
  • Seems to be an issue with setting
    pinMode(11, INPUT)

    This is present in both modes that aren't working (analog and digital) and absent in all the modes that are working.

    Removing this line or replacing it in the OpenBCI_32bit_Library_definitions.cpp prevents the Cyton from shutting down (but of course doesn't properly set the mode to read from the AUX channels).

    Is this specifically a problem with my board or has anyone else reproduced it?


    I'm not even sure which board would be the problem if it were a hardware issues (WiFi shield or Cyton). Again, its weird because however OpenBCI GUI enables analog mode with WiFi tx works just fine.

  • edited January 2019
    Hey Omar, I replied to your issue here: https://github.com/OpenBCI/OpenBCI_WIFI/issues/86#issuecomment-451568232

    Hopefully that gives you some clarity on what's going on. Unfortunately there is no immediate fix, analog mode is not implemented in python. But I will be working on it over the next few weeks. 

    Subscribe to notifications to track my progress: https://github.com/OpenBCI/OpenBCI_Python/issues/109
Sign In or Register to comment.