Brainwave Controller

1,216

39

0

Posted in Technology3D-Printing

Introduction: Brainwave Controller

This course will show you how to make an interesting thing in an intelligent way. Getting the brain waves through the TGAM module, which can acquire your attention and relaxation according to the 's built-in algorithm, you can control almost everything, including electric toys, lights, and other electronic devices. Technically, we collect the brain electricity signal through dry electrode to tgam module in order to acquire the data we need to deal with, which will soon be transferred to Arduino board by Bluetooth. In this way, we can obtain the date we need and then turn them into signal output to mos amplifier module to finally control something. I will demonstrate how to make this work and control my rail car as an example.

This thing consists of two parts. One of them is the brainwave acquisition part with the tgam module as the core. The other is the data conversion output section based on aduino. Both of them transmit data via Bluetooth. You can purchase necessary materials on ebuy, Amazon, Taobao or other shopping sites.

Step 1: Master and Slave Bluetooth Settings

Before starting the main production, we need to establish a connection between two bluetooth. However, the order between them is significant. Therefore, we need to set up a Bluetooth master and slave first so that these two Bluetooth can get connected and start making other parts.

We need to prepare materials, including two CH340 USB-TTL modules, one JDY08 Bluetooth and one hc05 Bluetooth. The brainwave acquisition part uses the jdy30 slave module. The data conversion output part uses the hc05 master module.

JDY30 settings

1. Test instructions::
send AT

Return OK

2、Setup device name:

Example:

send AT+NAMERosen\r\n

Return +NAME=Rosen

The bluetooth name is changed into Rosen. Parameter appeals to power saving.

3.Set the password:

Send AT+PIN0000\r\n

Return +PIN=0000

the bluetooth password is changed into 0000.

4. Set serial port :

Send :AT+BAUD7

Return :+BAUD=7

The baud rate is 57600

Input the AT instruction above to jdy30 bluetooth to complete the configuration of this module.

HC05 setting

The HC05 needs to hold the Bluetooth module's key button, and then connect the serial port to the computer. Until the Bluetooth module flashes the light for two seconds per time, it will ont enter the AT mode. Then, you should select the corresponding serial port number and baud rate, and perform the AT command operation.

1.Test instructions::
send AT\r\n

Return OK

2、Setup device name:

Example:

send AT+NAME=Rosamking\r\n

Return OK

AT+NAME=“Rosamking” The bluetooth name is changed into Rosamking. Parameter appeals to power saving. 3.Set role:

Send AT + ROLE = 1 \ r \ n

Return OK

Bluetooth becomes the master role.

4.Set the password:

Send AT+PSWD=0000\r\n

Return OK

the bluetooth password is changed intto 0000。

5.Set serial port parameters::

Send AT+UART=57600,0,0\r\n

Return OK

6.Set connection mode:

Send AT+CMODE=1\r\n

Return OK

Input the AT instruction above to HC05 bluetooth to complete the configuration of this module.

Test
Two bluetooth modules are powered independently, when hc05 is flashing for two seconds in twice quickly and jdy30 is constantly on. It indicates that the Bluetooth connection is successful. If there is no connection succeeded, you ‘d better check if there is a problem with the AT command and repeat the previous steps.

Step 2: Brainwave Acquisition Part

Now we begin to makeBrainwave acquisition part.First we need to prepare materials.

Connect like a picture.

Warning
1. Pay attention to the order of welding, according to the color from top to bottom, white line, black line and blue line. 2. Tighten the screw when fixing the dry electrode, and remove the exposed shielding wire around it, and fix it with hot glue.

3. The welding points of Tgam main board are fixed with hot melt adhesive to prevent the thread from falling off.

Test

The electrode is tightened on the forehead of the head and the ear clip is clamped on the left ear. Turn on the module power switch. Hc05 connects to the computer via the ch340 usb-ttl module Opens the serial port software Select the appropriate baud rate and serial port. Observe whether there is data transmitted to the serial port of the computer and use hex to receive. If there is data as shown in the figure, there is no problem in data transmission.

data analysis

The TGAM sends approximately 513 packets per second. You may note that it is "about every second", which means that the number of packets sent will not change, but the time it takes to send 513 packets is about one second.
There are two types of packets sent, referring to small one and large one. The first to the 512 packets are small packets, and the 513th packet is a large packet. The data format of the packet is AAAA 04 80 02 xxHigh xxLow xxCheckSum. AAAA 04 80 02 is constant, while the last three bytes are always changing. XxHigh and xxLow constitute the raw data rawdata. XxCheckSum is the checksum and therefore, a package contains only one piece of data that is useful to developers, which is rawdata. It can be said that a small package is a raw data, and there are about 512 raw data per second. How do you parse the original data from the packet?

Rawdata = (xxHigh << 8) | xxLow;

If(rawdata > 32768){ rawdata ­=65536; }

Now that the original data is calculated, we should check the checksum before calculating the raw data. How do checksums count?

Sum = ((0x80 + 0x02 + xxHigh + xxLow)^ 0xFFFFFFFF) & 0xFF

What does that mean? It turns out that you shuoud add the four bytes after 04, reverse, and take the lower eight bits.

If the calculated sum and xxCheckSum are equal, it means the package is correct. Then you may calculate Rawdata. Otherwise, you should just ignore this package. Packet loss rate will not affect the final result while it is down to 10%.

Now that the raw data comes out, how do we take signal strength, attention, relaxation meditation, and 8 EEG Power values? In the 513th big package, the format of this big package is changeless. When it's fixed, we take the data in the figure to describe the meaning they represent, byte by byte:

AA synchronization

AA synchronization

20 is a decimal 32, that is, there are32 bytes of payload, remove 20 itself + two AA sync + final checksum

02 represents signal value Signal The value of the

C8 signal

83 started on behalf of EEG Power

18 is a decimal 24, indicating that EEG Power is made up of 24 bytes, each of the following three bytes is a group

07 Delta 1/3

09 Delta 2/3

46 Delta 3/3

02 Theta 1/3

E6 Theta 2/3

BE Theta 3/3

00 LowAlpha 1/3

2C LowAlpha 2/3

06 LowAlpha 3/3

01 HighAlpha 1/3

C2 HighAlpha 2/3

19 HighAlpha 3/3

00 LowBeta 1/3

E3 LowBeta 2/3

19 LowBeta 3/3

03 HighBeta 1/3

33 HighBeta 2/3

A5 HighBeta 3/3

02 LowGamma 1/3

8D LowGamma 2/3

C0 LowGamma 3/3

05 MiddleGamma 1/3

7C MiddleGamma 2/3

FC MiddleGamma 3/3

04 Delegate Attention Attention

00 Attention value (between 0 and 100)

05 represents the degree of relaxation Meditation

00 Meditation value (between 0 and 100)

14 checksum

The data we need is the value of concentration and relaxation, so we need to consider how to obtain the required value? The above is the main content of the data packet and a simple algorithm. If you want to get more contents, you can view the tgam module communication protocol I uploaded. Also you can refer to the arduino code behind the control box.

Step 3: Data Conversion Output Part

First of all, we need to prepare the following materials:


Connect each element according to the picture


Download code


Warning:
1.Before downloading the program, you shall pull the Bluetooth module first

2. The code contains the library file for the lcd display, so you need to copy the library file to the lib file in the arduino file first.

Step 4: Appearance Designappearance Design

Regarding the appearance, I suggest that you can design some good-looking shells yourself. Of course, you can also refer to my design.

1.Sketch drawing

2.3D model design

I use solidworks modeling

3.3D printing

layer height 0.02mm

fill density 20%

printing temperature 200°


Step 5: Assembly

Step 6: Explanation and Test

1. External power input, 5V to 36V external power input to the MOS module for pwm control.

2. The reset button is used to restart the display or microcontroller when the data is too large.

3. Current regulation, used to control the output of the large current.

4. Switch

5. Charging port

6. External power output

7. Microcontroller external power supply interface, 5-12v

8. Code download port

9.Elastic headband, you can use some elastic cloth to make, I take the head of the vr box down and use it here. 10.LCD1602, which shows atention and relaxation, changes every second, and when the electrode is in bad contact, the number of the display is fixed or 0.

test

The brain wave acquisition part is worn on the head, the dry electrode is tightened on the forehead of the head, and the ear clip electrode is clamped on the right ear. Turn on the switch of the brainwave acquisition part and the switch of the data conversion output part and wait for the Bluetooth connection. When the light of the brainwave collection part is always on, it means that the two modules are connected. At this time, you should observe whether there are two rows of data displaying on the screen, where the first line shows“Attention:00”, whileThe second line is “Relaxation:00”. When there is no problem with the electrode fixing, the numbers of the two lines will change., which means there is no problem with data transmission.

Step 7: Control Rail Car

Since we need to map the pwm output to the corresponding pwm output by the size of the focus, and then control the mos by zooming in on something, I try to use this method to control my rail car.

Step 8: TO Sum Up

It can have more gameplay and more control ways.

In addition to controlling toys, you can also control the brightness or darkness of LEDs, or control other electronic devices.

Our brain is very complex. As a consumer-grade tgam, its function is limited. After all, it only uses a single-channel dry sensor to capture your brain.

However, with tgam's built-in algorithm, we can quickly get the two numerical parameters we need. One is concentration, and the other is meditation, ranging from 0 to 100, so we can control something based on these two values.

For example, you can control some electronic devices by changing your concentration value, such as leds or servos.

Finally, modifying the code, you can also do something more interesting.

Share

    Recommendations

    • Microcontroller Contest

      Microcontroller Contest
    • Woodworking Contest

      Woodworking Contest
    • Casting Contest

      Casting Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    Could you make a parts list, please?

    Comments