Wednesday, April 20, 2016

Project - Neurofeedback EEG Mindflex to MindWaveMobile Headset Part 2 (Details)

Configuring the TGAM1 board for raw EEG data (57600 baud)

Click here to go to part one

    • The default output baud rate for TGAM1 boards (at least the ones taken out of Mindflex and Force Trainer headsets) is 9600 baud (this only allows you to capture data for the default frequency bands once per second).
    • To use these cheap headsets with apps made to work with "Think Gear" headsets - we need to change the communication rate to 57600 baud.  There are 2 methods to achieve this:
      1. One way involves programming the TGAM1 board over Bluetooth - if you look through the links at the end of this post you'll find ways of doing this.  I did not do it this way, instead I chose the second method.
      2. The second way involves removing a single SMD (surface mount) resistor (pull-down resistor) and adding a different resistor going from the same area and then over to positive connection of the power supply on the TGAM1 board (pull-up resistor).
        • To do this you'll only need:
          1.  Basic soldering iron
          2. 10k 1/8th watt resistor
          3. Heat shrink tubing to insulate the resistor
    • Step 1: Remove SMD Resistor (surface mount resistor, it a little rectangle on the top of the board.
      • The SMD resistor can be removed by heating up the pad with a soldering iron and pulling it off with tweezers (or, if you are brave - snap it off with needle nose pliers).
    • Step 2 - Solder in the 10k through hole -(meaning is has wires) resistor.
      • the 10k resistor goes from the spot marked B1 on the board and goes over to the positive power connection (refer to the labeled picture at the top of this post)

    Setting up the HC-06(?) Bluetooth Host/ Slave Module (SPP – Serial Port Profile).

    Setting up the Bluetooth communication board/module:
    • Configuring the Bluetooth Slave Module for 57600 baud rate (most modules seem to be configured for 9600 baud rate as the default setting) **This step should be done with the Bluetooth Module alone (not connected to the TGAM1 board)**
      • This is where we need some type of USB to TTL serial converter
        • The easiest is to use an Arduino Board and load a 'Sketch' to connect to the Bluetooth Module over the serial console. 
        • Breadboard wiring (from Fritzing - just pretend the HC-05 is an HC-06 Slave)
        • So, you need:
          • An Arduino (I like the Nano since its made for bread boards - but you could use an Uno, etc.)
          • Logic Level Shifter
          • HC-06 Bluetooth Breakout Board
          • Arduino sketch to send commands to the HC-06 (HC-06 Setup ).
    •  Physical connections of Bluetooth Serial board to TGAM1board pics
      • I used 90 degree male pin headers so I could use cables
      • Bluetooth RX pin to TGAM1 TX pin
      • Bluetooth TX pin to TGAM1 RX pin
        • Vcc to 3.3v source (if you are using the Mindwave or Force Trainer headset use the on board regulated voltage)
        • Gnd - make sure the TGAM1 and HC-06 (or -05) grounds are connected together
        • LED on Bluetooth Module
          • When initially connected to power it should blink
            • There are different flashing rates that depend on default baud rates
            • Vast majority of modules are set at 9600 as the default baud rate
          • LED will stay lit constantly after the device is paired
            • actually a little more complicated – stays lit constantly when paired and ACTIVELY sending data to application (while setting up my module, I couldn't understand why it would say it was paired and the light on the board continued to blink. Even after I attached it to the headset and powered it on again – it continued to blink – computer said it was paired. FINALLY, after installing Neurosky's Mindwave Mobile and starting the Brain Wave Visualizer – it stayed lit. After I closed Mindwave Mobile it began blinking again. I mention all this because, I didn't see it stated anywhere else.)

      Some REALLY BASIC! Background on Bluetooth Communication

      Being very, very new to working with Bluetooth, myself, I decided to include some additional information so that others can hopefully avoid making the same mistakes that I've made:

      Slave vs Master
      • Master is the device at the center of a Bluetooth network (in this case – your phone, tablet or computer)
        • a Master can pair with multiple Slave devices
      • Slaves send and receive data only to or from the Master (in this case – the MindFlex headset, you could, conceivably,  pair multiple headsets to one Master device)
        • a Slave can only be paired to 1 Master at a time
      • Bonds Slave device to Master device
      • After pairing devices automatically connect when they are both powered on and close enough
        • uses authentication data saved on the 2 devices
      Profiles (devices need to support the same profile to communicate - "communication profiles") – this is not an exhaustive list
      • HSP -head set profile
      • HFP – hands free profile
      • HID – human interface device (generally a keyboard, mouse, etc.)
      • SPP – serial port profile (this is what we need for communication)
      • A2DP – advanced audio distribution profile (streaming audio data to speakers, etc)
      • AVRCP – A/V remote control profile (Bluetooth remote for TV, etc.)
      - A little note on profiles and their importance: I have an older android smartphone (Bluetooth and WiFi capable), an IPhone 5 and a Kindle Fire.  It turns out that none of them support the Bluetooth Serial Port Profile and as a result the only way I can use the Bluetooth connection is with my laptop and a Bluetooth USB dongle.  So, if you are planning to use this with a specific device make sure to check if it supports SPP (Serial Port Profile) Bluetooth Profile.
      • First modules I purchased were actually just back planes (essentially just the breakout board without the module – read descriptions very carefully – not a costly mistake but annoying)

      • The next module was a Master – (projects I looked at never seemed to mention if I needed a Master or Slave module... well it turns out I needed a Slave module, of course)

      • Finally got an HC-06 Slave Module

      AT Commands

      You can find these on the datasheets for the Bluetooth Serial Modules (you can find them online - none of the ones I ordered included the datasheet).  AT commands apply to both the HC-05 and HC-06 boards. These are the ones we need to setup the HC-06 breakout:
        • AT pings the device (response back “OK”over serial)
        • AT+PINxxx
        • AT+NAMExxx
        • AT+BAUD4 (sets baudrate to 9600 – default rate)
        • AT+BAUD7 (sets baudrate to 57600)

        Links to more information and resources:

        Wednesday, April 13, 2016

        Hackaday World Create Day 2016 and Hackaday Prize 2016

        Only 1 week from this Saturday, on April 23rd, it's:

        I'll be hosting a Meetup in Plainfield, IL at the Plainfield Public Library to meet and brainstorm ideas for entries to this years Hackaday Prize. Plainfield, IL World Create Day

        Create tech solutions for social change on Hackaday World Create Day, our worldwide brainstorming session for the 2016 Hackaday Prize design concept challenge! Join teams from around the globe and submit ideas for projects that solve problems in categories from citizen science to assistive technologies, or anything else that leverages your hardware, coding, scientific, design and mechanical skills.
        We’ll be picking the most spectacular design solutions to share on the Hackaday front page, and there will be prizes. But we also want to celebrate the fun of getting together in person with all of the people who make Hackaday a part of their daily ritual, so share your photos and ideas with hashtag #WorldCreateDay!

        The Goal:

        Form a team (or work on your own) and submit a project to the Hackaday Prize design challenge. See challenge details here:
        Need some inspiration for your project? Here are some ideas:
        • Citizen Science - Build a graphene supercapacitor, study the effects of a behavior, build an open source instrumentation device.
        • Automation - Build a device that makes breakfast or buys laundry detergent when you’re running low. Automatically track stuff, automate any process, build a Me-robot to do your every whim
        • Assistive technologies - Build a project that helps others move better, see better, or live better. Whether that means exoskeletons, a better wheelchair, a braille display, or educational software, we want to see it.
        • Or any other idea you have to hack for social change! Leverage your talent and find solutions to address technology issues facing humanity today.

        Beyond Hackaday World Create Day Meetup

        Hackaday World Create Day is a single event, but your meetup can live on if you want it to. We can help with ideas for future meetups of your group. This is a great way to show that the Hackaday community is alive and thriving in your part of the world. Maybe our next big event will be held in your city!