Brain icon indicating copy to clipboard operation
Brain copied to clipboard

Nothing on Serial

Open ghost opened this issue 5 years ago • 20 comments

I wired up everything correctly: the tx pin of my starwars force trainer II headset and the rx pin of my arduino uno. But the BrainSerialTest example does not write anything to the serial (which I made sure to be at baud 9600).

I was wondering if I broke my headset so i connected it to my phone and the hologram app worked fine.

I also read here: https://github.com/JimRoskind/NeuroskyHacking/blob/master/ForceTrainer.ino that the headset should use a default baud rate of 57600 so I wrote an arduino script that relayed the raw serial data from it's rx pin to the serial monitor. This time, the serial displayed a stream of numbers so I assume there's nothing wrong with the hardware setup. As far as I can tell, the headset is meant to send 11 data values at a time, but I couldn't find any pattern in my results.

I found on an Arduino forum that someone else had the same issue but the issue just suddenly went away for them?

What can I do?

ghost avatar Feb 20 '20 10:02 ghost

I tried out the code in the github I linked, and it's giving me something Capture

edit: I've found that all these numbers are unuseful because i've found that the serial monitor is meant to and sometimes does display meditation, attention, etc. I have no idea why it works when it does and nor why it doesn't work. Nonetheless, I still haven't been able to get the brain library example to work.

ghost avatar Feb 20 '20 10:02 ghost

I'm also currently working on a MindFlex EEG project and found nothing output to the serial.

I was getting no data from the BrainSerialTest example until i was a lot more careful about placement of the headset (sensor repositioned above the left eye) and used alcohol swabs on the sensors and the places where it met my face and ear lobes. Then i began getting data, and with more positioning finally a zero value in the brain.readSignalQuality() which indicates the best possible signal.

zensutherland avatar Feb 20 '20 12:02 zensutherland

Isn't the code meant to display signal quality 200 at the very least? I'm not getting anything displayed at all.

ghost avatar Feb 20 '20 12:02 ghost

I thought so too, but i'm not sure how the "if (brain.update())" operates, but i kept monkeying with the whole setup and positioning until i began getting data. I know that's not very scientific or logical, but that's pretty much all i've got.

zensutherland avatar Feb 20 '20 13:02 zensutherland

Well thanks anyway, I'll try tomorrow.

ghost avatar Feb 20 '20 14:02 ghost

I was having trouble with serial connections and 32-bit processors, so i wrote this quick serial signal evaluator for when i'm using a Teensy 3.2. Maybe it'll show whether you're getting good transmissions from the MindFlex.


#define HWSERIAL Serial2

int counter = 0;

void setup() { Serial.begin(9600); HWSERIAL.begin(9600); Serial.println("Mindflex test"); Serial.println("-------------"); Serial.println("Please Connect and Turn Turn on Headset"); }

void loop() { byte incomingByte; if (HWSERIAL.available() > 0) { // Anything coming in from Mindflex headset incomingByte = HWSERIAL.read(); if (incomingByte == 0xAA) { // First Header good, check next incomingByte = HWSERIAL.read(); if (incomingByte == 0xAA) { // Second Header good - Start Processing counter++; Serial.print("Header Signal Encountered ("); Serial.print(counter); Serial.print(") "); delay(100); incomingByte = HWSERIAL.read(); incomingByte = HWSERIAL.read(); // Read second byte incomingByte = HWSERIAL.read(); // Read Third byte Serial.print(incomingByte, DEC); if (incomingByte == 0x00) Serial.println(" - Signal Good"); if (incomingByte > 0x00 and incomingByte < 0x20) Serial.println(" - Signal Marginal"); if (incomingByte > 0x21 and incomingByte < 0xC8) Serial.println(" - Signal Very Poor"); if (incomingByte == 0xC8) Serial.println(" - Headset Not Touching "); } } } }

zensutherland avatar Feb 29 '20 02:02 zensutherland

Hey Guys, I just started this up today, and got really disheartened by seeing nothing in serial pin. I tried a baud rate of 57600 too, changed some code and still got nothing. Is it just the placement of electrodes, positioning and set up? I checked my soldering and I don't think I've done anything wrong with the chip. Please help me with what I could try???

AdiSun123 avatar Feb 10 '22 14:02 AdiSun123

placement, positioning, etc. have nothing to do with data coming in. you need to debug your hardware and software. perhaps upload an arduino sketch with just void setup() {Serial.begin(9600);} and void loop() {Serial.println('test');} and then keep upping the Baud rate until everything is stable and working at 115200, then switch back to the Brain firmware.

sixtyfive avatar Feb 10 '22 15:02 sixtyfive

I'm so sorry, I'm a bit new to these things; I actually don't know what it means by keep upping the baud rate until everything is stable and working at 115200, then switch back to the brain firmware. So currently I'm using an Arduino Uno, and just using the example code of BrainSerialOut form the frontier nerds website And at the moment, as I'm checking the serial monitor, it doesn't give me any values. So you suggest I keep changing the baud rate until I get some consistent "test" prints using the small code of yours separately and then switch back to the example frontier nerds code? Because I changed the original code to print error whenever it didn't pick up anything using an else statement, and the "error" print in was coming in quite consistently at 9600 baud rate.

AdiSun123 avatar Feb 10 '22 15:02 AdiSun123

"keep upping" as in: start at 9600, try 19200, try 38400, then 57600, then 115200. sometimes there is a problem that only happens at higher rates, but not at lower ones. so yes, i suggest you start at low baud rates, but with a simple TEST program, not with BrainSerialOut. if you know that your test program works, then try again with BrainSerialOut.

sixtyfive avatar Feb 10 '22 20:02 sixtyfive

Thank you so much for the help, I'll try it tonight and get back to you whether it work

AdiSun123 avatar Feb 10 '22 23:02 AdiSun123

So i began with trying to make changes in baudrate and I was getting quite consistent prints outside of the brain firmware. Then I also took some time to see if the voltage is flowing around the circuit using a multimeter checking every point from the rx and tx pins to the power to the TGAM and it all seems in place. I also tried removing the "if brain.update()" line of the script and that gave me 200, 0, 0 in output in each line of the serial monitor. Now I think there are only 2 possible issues but I still needed some help on that:

  1. I haven't soldered 2 of the pins. For the TGAM, I have only soldered the ground and vcc pins which power the TGAM and not the ones that go to the Arduino. I thought that It mightn't be required but I'll give that a shot today, I've attached a photo github link; I have soldered the pins circled in red to a 2x aa battery pack for the required 3.3v power to tgam but I have left the other 2, in blue empty whereas on the sales sheet it shows that they should be going to the microprocessor (in this case the arduino). Is this why I'm getting nothing or only 200, 0, 0. https://user-images.githubusercontent.com/99411573/153746485-87b45cb7-d344-4d48-bb6d-35917766e7fe.jpeg

  2. Or I think it could be a possible issue with contact to skin. At the moment I'm just using AgCl dry electrodes and taping them without any sort of conductive gel or anything. Could that be the reason why I am getting no readings?

Help would be really appreciated

AdiSun123 avatar Feb 13 '22 09:02 AdiSun123

Sorry, it's been so many years since I even saw a TGAM module and I can't even remember what pins there are. Back then I had a link collection in my repo's README and some of these (including kitschpatrol's project) are not yet dead. So...

  1. Scrolling through these links (but please, do take a look yourself, too!) I can't find any reason why one would need to solder anything more than VCC, GND, RX and TX. And I can't remember having to solder more than 4 wires, either.
  2. No. We didn't even have proper AgCl electrodes, just the MindFlex headset and that basically has a piece of aluminium or whatever touching your forehead, so I don't think that's the issue. And the expectation would be empty data, not no data.

It's good you were able to verify your serial connection is working. From your problem description it sounds a little bit as though you're getting data intermittently only, though. Are you in a very electromagnetically noisy environment by any chance? What's your power source? If it's not a battery, are you sure it's clean enough? Also, it's difficult to tell you anything at this point; a good-quality photo of your setup might be useful.

sixtyfive avatar Feb 13 '22 18:02 sixtyfive

It's been years for me, too, since I've used a TGAM module. But as far as I remember you should get a reading every second. If you have no contact to the skin at all (or bad contact) you still get the '200' value.

And for soldering additional pins: Ground, Vcc and the two data wires are all that is needed. But there are bridges that you can short with a resistor to determine the default baud rate. Depending on where you got the module, there may already be a baud rate set (e.g. if you got it from a used toy that used something else than 9600). If I remember correctly, you can set the baud rate independently in software by sending a command over serial. But you have to know the baud rate that's set by the hardware bridges. Have a look at the datasheet for your version of the module to identify the bridges. But make sure to compare the version and revision printed on your board with the one in the datasheet PDF. I think there were tiny differences in later versions.

steeph-k avatar Feb 13 '22 18:02 steeph-k

As for setting the baud rate in hardware as just mentioned by steeph-k: also see the README I mentioned, it has some info about that. Especially note that TGAM modules come with different firmware versions (1.6 or 1.7 if memory serves) and things work a little differently for either.

sixtyfive avatar Feb 13 '22 22:02 sixtyfive

Hey, I'm so sorry, I just got really busy and left the project completely.

TGAM Image

Here is an image of the TGAM. So I've just soldered female jumper leads to the end of each of the connections and then connected each component to it. At the top: The black lead is connected to the electrode placed at the head. The red lead is connected to a ear clip electrode The black lead is connected to the other ear clip electrode At the bottom: The blue lead is connected to the ground of a 2x AA battery pack The purple lead is connected to the positive of the 2x AA battery pack The white Tx pin is going to Rx Pin (pin 0) on Arduino The grey Rx pin is going to the Tx Pin (pin 1) on the Arduino

Despite the neat soldering and some conductive gel placed with the different electrodes (tried both AgCl and Steel and just about to try the gold plated ones) I am using the BrainSerialOut code, completely unchanged and still getting nothing in the serial monitor (not even 200, 0, 0). And we have already verified that there is serial communication. And as for baudrate I tried both 9600 and 57600 and still haven't received anything.

What could I do now?

AdiSun123 avatar Apr 10 '22 12:04 AdiSun123

The black lead is connected to the electrode placed at the head. The red lead is connected to a ear clip electrode The black lead is connected to the other ear clip electrode

I don't see two black leads.

But I do notice that you're not using shielded wires and also we can't see how long they are. Both might be a problem. Even the Mattel toy has to make use of shielded wires despite the short distance between TGAM PCB and forehead / earlobe, respectively.

Also I remember my Mattel toy needing 3x1.5V cells in series, not 2x. That's 4.5V, which is almost 5 - and I can't remember seeing anything like an LDO on the carrier PCB. Have you checked the TGAM datasheet and is it indeed happy with just 3V?

In case you haven't already discovered it, https://frontiernerds.com/brain-hack helped me a lot back then; also has a video if you scroll down a little.

sixtyfive avatar Apr 10 '22 17:04 sixtyfive

Thank you so much for a prompt response. My bad, I had a typo I meant the yellow lead is connected to the other ear clip electrode. I went through the data sheet once again and it says that the TGAM works with voltage anywhere between 2.97V and 3.63V and I used the multi-meter once again to check a consistent 3.2V is going into the TGAM. Additionally, for the wire length, today, I shortened and resoldered the leads to about 6cm, keeping TGAM close to the head and still am getting an empty serial monitor. And yeah, I began the project from the frontier nerds blog and then came over from it to the Github to share my issues.

AdiSun123 avatar Apr 11 '22 13:04 AdiSun123

Alright, in that case the Mattel Mindflex carrier board must after all have a little LDO to get down from it's 4V5 to the 3V3-ish required by the daughter board. And as @steeph-k pointed out, you should still be getting 200s back when there's no data to report. I'm sorry, I'm drawing a blank here at the moment ... if jumpers are set correctly and baud rates match then I don't know. In about two weeks I'll be able to go by the workshop again and I think I still have the Mindflex there and might give it a go again.

sixtyfive avatar Apr 11 '22 13:04 sixtyfive

Just another thought, I think I know why I'm not getting the 200,0,0. It might be because my arduino code starts with the condition if brain.update() or if serial.available() > 0, and I am assuming that I am getting no serial data on rx, tx and hence the function isn't fulfilled and the code doesn't give any result on the serial monitor. When I removed this condition then I start receiving 200,0,0. Thank you so much for your help and If you get any ideas while going through the workshop your further help will be greatly appreciated.

AdiSun123 avatar Apr 11 '22 13:04 AdiSun123

Thanks for this conversation. Getting a solid connection is indeed tricky. Closing since it's not an issue specific to the library.

kitschpatrol avatar Nov 19 '23 22:11 kitschpatrol