Controle a velocidade do motor usando meditação e nível de atenção do cérebro (Parte 6/13)

Control Motor Speed ​​Using Meditation and Brain Attention Level (Part 6/13)

Control Motor Speed ​​Using Meditation and Brain Attention Level

SUMMARY

After controlling the LED brightness with the brain's meditation and attention level, let's move on to more applications in Brain Wave. Since the resolution of the previous experiment was unclear, we will now try a different experiment to get a clearer picture.
In this article, I am again thinking about changing something that can give us a clearer understanding about the variations, say a DC motor. Here, we will control the speed of an engine using our brain's attention and meditation levels at any specific moment. We will be using the Arduino UNO and the mindflex sensor to read the brain waves and a MOTOR to show the results. We can also use an amplifier before the DC motor to see more variations in speed.
DESCRIPTION
It is important to note that the motor speed is controlled by the PWM technique. It's the same technique we use for brightness control.
Quick Note : PWM technique is a technique to control analog devices by digital outputs. Through the digital outputs we are creating a square wave of ON and OFF patterns. This ON and OFF pattern is used to create analog voltage varying between Low Voltage and High Voltage and we can vary the voltage by changing the duration of the ON time in relation to the OFF time.
If we pass this ON OFF pattern to the motor at high speed, an analog voltage will be received and the motor speed will change accordingly.
First, let's control the engine speed using the attention level.
So now to control the speed of the motor, we will measure the level of attention from and meters of the TGAM1 chip. Note that this chip gives us the level of attention on a scale of 0 to 100. It is also interesting to know that the chip transmits the meditation signals only when the sensor is accurately connected to the brain and the sensor module is receiving 100% of the signal. strength. Signal strength varies from 0 to 200.
Imagem mostrando a velocidade do motor DC sendo controlada pelo nível de meditação usando o sensor de ondas cerebrais
Fig. 1: Image showing DC motor speed being controlled by meditation level using brainwave sensor
Dramatically, when the signal strength is 100%, the sensor sends the value 0, and when the sensor sends 200, it means there is no connection of the metal sensor with our brain. So, after confirming that our signal strength is 100% and that our sensor is sending 0 in series for signal strength, we can perform this experiment.
Now we know that PWM has a duty cycle that determines the analog level. The duty cycle is basically the on time divided by the total period. To change the MOTOR speed based on attention level, we will change the PWM duty cycle.
Imagem mostrando a velocidade do motor DC sendo controlada pelo nível de meditação usando o sensor de ondas cerebrais
Fig. 2: Image showing DC motor speed being controlled by meditation level using brainwave sensor
We are getting the sensor meditation value on a scale of 0 to 100. So we will make the duty cycle value equal to the meditation value subtracted from 100. For example, if the sensor meditation value is 40, the duty cycle will be 100 – 40 = 60. This will make the ENGINE speed parallel to the meditation level. You can check the code and video of this experiment.
Now, after the meditation level, we will do the same with the attention level. Just to remind you again, check if the signal strength is reaching 100% along with the 0 value . We again need to remove the attention values ​​from the sensor and change the PWM duty cycle in relation to the attention values. Again, make the duty cycle value equal to the attention value subtracted from 100. For example, if the sensor meditation value is 40, the duty cycle will be 100 – 40 = 60.
Imagem mostrando a velocidade do motor DC sendo controlada pelo nível de meditação usando o sensor de ondas cerebrais .
Fig. 3: Image showing DC motor speed being controlled by meditation level using brainwave sensor
Check out the software section to see how PWM is implemented in code. We also complete speed control using attention values. Check out the code and video to perform the experiment yourself.
Diagrama de blocos do controlador de velocidade do motor DC baseado no sensor MindFlex Brainwave
Fig. 4: Block diagram of DC motor speed controller based on MindFlex Brainwave sensor
Hardware: Find the attached circuit diagram of the connections that need to be established. We take a pin from the T pin of the mindflex sensor and connect this pin to the Rx pin of our Arduino UNO. Additionally, we short-circuited the Sensor and UNO ground by a wire. Take special care when soldering anything to the Mindflex sensor, as the pins are very close to each other. After establishing the connections, we use an amplifier to amplify the Arduino output. Additionally, we use an L293D to drive the engine. The Arduino PINS are connected to the input of the l293d and then the motor is connected to it.
Software: The software part is exactly the same as the LED brightness experiment. Even so, I explained everything again so you don't have to go back.
The sensor is sending us the value of e meters through the T pin. Once we receive the value at any specific point, we just need to convert that level of value into the MOTOR speed. As discussed earlier, we will use PWM techniques. The Arduino “analogWrite” function is used to implement PWM technology
For example,
AnalogWrite(13,240);
AnalogWrite in Arduino is used to write PWM wave to a pin. In the example above, the first parameter is the PIN number and the second is the PIN value. So we are writing 240 on pin 13. Now we can easily calculate the analog voltage at value 240. The total voltage range is 0V to 5V and the range of values ​​is 0 to 255.
This means 240 = (5/255)*240 = ~4.70V.
Now, the values ​​we get for and meters are in the range 0 to 100.
So let's say we get evalue = 70.
We will multiply the value of e by 2.55 to put it in the range 0 to 255.
So it will be analogWrite(pin,evalue*2.55) in a loop.
Some points to note:
The sensor usually provides 60 to 80% resistance due to its orientation and the location where we place it. Try to keep the metal sensor exactly above your left eye. I also applied salt water to my forehead for better connectivity with the sensor. The signal strength also messes with how we solder the wire to the T pin. Try shielding this wire and also make sure the reference probes are connected correctly.
If you have any wire connected to the EEG pin of the sensor, disconnect that wire as it will create a lot of disturbances in the sensor values. Give this experiment a try and let me know your comments. Stay tuned for our upcoming experiments that describe sending a message to detect whether a person is sleeping.

Project source code

###

 //Program to

#include
// Configure the brain analyzer, pass it the hardware serial object you want to listen to. Brain (Serial); //char a(400); Sequence a,a1; int v = 0; int z=0,output; uint32_t num=0; uint32_t num1=0; empty configuration { // Start the hardware serial. Serial.begin(9600); pinMode(9, OUTPUT); } empty loop { // Expect packets about once per second. // The .readCSV function returns a string (well, char*) listing the most recent brain data, in the following format: // "signal strength, attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma" if (brain.update ) { //Serial.println(brain.readErrors ); //Serial.println(brain.readCSV ); //sprintf(a, "%c",brain.readCSV ); a = brain.readCSV; v = a.indexOf(','); v = a.indexOf(',',v+1); v = a.indexOf(',',v+1); v = a.indexOf(',',v+1); z = a.indexOf(',',v+1); a1 = a.substring(v+1,z); num = a1.toInt ; v = a.indexOf(',',z+1); a = a.substring(z+1,v); num1 = a.toInt; //Serial.println(num); Serial.println(num1); analogWrite(9, output) //brain.readCSV .toCharArray(a,200); } }

###

Circuit diagrams

Circuit-Diagram-MindFlex-Brainwave-Sensor-DC-Motor-Speed-Controller

Project video

Related Content

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.