PROS: Solenoids cycle randomly

I have been using PROS for a while, love it because I’m used to C. But I have a slight issue with using pneumatics.

Whenever VexNET is disconnected, on disconnect all solenoids cycle once (on and off). Then while it’s searching for a signal they continue to cycle on a time period I have yet to measure. Same thing happens on first power on.

This causes issues with safety as my team often forgets to shut off the pneumatic system before doing anything and almost get things in their face. Not fun

Is this because by default all pins are set to floating input instead of an output and that is causing issues?

My code is below

void initializeIO() {
	  /**
	   * Set pin modes for solenoids
	   */
	  pinMode(SOL_LEFT, OUTPUT);
	  pinMode(SOL_RIGHT, OUTPUT);
	  pinMode(SOL_FLIP, OUTPUT);
	  /**
	   * Assign default values to solenoids
	   */
	  digitalWrite(SOL_LEFT, 0);
	  digitalWrite(SOL_RIGHT, 0);
	  digitalWrite(SOL_FLIP, 0);
}

Function I wrote to toggle the pins:

void toggleDigitalPort(unsigned port) {
	  digitalWrite(port, (digitalRead(port) == 1 ? 0 : 1));
}

Probably the same issue as described here.
https://vexforum.com/t/cortex-digital-io-ports-and-the-pneumatics-driver/25441/1

Have at look at the PROS source code now it’s open source and let us know what you find :slight_smile:

Looking at the source in https://github.com/purduesigbots/pros/blob/master/src/system.c

You can see in initPorts() beginning on line 288, that ports are set to both inputs and outputs seemingly in groups. When I get to my robot I will test moving the ports for solenoids that are set to output by that function.