Hello all, I am doing a softrobot tool kit project changing their sample code and design to control the pressure of a hand that we fabricated.
I have an Arduino mega 2560
The pressure sensor is a honeywell 100PGAA5. Data sheet is in the attachments below.
The control board diagram is posted below.
The sample code is quite long so I'll give you a simpler version that works better for my project.
int prescaler = 256; // set this to match whatever prescaler value you set in CS registers below
// intialize setpoint
float setpoint=8;
void setup() {
Serial.begin(9600);
// input pins for valve switches
pinMode(50, INPUT);
pinMode(51, INPUT);
pinMode(52, INPUT);
pinMode(53, INPUT);
// output pins for valve PWM
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
}
void loop() {
float PWM=255;// set PWM you want a finger to be
float P1 = (analogRead(A8)/25);
float P2 = (analogRead(A9)/25);
float P3 = (analogRead(A10)/25);
float P4 = (analogRead(A11)/25);
// if statement for manual switch override
if ((digitalRead(50) == HIGH) && (P1<setpoint)){analogWrite(5,PWM);} else {digitalWrite(5,LOW);}
// first if statement turns everything on. Second if statment says that if the pressure reading
// is lower than the set point, open and close valve at your desired PWM. If it is not shut the valve completely off.
if ((digitalRead(51) == HIGH) && (P2<setpoint)){analogWrite(6,PWM);} else {digitalWrite(6,LOW);}
if ((digitalRead(52) == HIGH) && (P3<setpoint)){analogWrite(7,PWM);} else {digitalWrite(7,LOW);}
if ((digitalRead(53) == HIGH) && (P4<setpoint)){analogWrite(8,PWM);} else {digitalWrite(8,LOW);}
// print pressure readings
Serial.print(setpoint); Serial.print("\t");
Serial.print(P1); Serial.print("\t");
Serial.print(P2); Serial.print("\t");
Serial.print(P3); Serial.print("\t");
Serial.print(P4); Serial.print("\n");
delay(200);
}
What I expect to happen is that when air is flowing past my sensor through a t connector that connects the pump to the hand, the sensor will read the airflow as pressure and convert it to a voltage that the arduino can read. However what actually happens is the voltage the arduino reads fluctuates in a slightly periodic way. The input of pressure seems to have no effect on its fluctuation. Only turning on the board and switching on the valve seems to change it. When it does it behaves similar to a sharply fluctuating floor function. Consistently fluctuating but shifted up or down depending if a switch is turned off or on.
The issue I am facing is most likely electronic. I posted my code just now but I tried the original source code my code is based off of, and it doesn't read any attempt I made and better.
