Arduino Pro Mini, Serial, RFI?

  if (digitalRead (13) == HIGH  && w == 1 && u == 0) { // only once - after purge
    delay(100); // this delay was an attempt to stop the chatter
    digitalWrite(4, LOW); // turns on Start Light (does not shut it off)
    Serial.println("    Start light ON");
    Serial.println ("Now waiting for operator to press START BUTTON ");
    u = 1;
  }
  else {
    startTime = millis(); // print USER NOTICE every 15 seconds
    if (startTime - prntInterval >= prntTime && w == 1 && u == 0) {
      Serial.println("Waiting for stack temperature to reach 160 ");
      prntInterval = startTime;
    }
  }

I've coded a Pro Mini to operate a project that (amoung other things) turns 7, 24 volt Solenoids on using digital Write() commands. The code has 338 lines and as long as the USB connection (a SparkFun, FTDI Basic) is present the code runs like a clock. But with the FTDI removed control fails! It fails at the code snippit above. The solenoids begin to chatter when I bring pin13 HIGH specifically, the Mini seems to be resetting(?) and the 7 solenoids chatter for a bit. I did install diods across the solinoid coils :confused:
Thats when I inserted the 100 msec delay, just to see if I was fightting a race condition, as the trigger for bit 13 is a temperature threshold actuated via a thermocouple controller, alarm relay outputput.
Aditionally there seems to be a random reseting as the system is running, again only when the FTDI is removed.
So my questions are:

  1. Can anyone tellme if I should be adding decoupling capacitors, or pull up/down resistors etc.?
  2. What could be in play here why is the FTDI preventing the failure?
    BTW I tried it with the cable removed and the FTDI in place but the failure still occures
    Thanks
    Gene

Post your schematic.

Post a full sketch that reproduces the problem. 99% of the time when someone posts a snippet where they're sure the problem is, it's somewhere else.

void setup() {
  // put your setup code here, to run once:
  Serial.begin(57600);
  pinMode(2, OUTPUT); //STOP Light
  pinMode(3, OUTPUT); //H2 flo value (PWM)
  pinMode(4, OUTPUT); //START Light
  pinMode(5, OUTPUT); // CO2 flo value (PWM)
  pinMode(6, OUTPUT); //PSU CC (Current Control)(PWM)
  pinMode(7, OUTPUT); //SV1 CO2 in
  pinMode(8, OUTPUT); //SV2 Product out
  pinMode(9, OUTPUT); //SV3 H2 out (vent)
  pinMode(10, OUTPUT); //SV4 N2 Anode
  pinMode(11, OUTPUT); //SV5 N2 Cathode
  pinMode(12, OUTPUT); //SV6 H2 in
  pinMode(A0, OUTPUT); //3wV (Humidity valve)
  pinMode(18, INPUT_PULLUP); // user start button input
  pinMode(19, INPUT_PULLUP); // user stop button input
  digitalWrite(4, HIGH); // begin with START lite off
  digitalWrite(2, HIGH); // begin with STOP lite off
  digitalWrite (7, HIGH); // SV1
  digitalWrite (8, HIGH); //SV2
  digitalWrite (9, HIGH); //SV3
  digitalWrite (10, HIGH); //SV4
  digitalWrite (11, HIGH); //SV5
  digitalWrite (12, HIGH); //SV6
  digitalWrite (A0, HIGH); // humidity valve 3wV

}

I have a 10K ohm resistor on pin 13 to ground. I have attached a hand drawing (jpg).
The code snippit is reproducing the malfunction unfortunately
When I put 5 v on pin 13 (via the dry relay contacts on my temperature controller) the code works, as long as the FTDI is plugged into a computer. When I unplug the FTDI and close the contacts on that relay, pro Mini starts turning all my relays on and off! I have a Sainsmart 16 channel relay board with optically isolated inputs, that the Pro Mini interfaces with to operate all the solenoids and lights, all 24 vdc
Perhaps there is somthing with pin13 it is the LED pin so it is not exactly the same as the others?
Gene

Please post a full schematic. You have not shown how power and ground are connected (that's where I suspect the problem lies), nor have you shown the other connections to the sainsmart relay board.

What is this relay board? Please link to details on it so we know what we're working with.

Thanks DrAzzy for your input!
I’ve attached the only data I have for the relay board and the PWM to analog converter chips. I’ve also included a more detailed circuit diagram. NOTE For some reason my Norton Security is preventing me from accessing the Sainsmart web site (www.sainsmart.com), Norton claims it is dangerous!
Each input channel on the relay board draws less than 5 ma and I am using 9 channels and operate up to 7 simultaneously.
The LTC2644 chip has 2 channels, that convert an 8 bit PWM to a true analog output. It draws 5 ma @ 5 v Vcc. for each chip I use 2 chips to control 3 devices that do not like the PWM (filtered or not)
Thanks again for your help
Gene

16 relay 2.pdf (55.1 KB)

LTC2644 10 bit PWM to analog converter.pdf (407 KB)

One more try
It seems I cannot load the jpg file Ill try again later

I have set up a proto board with the Pro-Mini and 9 LEDs to simulate what is wired in my project. The circuit on pin 13 draws 85 ma when the circuit is completed. while this is a lot more than I expect it should be OK total current becomes 165 ma from 75 ma in a “normal” operating mode.
going to try to attach the drawing again

I just found the error. The Arduino 9 v raw was referenced to the +24 Vdc! While the measured voltage referenced to ground was 33Vdc the Pro Mini was "floating" 24 volts above the common ground and not receiving the full 33 volts. The "spooky" part of this is still a mystery to me, as it all worked with the USB plugged in. Of course I do not really know what the input power circuitry on the Pro Mini is.
My thanks to DrAzzy for offering helpful advice.
Gene