Reset/Crash Problem on Atlas Scientific EC Stamp

I am working with the Atlas Scientific PH,ORP, and EC Stamps. I am having a problem with the EC stamp. I am using Arduino 1.0.4 IDE. I am working with an Arduino Mega.

I wrote a class library to process data from each stamp. I used character arrays instead of the String class from their example code. I noticed my code was crashing/reseting the Arduino. After looking deeper I discovered the problem was only related to the EC stamp. After digging deeper into my code and I could not find the root cause of the problem. The PH and ORP stamps seem to work fine running for hours without any issues.

My next step was to load sample code provided by Atlas to see if I had the same problem. I loaded sample code provided and added a Serial.print command in setup. I noticed this program is crashing as well.

The problem seems to happen with reading from the Stamp either using the C and R commands, Sometimes I am seeing non-printable ASCII characters being returned as well.

VCC across both GND points on the stamp is 4.85V.

I have tried the following:
Factory Reset
IDE 1.0.2 same results
Use Serial1,Serial2,Serial3 for stamp same results.
Swap BNC connectors, same results.
Remove Probe, Readings 0,0,0 but Same results.
Different Mega, Same results.
Use Putty and IDE Serial Monitor, Same Results.

Here is the code I am using. It's right off their site (https://www.atlas-scientific.com/_files/code/Arduino-sample-code-EZ-COM-MEGA.pdf)

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(20);                                                   //set aside some bytes for receiving data from the PC
     sensorstring.reserve(30);                                                 //set aside some bytes for receiving data from Atlas Scientific product
     Serial.println("Start");
     }
 
 
 
   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
      }
 }

Here is the output showing the problem:

Start <- Normal Start of Program
E,V3.0,4/12 <-- I command send from Serial Monitor
2178,1176,0 <-C command sent from Serial Monitor (returns readings every 1000ms)
2178,1176,0
2178,1176,0
2178,1176,0
2178,1176,0
2178,1176,0
2156,1164,0
2178,1176,0
2178,1176,0
2178,1176,0
2178,1176,0
2156,1164,0
2178,1176,0
2156,1164,0
2178,1176,0
2178,1176,0
2178,1176,0
2178,1176,0
2156,1164,0
2178,1176,0
2178,1176,0
2156,1164,0
2156,1164,0
2178,1176,0
2178,1176,0
2156,1164,0
2178,1176,0
2156,1164,0
2178,1176,0
2178,1176,0
Start <---- Crash
2178,1176,0
2111,1140,0
2200,1188,0
2178,1176,0
2178,1176,0
Start <--- Crash
2178,1176,0
2156,1164,0

Any help or suggestions would be greatly appreciated.

Thanks,
John

Here's an update. This is one of the oddest things I've ever seen. My inclination is that this is not a software issue but rather a power issue. I connected the stamp directly to my PC via a 5V USB adapter and connected to Putty and it worked as expected. No garbage and all functions work.

I hooked the stamp back up to arduino and it continued to crash. Tried disabling reset on Mega (didn't help). I wanted to check and see what the current draw on the stamp was so I connected it up to multi-meter. I used two long alligator clip extensions back to the mult-meter and read between 9-11mA which seems normal according to the datasheet. What I did notice during this process was the program was now stable and not crashing. I removed multi-meter, restart and it's crashing again. So just for grins I put the alligator extension clips back in but didn't connect the leads to the multi-meter (so I just extended the VCC connection to the stamp by about 1' total. (Each lead is about 6"). After doing this and a reset the program is running without crashing.

Is this some type of EMF causing the problem? The wire has very very minimal resistance so I just do understand what I am seeing here. Any ideas?

Perhaps you could switch into some big boy pants, and get rid of the Strings.

Your comments are not helpful and will only discourage other people from posting. I understand the well documented problem with the String class (which is a problem with the (malloc/free). The C++ class library I wrote and will post once I get this going is using char arrays.

If you carefully read the original post I posted the minimum example provided by the vendor of this stamp and I pointed this out in my post. If you have something constructive to solving the problem then post it. This is not a memory problem.

This is not a memory problem.

You seem awfully certain of that.

Why would extending the length of VCC explain a memory issue? I suspect the issue is a problem with the stamp. I have a PH and ORP stamp and I am not having any issues running the same code. I have a freeRam function I used for debugging and it was reporting 7K of Free Ram. Read the detail of the post, this is beyond a simple and obvious memory leak.

Thanks for your input Paul.

I would try adding some bypass caps. Add a largish cap as near to the board as you can to make sure you have plenty of reserve power. If you have long skinny power leads, that can cause problems due to the inductance. Logic circuitry draws current in surges as it is clocked, too much inductance in the power leads can cause brownouts and massive ripple at the CPU.

I tried a .01uf between VCC and GND and it didn't make any difference. Any other value that would be recommended?

vbcodep:
I tried a .01uf between VCC and GND and it didn't make any difference. Any other value that would be recommended?

Put something like 100uF nearby also to hold a reserve supply.

EDIT: You could also try a 100 ohm resistor in the power lead of the board that is crashing. This helps prevent noise migration on the power leads.

Good call. The 100uf seems to have done the tick so far.

Please edit your post, select the code, and put it between [code] ... [/code] tags.

You can do that by hitting the # button above the posting area.

How to use this forum

As for the power issue: De-coupling

Can you draw a schematic of your bypass capacitor?

I tend to have the same problem.