Control small Motor with a Vacuum Sensor

Hello All
First Please excuse me if any thing I ask here is seem stupid! I am 55 y/o and have never written a piece of code in my life.
But I have been searching endlessly for days trying to at least find some code that would apply to what I am trying to do with NO luck what so ever.

Secondly the need for this code is to help with a medical device that needs to be used right away and I don't think I can figure whats needed as far as the coding in a couple days. If anyone know of a sketch that may apply already please direct me where I might find it, Thank you.

Here is what I'm trying to do.
I have built a negative pressure wound vacuum machine. I'm Using a Arduino UNO, + seeed relay shield, a small 12vdc vacuum pump as well as a vacuum pressure sensor.

THE PRESSURE SENSOR IS A---------- (MXPV6115VC6U)

What is need is a sketch that will turn on my motor relay on and off depending on a voltage level from the sensor. On at -50 mmhg voltage level and Off at -115 mmhg voltage level not exactly those number but close.

I know this may seem to simple but for me I don't have a clue how to make the Arduino complete this operation.

Just want to thank you for any help with this project it will be used on a wound for a decube ulcer for me to try and heal it from being in a wheelchair for 28 years.

Neil, USA

wound vac parts.JPG

MPXV6115VC6U.pdf (99.5 KB)

Do you have a link to information about the pressure sensor? Google isn't recognising that part number.

Never mind - I see you attached the data sheet. It looks as if the output consists of an analog voltage in the 0-5V range, which is ideal for reading by an Analog input.

Once you know how to get a reading from the pressure sensor, the rest of your sketch will be simple. Do you definitely want the pump to cycle on and off with some hysteresis? If not, it would only require a small change to give you proportional control over the pump speed so that you could maintain a constant vacuum.

Also, have you considered just using a simple mechanical vacuum switch and getting rid of the Arduino completely?

Just to give you a starting point, once you have got the circuit sorted out, the control logic for the simple on/off case could be something like this:

int analogReading = analogRead(vacPin);
int pressure = map(analogReading, 0, 1023, -115, 0);

if(pressure > -50)
{
    pumpOn();
}
else if(pressure < -115)
{
    pumpOff();
}

Hello Peter

Just wanted to thank you for giving me some help getting started.

I should have the circuit built tomorrow, and hopefully be able to do some testing.

I would like to keep some hysteresis running in the sketch as it will give me a desired affect on the wound that is under a negative pressure.

The mechanical vacuum switch was thought of but using the Arduino gives me a wider range to change vacuum levels as the healing process changes, but thank you for mentioning it.

I entered the code you sent and tried to compile it, it came back with errors, of coarse I have no idea what to do. I am thinking I need to add void loop() or setup() to it???????????

The message said.

expected unqualified-id before 'if'
expected unqualified-id before 'else'

I'm very sorry that I am so green to all of this coding. I am reading and trying to learn but with never dealing with it it looks like jibberish but the more I read it's helping me start to learn. I just got put in a position that put me in a rush situation.

Once again thank you so much.

Hi, I would not recommend speed controlling the pump, with PWM control there is degree of heat buildup in the motor.
Periods of constant full speed will ensure that when the motor is running it is producing an air flow through it to keep it cool.
Otherwise fit a vent fan to the pump to keep it cool.
The application is ideal for the capabilities of the adruino.

Tom..... :slight_smile:

The code I posted was just a fragment that would go inside your loop() function - it is not a complete sketch so it will not compile on its own.

Hello
Just a Thank you for the input and suggestions "Pete and Tom" your the only 2 that jumped in so thanks very much

I finished the circuit today and started trying to piece a sketch together. I finally put together a small program to just turn vacuum pump on and off at different pressure levels which is mainly what I needed to get this unit going.

Just so you know this type of medical equipment that is used in negitve wound therapy is so expensive the average guy cant buy one and if you dont have insurance forget about it. $50 to 100 USD a day charge depending on the company it comes from.

Anyways here is what my ugly atempt at writing sketch looks like, its not much but its all I got. I know there are a hundred ways to write this code and to most it seems so simple, but when you have never done it, its pretty crazy trying to figure things out. So I'm pretty proud to at least getting this far.

//Wound Vac cotroller for on/off time at different pressure levels


int sensor1 = 5; // select the input pin for sensor 1

int sensorValue1 = 512; // variable to store the value coming from sensor 1

#define RELAY1 5 //relay number 3 on seed sheild

void setup()
{ 
// Initialise the Arduino data pins for OUTPUT
 pinMode(RELAY1, OUTPUT); 
 Serial.begin(9600); // initialize serial communications at 9600 bps
 Serial.print("wound vac control ");
 Serial.println();
 delay (3000);
 Serial.print("Beginning Vacuum ");
 Serial.println();
 
 delay(3000);
 
Serial.print("System Ready " );
 Serial.println();
 delay (3000);
 digitalWrite(RELAY1, HIGH); // This turns vac pump on
}

 void loop()
{
 
 sensorValue1 = analogRead(sensor1); // read the value from sensor1: 
delay(1000); // pause for 1 second
 Serial.print("sensor 1 = " ); // print to screen
 Serial.println();
 Serial.println(sensorValue1); // print sensor value to screen
 Serial.println();
 if (sensorValue1 < 6) // if sensor value less than figure "0-1023 scale"
 // then do the following
{
 digitalWrite(RELAY1, LOW); // keep motor off
}
if (sensorValue1 > 420) // if sensor value is greater than figure "0-1023 scale"
 // then do the following

 digitalWrite(RELAY1, HIGH); // Turn on vac pump
 
}

Im going to add more code tomorrow so I can use a LCD display to give more information on the project box that it all will be mounted in.

Im sure Ill be asking more questions and I can see how this could become addictive learning to pull the real world in side and controlling things with it.

Take Care!

If that's your first sketch you should be proud of it. There are some magic numbers in there that will need to be checked, but the basic logic looks sound.

Any updates on this project?