Offline
Jr. Member
Karma: 0
Posts: 51
|
 |
« on: December 24, 2012, 06:55:12 am » |
Hello. I want to be able to use gobetwino for logging some data to excel and plot graphs. I followed the instructions in the tutorial pdf and in the sample pdf, namelly the creation of CPTEST and LOGTEST. I have read this topic too and folowed the instructions contained in it: http://arduino.cc/forum/index.php/topic,132419.15.html But i cant get it working... To be more specific and helpful here is the steps i followed: 1. Downloaded and unziped gobetwino to C:/gobtwino location; 2. In Settings i choose COM 9 at 9600 baud, that is the port i have for working with arduino 3. In Settings i have level 3 message status, so i guess it shows up every message. 4. I created the commands CPTEST and LOGTEST and linked it to the respective example csv files. 5. I restarted gobetwino to make the settings and comand updates valid. 6. have closed gobetwino window; 7. Uploaded the sketch to Leonardo unsing COM 9 (since i tried another time before this: the serial monitor prints CPTEST and LOGTEST random values) 8. Started gobetwino and all i get is this in status messages: 24-12-2012 11:53:15 Serial port : COM9 opened at 9600 baud Important informations: I use window 7 machine and an Arduino Leonardo in setup() function i use: While(!serial){ ;}; Any help would be great. Thanks.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 51
|
 |
« Reply #1 on: December 24, 2012, 07:06:08 am » |
Another thing:
Sometimes when i close gobetwino i get an error message that "the program quited working" and that windows is looking for a solution for this.
Another information, and dont know if this is important, every time i open gobetwino the RX led in Leonardo lights up.
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 313
Posts: 35502
Seattle, WA USA
|
 |
« Reply #2 on: December 24, 2012, 07:27:33 am » |
What code do you have on the Arduino?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 51
|
 |
« Reply #3 on: December 24, 2012, 07:47:03 am » |
I have one of the sketches that comes in the samples folder of gobetwino: // This sketch demonstrates the use of the Gobetwino commandtypes LGFIL and CPFIL
int serInLen = 25; char serInString[25]; int logValue1=0; int logValue2=0; int logValue3=0; int result;
void setup() { // Setup serial comm. Initialize random function. Serial.begin(9600); while(!Serial){ ; }; randomSeed(analogRead(0)); delay(5000); // Use the CPTEST copy file command to make a copy of a new empty logfile Serial.println("#S|CPTEST|[]#"); readSerialString(serInString,1000); // There ought to be a check here for a non 0 return value indicating an error and some error handeling } void loop() { //Create some random values to log to a file on the PC. This could be sensor readings or whatever //but for this example it's just 3 random values logValue1= random(0,1000); logValue2= random(0,1000); logValue3= random(0,1000); logData(logValue1,logValue2,logValue3); delay(500); }
// Send the LOGTEST command to Gobetwino the 3 random values are seperated by semicolons void logData( int value1, int value2, int value3) { char buffer[5]; Serial.print("#S|LOGTEST|["); Serial.print(itoa((value1), buffer, 10)); Serial.print(";"); Serial.print(itoa((value2), buffer, 10)); Serial.print(";"); Serial.print(itoa((value3), buffer, 10)); Serial.println("]#"); readSerialString(serInString,1000); // There ought to be a check here for a non 0 return value indicating an error and some error handeling }
//read a string from the serial and store it in an array //you must supply the array variable - return if timeOut ms passes before the sting is read void readSerialString (char *strArray,long timeOut) { long startTime=millis(); int i;
while (!Serial.available()) { if (millis()-startTime >= timeOut) { return; } } while (Serial.available() && i < serInLen) { strArray[i] = Serial.read(); i++; } } It had a pde extension but the frist time i opened it in Arduino environment asked to change to ino extension.
|
|
|
|
|
Logged
|
|
|
|
|
Copenhagen / Denmark
Offline
Edison Member
Karma: 5
Posts: 2338
Do it !
|
 |
« Reply #4 on: December 25, 2012, 04:41:47 pm » |
What is the purpose of this code, which i believe is not part of the supplied sample code : while(!Serial){ ; };
|
|
|
|
« Last Edit: December 25, 2012, 04:47:14 pm by MikMo »
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 313
Posts: 35502
Seattle, WA USA
|
 |
« Reply #5 on: December 26, 2012, 08:57:23 am » |
What is the purpose of this code, which i believe is not part of the supplied sample code : On the Leonardo, it waits for the serial port to be ready. On other models, it does nothing.
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 313
Posts: 35502
Seattle, WA USA
|
 |
« Reply #6 on: December 26, 2012, 09:25:56 am » |
I installed GoBetwino, set up the necessary commands, and compiled and linked that code for the Mega. GoBetwino caught all the serial data, and logged it as it was supposed to.
I then changed the board type to Leonardo, and connected the Leonardo. I uploaded the sketch, started GoBetwino and changed the com port to the correct port. No communication with the Leonardo appears in the top window. Opening the Serial Monitor fails, because the COM port (COM10) is in use.
MikMo, what's going on? Any ideas?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 51
|
 |
« Reply #7 on: December 26, 2012, 12:24:15 pm » |
In my case i think gobetwino comunicates with Leonardo, since the only message it gives is: Serial port : COM9 opened at 9600 baud
But nothing more than that....
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 313
Posts: 35502
Seattle, WA USA
|
 |
« Reply #8 on: December 26, 2012, 12:58:10 pm » |
In my case i think gobetwino comunicates with Leonardo, since the only message it gives is: Serial port : COM9 opened at 9600 baud All that that means is that GoBetwino connected to the serial port. It isn't clear that any communication actually takes place. If MikMo doesn't get back to us today, I'll try my C# application, to see if the Leonardo and PC are actually communicating. Right now, I'd suspect that there is something about the COM port setup that isn't what the Leonardo expects.
|
|
|
|
|
Logged
|
|
|
|
|
Copenhagen / Denmark
Offline
Edison Member
Karma: 5
Posts: 2338
Do it !
|
 |
« Reply #9 on: December 26, 2012, 04:08:34 pm » |
I'm afraid i have no idea right now.
I do not have a Leonardo to try out.
Is there any known difference in the serial communication between the UNO and the Leonardo ?
|
|
|
|
|
Logged
|
|
|
|
|
Copenhagen / Denmark
Offline
Edison Member
Karma: 5
Posts: 2338
Do it !
|
 |
« Reply #10 on: December 26, 2012, 04:17:59 pm » |
Thi is the VB.net code that opens the serial port in GoBetwino: Public Sub serialPortOpen()
'Configure and open the serial port
'If the port is already open, close it first If serialPort.IsOpen Then serialPort.Close() End If
Try With serialPort .PortName = settings.getSetting("serialPortName") .BaudRate = CInt(settings.getSetting("serialPortbaud")) 'WARNING DO NOT CHANGE BELOW SETTINGS FOR USE WITH ARDUINO .Parity = CInt(settings.getSetting("serialPortParity")) .DataBits = CInt(settings.getSetting("serialPortDataBits")) .StopBits = CInt(settings.getSetting("serialPortStopBits")) .Handshake = CInt(settings.getSetting("serialPortHandShake")) 'WARNING END :-) .Encoding = System.Text.Encoding.ASCII .NewLine = Chr(13) + Chr(10) End With
'Open the port and clear any junck in the input buffer serialPort.Open() serialPort.DiscardInBuffer() statusAndLog("Serial port : " + serialPort.PortName + " opened at " + settings.getSetting("serialPortbaud") + " baud")
Catch Ex As Exception statusAndLog("Can not open serial port : " + serialPort.PortName) statusAndLog(Ex.Message) End Try End Sub
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15316
Measurement changes behavior
|
 |
« Reply #11 on: December 26, 2012, 04:29:50 pm » |
I'm afraid i have no idea right now.
I do not have a Leonardo to try out.
Is there any known difference in the serial communication between the UNO and the Leonardo ?
Must be as there seems to have been a new serial function added in version 1.0.1 to support the Leonardo: http://arduino.cc/en/Serial/IfSerialLefty
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 313
Posts: 35502
Seattle, WA USA
|
 |
« Reply #12 on: December 27, 2012, 08:25:25 am » |
This is my C# callback to open the serial port: private void btnConnect_Click(object sender, EventArgs e) { System.ComponentModel.IContainer components = new System.ComponentModel.Container(); port = new System.IO.Ports.SerialPort(components); port.PortName = comPort.SelectedItem.ToString(); port.BaudRate = Int32.Parse(baudRate.SelectedItem.ToString()); port.DtrEnable = true; port.ReadTimeout = 5000; port.WriteTimeout = 500; port.Open();
readThread = new Thread(new ThreadStart(this.Read)); readThread.Start(); this.hardWorker.RunWorkerAsync();
btnConnect.Text = "<Connected>";
btnConnect.Enabled = false; comPort.Enabled = false; sendBtn.Enabled = true; } With this, the C# application is able to receive data sent by the Arduino: Text: #S|CPTEST|[]# Text: #S|LOGTEST|[851;349;305]# Text: #S|LOGTEST|[172;976;867]# Text: #S|LOGTEST|[311;756;941]# Text: #S|LOGTEST|[917;637;713]# Text: #S|LOGTEST|[933;707;769]# Text: #S|LOGTEST|[112;701;456]# Text: #S|LOGTEST|[837;12;744]#
|
|
|
|
|
Logged
|
|
|
|
|
Copenhagen / Denmark
Offline
Edison Member
Karma: 5
Posts: 2338
Do it !
|
 |
« Reply #13 on: December 27, 2012, 11:33:40 am » |
Hmmm.
I wonder if it is the dtr enable that makes it work ?
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 313
Posts: 35502
Seattle, WA USA
|
 |
« Reply #14 on: December 27, 2012, 02:38:29 pm » |
I wonder if it is the dtr enable that makes it work ? Worth a try. I'll test it for you, if you create a new executable.
|
|
|
|
|
Logged
|
|
|
|
|
|