Created Mon, 18 Nov 2013 06:29:09 +0000 by Endevor
Mon, 18 Nov 2013 06:29:09 +0000
I have an EC probe and a PH probe on the way, both with their embedded controllers.
https://www.atlas-scientific.com/kits.html
I've tried using the code they offer as well as a few from some random forums that other people used. It seems the SoftwareSerial library used in MPIDE is "outdated" according to the Arduino IDE v1.05. The probe works with Atlas code on my mega, I just can't get it to work with the max32.
Anyone have any experience or incite on this?
Thanks,
Mon, 18 Nov 2013 10:47:11 +0000
SoftwareSerial is outdated, because basically it's not really needed.
If you have a MAX32 then you have 6 (yes, SIX) hardware serial ports at your disposal. Why would you want software serial too?
Mon, 18 Nov 2013 13:35:54 +0000
Do feel kind of like an idiot in saying I thought that SoftwareSerial somehow facilitated the HW Serial... Function is in the title...
Regardless, I should be able to access the data in this manner:
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
Serial2.begin(9600);
Serial3.begin(9600);
}
void loop() {
if(Serial3.available())
Serial.println("3 Found");
if(Serial2.available())
Serial.println("2 Found");
if(Serial1.available())
Serial.println("1 Found");
}
Correct? If I have the probe attached to RX3 and TX3, it should return a "3 Found" statement whenever it receives data. I'm still not getting anything however. The LED on the embedded controller does say it's transferring data however.
Mon, 18 Nov 2013 13:52:34 +0000
Do you have the latest version of MPLAB, or have you applied the Serial1 Crashes fix? [url]http://chipkit.org/forum/viewtopic.php?p=9491#p9491[/url]
Tue, 19 Nov 2013 00:39:39 +0000
That grabbed a signal. It at least replies that it found something from Serial 3. I'm able to even get some values, though I don't think they're exactly correct. Regardless, I tried the sample code again from Atlas, and that doesn't work.
/*
This software was made to demonstrate how to quickly get your Atlas Scientific product running on the Arduino platform.
An Arduino MEGA 2560 board was used to test this code.
This code was written in the Arudino 1.0 IDE
Modify the code to fit your system.
**Type in a command in the serial monitor and the Atlas Scientific product will respond.**
**The data from the Atlas Scientific product will come out on the serial monitor.**
Code efficacy was NOT considered, this is a demo only.
The TX3 line goes to the RX pin of your product.
The RX3 line goes to the TX pin of your product.
Make sure you also connect to power and GND pins to power and a common ground.
Open TOOLS > serial monitor, set the serial monitor to the correct serial port and set the baud rate to 38400.
Remember, select carriage return from the drop down menu next to the baud rate selection; not "both NL & CR".
*/
String inputstring = ""; //a string to hold incoming data from the PC
String sensorstring = ""; //a string to hold the data from the Atlas Scientific product
boolean input_stringcomplete = false; //have we received all the data from the PC
boolean sensor_stringcomplete = false; //have we received all the data from the Atlas Scientific product
void setup(){ //set up the hardware
Serial.begin(38400); //set baud rate for the hardware serial port_0 to 38400
Serial3.begin(38400); //set baud rate for software serial port_3 to 38400
//inputstring.reserve(5); //set aside some bytes for receiving data from the PC
//sensorstring.reserve(30); //set aside some bytes for receiving data from Atlas Scientific product
}
void serialEvent() { //if the hardware serial port_0 receives a char
char inchar = (char)Serial.read(); //get the char we just received
inputstring += inchar; //add it to the inputString
if(inchar == '\r') {input_stringcomplete = true;} //if the incoming character is a <CR>, set the flag
}
void serialEvent3(){ //if the hardware serial port_3 receives a char
char inchar = (char)Serial3.read(); //get the char we just received
sensorstring += inchar; //add it to the inputString
if(inchar == '\r') {sensor_stringcomplete = true;} //if the incoming character is a <CR>, set the flag
}
void loop(){ //here we go....
if (input_stringcomplete){ //if a string from the PC has been recived in its entierty
Serial3.print(inputstring); //send that string to the Atlas Scientific product
inputstring = ""; //clear the string:
input_stringcomplete = false; //reset the flage used to tell if we have recived a completed string from the PC
}
if (sensor_stringcomplete){ //if a string from the Atlas Scientific product has been recived in its entierty
Serial.println(sensorstring); //send that string to to the PC's serial monitor
sensorstring = ""; //clear the string:
sensor_stringcomplete = false; //reset the flage used to tell if we have recived a completed string from the Atlas Scientific product
}
}
It doesn't return anything. The only error I get is the command 'reserve' isn't valid, hence the commenting them out. Otherwise, anything need to be changed for the max32? I'm a little new to coding with serial signals.
Thu, 21 Nov 2013 02:09:13 +0000
Solved the issue, though I'm not fully sure how. I wrote my own code using the most basic functions to simply read and write to Serial3
Here it is:
String result = "";
String input = "";
String inData = "";
String outData = "";
void setup() {
Serial.begin(38400);
Serial3.begin(38400);
}
void loop() {
//Send commands to embedded controller
if(Serial.available()) {
inData = (char)Serial.read();
input += inData;
if(inData == '\r') {
Serial3.print(input);
input = "";
}
}
//Receive data from embedded controller
if(Serial3.available()) {
outData = (char)Serial3.read();
if(outData == '\r') {
Serial.println(result);
result = "";
} else
result += outData;
}
}
Sun, 02 Mar 2014 21:05:57 +0000
The serial events may not work properly in chipKIT. I think I tried them a while back and they did nit. I ddon't know if they have been fixed yet.
Jacob