Focus Widget: questions on COM Port errors / values sent by widget

Xp0Xp0
edited August 2018 in OpenBCI_GUI
I have been recently working with the OpenBCI_GUI processing source code to try and achieve sending data/ values to external hardware via serial/COM port in a windows 10 environment. The networking widget of the GUI works fine and appears to be able to establish a link with an arduino I have connected to the same computer. An issue arises however when I try to link the output value from the Focus widget to the same COM port. I continuously receive "serial not present, search 'serial_output' in OpenBCI.pde and check serial settings." I changed the serial_output to my desired COM port first thing and that appears to a have achieved very little. 

Any advice on fixing this?

imageimageimageimage

Comments

  • retiututretiutut Louisiana, USA
    edited March 2018
    Can you please post the lines of Arduino code you are using to receive the data? This will explain how you have told the computer to communicate with the Arduino. There is not enough information to determine if the connection has been made properly. The GUI will only output this error code if it can't connect.

    I'll try and set up a simple tutorial, if possible.
  • retiututretiutut Louisiana, USA
    edited March 2018
    I got it to work by sending the Focus [0,1] data via OSC to Max and then via Serial to an Arduino. Remember that asking the Arduino to communicate with multiple apps over serial is not best practice and will show error messages while maintaining communication with whatever it connected to first (example: trying to send data to Arduino from the GUI while viewing the Arduino IDE serial monitor). It does connect to the COM port via the Networking widget when the baud rate is set up properly.

    The Arduino code in W_Focus did not run properly when receiving simple 1 and 0 messages over serial. Therefore, I will provide the simple Arduino sketch I was able to make work. A green led lights up when focused.

    // OpenBCI_GUI Arduino Serial Tester
    // Focus Widget Blink
    // Tested 3/31/2018 using iMac, Genuine Arduino, OpenBCI_GUI 3.2.0, and Max 7 by R. Waltman

    int serialvalue = 0; // value for serial input
    int started = 0; // flag for whether we've received serial yet


    void setup()
    {
    Serial.begin(115200); // open the arduino serial port
    // initialize digital pin 2 as an output.
    pinMode(2, OUTPUT);
    }

    void loop()
    {
    if(Serial.available()) // check to see if there's serial data in the buffer
    {
    serialvalue = Serial.read(); // read a byte of serial data
    started = 1; // set the started flag to on
    }
    else
    {
    serialvalue = 0;
    started = 0;
    }

    if(started) // loop once serial data has been received
    {
    //if the value is 1 (focused), turn on the onboard LED/pin 2
    if(serialvalue>=1){
    digitalWrite(2, HIGH);
    }
    //if the value is 0 (not focused), turn off the onboard LED/pin 2
    else if(serialvalue==0) {
    digitalWrite(2, LOW);
    }

    }
    }

    Before this workaround, I was able to verify that the Arduino was connected directly to the networking widget and was receiving data from the focus widget. However, it was unclear what kind of message was being sent to the Arduino. It must have been >= 1 because the light remained on. Using the same Arduino code with Max yielded the desired result. There may be an issue with the data format  from the Focus widget over serial, how the Arduino processes it, or a baud rate discrepancy.
  • retiututretiutut Louisiana, USA
    edited March 2018
    I think the GUI sends 0 and 1 out using strings, not integers or Boolean. The Arduino code in Github supposedly processes the Serial data as a string, but my Arduino just shows a simple Receive blink. Here are the lines of code from the networking widget that send focus data over serial:


  • Thank you so much! This actually gave some response as opposed to the others. After checking I believe i may have made in error in baud rate, though by default the drop down menu on the GUI reads 115200, you have to open it up and click on 115200 otherwise it stays at a lower value.

    The arduino code gets the led activated. The one issue is that the for whatever reason, the led on pin 2 stays on, whether or not the the GUI reads focused. I cant tell if this is either because the processing code is constantly emitting the same output or if the arduino code needs to look for different value.

    I have been looking at the processing code as well and am still confused as to exactly what value is being sent over serial. As for now it seems to remain solid, but thank you for finding that the value is not a Boolean/integer!
  • Xp0Xp0
    edited August 2018
    [original thread title: Regarding the value that the Focus or Networking Widget sends of serial port.]

    Hello,

    I recently had the chance to attempt yet again to get this seemingly trivial concept functioning: the focus widget as well as the the GUI and the networking widget accompanying it have the option to send data over serial to something such as an arduino.

    Something similar to the physical DARK MAZE project I suppose.

    I havent been able to get this thing working.


    The problem goes something like this: ( this has been tested on two windows 10 devices)

    If I attempt to connect the actual Focus Widget via serial two an arduino... ( This of course requires serial_output_name to be changed accordingly) I get that no serial port is detected. No reaction from arduino.

    In contrast, the Networking Widget does connect to the arduino, but it is very unclear what value is being sent over serial. I've attempted True, False, 1, 0 etc.... (I should mention that the focus widget sends over values of 48 and 49 (when isFocused is true, it functions as an extra 1, ergo, 49 is TRUE, 48 is FALSE) this however doesnt work due to reasons mentioned earlier.

    I am currently using the v3.3.2 Processing GUI -

    People have done this before, there has to be someone who knows whats going on here.

    I am certain I am missing something. Any advice?


  • wjcroftwjcroft Mount Shasta, CA
    Hi, @Xp0,

    I've merged your new thread into this existing thread, because the subjects are directly related. Also, when you post a new comment on an existing thread, all previous participants (such as @retiutut ), receive email notifications. Making it more likely that you can continue the conversation with knowledgeable users.

    I'm also wondering if there is an existing issue logged for this, or if a new issue should be opened.


    Regards,

    William
  • retiututretiutut Louisiana, USA
    @wjcroft Do you think the Arduino code is not pulling its weight? Is there a pattern of this not working?

    @Xp0 update to GUI 3.4.0 please! I removed the "serial" option from the Focus Widget (which resolves the issue this thread addresses), because there were high risk of errors. Now, the Networking Widget does any and all networking.
Sign In or Register to comment.