Some guidance for my project is required, please

Hi guys,
I'm looking for some guidance to reach my end goal of programming an Arduino. I have spent some time on the Arduino site and YouTube watching tutorials and am still struggling to piece my plan all together. Any assistance or advise would be greatly appreciated.

Project:
Liquid chemical nutrient dosing of a water tank using peristaltic pumps. This is for a plant watering system.

There is 1 digital input for pump calibration.
There are 2 user selectable analogue inputs:

  1. the tank mix volume (10L, 20L, 30L, 40L, or 50L).
  2. the week of the grow cycle, which will determine the chemicals required
    (Vegetative week 1, Vegetative week 2, Vegetative week 3, Flowering week 1,
    Flowering week 2, Flowering week 3, Flowering week 4, Flowering week 5,
    Flowering week 6, Flowering week 7, and Flushing.
    Control method for analogue inputs - I was thinking of using a 5-position and an 11-position rotary selector switch to accomplish this. Each rotary switch would be connected to its own Analogue input. Then each position of the selector would have a different resistance value in series before returning the circuit to the input.

There are 6 outputs:

  1. peristaltic pump 1
  2. peristaltic pump 2
  3. peristaltic pump 3
  4. peristaltic pump 4
  5. peristaltic pump 5
  6. peristaltic pump 6
    Control method - Each pump requires 12VDC to operate. I will use a separate 12VDC power supply capable of running all 6 pumps simultaneously, without being affected by voltage drop of the pump start up. Each Arduino output will switch its pump through a transistor with a fly-back diode over the motor terminals.

Table for nutrient dosing by week:

            |V1|V2|V3|F1|F2|F3|F4|F5 |F6 |F7 |FLU|

|pump1 |5 |10|20|20|15|15|15|15|15 |15 |0 |
|pump2 |5 |10|20|20|15|15|15|15|15 |15 |0 |
|pump3 |10|20|20|0 |0 |20|20|20|20 |20 |0 |
|pump4 |0 |0 |20|20|20|20|20|20|20 |20 |20 |
|pump5 |0 |0 |0 |0 |50|50|50|50|50 |50 |0 |
|pump6 |0 |0 |0 |15|15|15|15|15|15 |15 |15 |
The table values represent a 'standard' 10 litre mix. Changing the input tank mix volume will multiply these figures accordingly.

Each value in the table is milliliters. I also need to calibrate each peristaltic pump to ensure the correct dose is administered. I need 1 digital input called PumpCal with another transistor switching a pump. The pump calibrate feature will run the peristaltic pump for 60 seconds and a known volume can be measured. Then I can test each pump prior to final installation and adjust the run timer to match the desired 10 litre mix output in the table. Additional benefit is any future pump, of any brand can be integrated by simply running a pump calibration prior to final installation.

I really need some guidance as to where to find sample code for the different aspects to achieve the above and I will try to piece it all together.

As I said earlier any help would be greatly appreciated!
Regards

Is that necessary? Can the pumps not be run sequentially, so the PSU can be smaller?

Will this PSU power the Arduino also? (It could do that)

When will the nutrients be delivered? Once at the start of the week, or must they be spread over the week? If so, what if there is a power failure? How will the arduino know how much has been delivered up to the power failure?

Will the start of a new week be triggered by changing the "week" rotary switch position?

If the pump delivers a known volume in 60 seconds then no calibration is required. I think maybe what you meant to say is that the volume delivered in 60s will be measured (by a person) and used to calibrate each pump. I'm not clear if the arduino will be involved in this calibration process. I guess the Arduino could time the 60s and control the pump under test. Not sure why another transistor is needed, you already have one transistor per pump. I'm not sure what the digital input is for, either.

The first thing you need to decide is this: do you want to pay someone to do this for you, or do you want to learn how to do this for yourself?

There is a forum section where you can offer payment, but take great care who you choose to help you. Maybe offer to pay half up front and the other half only on a satisfactory outcome of your testing. Be prepared to lose money and get nothing in return. If this is your choice, I can move this topic to that section for you.

If you want to learn how to design the circuits and write the code, this forum section is fine and you will get lots of help here. But usually no-one will write all the code for you or design the whole circuit for you. You need to show willingness to learn and attempt things for yourself.

I'll respond properly in the morning mate. You really know how to make new people feel welcome @PaulRB

I hope that wasn't sarcasm. :wink:

Hi, @bensydneyaust
Welcome to the forum.

Can you please tell us your electronics, programming, arduino, hardware experience?

Have you programmed your controller yet?
What model is your Arduino.

To get your project started, you will need to write separate code to read each of your input values and similarly your output controls.

This will make sure you can input values and control your hardware, before combining code to get it to interact.

First you need to make sure your hardware works and you can read or control it, as separate codes.

As you do this you will learn the limits of the hardware and how your logic has to work.

Thanks... Tom.. :smiley: :+1: :coffee: :australia:

This looks like a nice project. It may be somewhat ambitious, don't worry yet.

You may want to use an RTC real time clock module to inform the times of dosing.

Make experiments with each hardware piece separately. Use example code you can trust, that you didn't write or mess with too much.

You could get most of the logic settled using LEDs in place of the motor drivers and code the hole mess in a simulator, which BTW makes it easy to share runnable sketches what either do or do not yet do what you want.

See

and be fearless, the learning curve is gentle enough, most of the features can be figured out with some diligent poking around and the documentation isn't too bad either.

There are plenty of hardware parts on offer in the simulator. Most if the time some kind of proxies can be arranged for hardware that cannot be directly simulated.

HTH

a7

This can easily be represented as a 2-D table or array in your code. Since the values are small (<250) you can use the data type byte which uses, as you might guess, only 1 byte per entry.

const byte pumpCount = 6;
const byte weekCount = 11;
const byte dose[pumpCount][weekCount] = {
// V1  V2  V3  F1  F2  F3  F4  F5  F6  F7  FLU
  { 5, 10, 20, 20, 15, 15, 15, 15, 15, 15,   0}, //pump0
  { 5, 10, 20, 20, 15, 15, 15, 15, 15, 15,   0}, //pump1
...
  { 0,  0,  0, 15, 15, 15, 15, 15, 15, 15,  15}  //pump5
};

By the way, in programming terms, when you count things, like pumps, always start the count at zero, not one. So instead of calling them pump1 to pump6, call them pump0 to pump5. This may seem strange, but you soon get used to it and it makes coding a little easier.

So, firstly apologies for not being clear enough in my initial post. After reading PaulRB's comments, I agree plenty of information is missing.

My background:
I'm an industrial electrician specialising in controls, working with variable frequency drives, PLC's and encoders as well as safety control systems. My hobbies include 3D design and printing, off-road buggy racing, custom metal fabrication, cryptocurrency investment/speculation, technology in general and a unquenchable thirst for knowledge.

The project, further details:
The mix will be made after you first select the week and tank size, then triggered to run by pressing the 'makeMix' input.

Prior to making any mix each peristaltic pump needs to be calibrated to ensure 10 milliliters is dispensed. Selector switch 'calPump' allows calibration of each pump via analogue input A2. The selected pump will run for 20 seconds (any time is fine) into a measuring beaker, then adjust the pump?Run value to reflect 10ml.

A standard mix is 10 litres. When 10L and Week 1 is selected each of the values in the first vertical column of the array needs to be pumped into the water tank by each of the corresponding peristaltic pumps. So I need the array values to multiply the runtime of each pump?Run time.

Example:
pump0 = 0.5 * pump0Run
pump1 = 0.0 * pump1Run
pump2 = 1.0 * pump2Run
pump3 = 0.0 * pump3Run
pump4 = 0.0 * pump4Run
pump5 = 0.0 * pump5Run
I don't mind if the pumps run together or sequentially. I have piles of electrical control gear I have collected over the years. I think sequential would be preferable so I can see each one run separately.

So this is where I'm at with this current project, I have some base code which declares some values, setup the minMode values, and setup analogRead and serial.Print to determine analogue values.

What I'm struggling with is integrating the array provided by PaulBR.

int calPump=0;      //press to calibrate, or prime, the selected pump
int makeMix=1;      //press to make a mix with current week and tank settings
int delayTime=500;  //general delay
int pump0=8;        //set pump 0 to pin 8
int pump1=9;        //set pump 1 to pin 9
int pump2=10;       //set pump 2 to pin 10
int pump3=11;       //set pump 3 to pin 11
int pump4=12;       //set pump 4 to pin 12
int pump5=13;       //set pump 5 to pin 13

int pump0Run=1000;  //set pump 0 run time - user calibrated for 10ml output
int pump1Run=1000;  //set pump 1 run time - user calibrated for 10ml output
int pump2Run=1000;  //set pump 2 run time - user calibrated for 10ml output
int pump3Run=1000;  //set pump 3 run time - user calibrated for 10ml output
int pump4Run=1000;  //set pump 4 run time - user calibrated for 10ml output
int pump5Run=1000;  //set pump 5 run time - user calibrated for 10ml output

int tankPin=A0;     //tank or mix size selection input
int tankVolt;       //tank analogue input voltage
float A0;           //tank voltage decimal value
int weekPin=A1;     //week selection input
int weekVolt;       //week analogue input voltage
float A1;           //week voltage decimal value
int pumpPin=A2;     //pump selection input
int pumpVolt;       //pump analogue input voltage
float A2;           //pump voltage decimal value

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);         //monitor the analogue input values on A0 & A1 & A2
pinMode(calPump, INPUT);
pinMode(makMix, INPUT);
pinMode(tankPin, INPUT);
pinMode(weekPin, INPUT);
pinMode(pump0, OUTPUT);
pinMode(pump1, OUTPUT);
pinMode(pump2, OUTPUT);
pinMode(pump3, OUTPUT);
pinMode(pump4, OUTPUT);
pinMode(pump5, OUTPUT);

}

void loop() {
  //voltage readings for A0 & A1 & A2 via serial printer
tankVolt=analogRead(tankPin);
A0=(5./1023.)*tankVolt;
weekVolt=analogRead(weekPin);
A1=(5./1023.)*weekVolt;
pumpVolt=analogRead(pumpPin);
A2=(5./1023.)*pumpVolt;
Serial.print ("Tank size selected V = ");
Serial.println (A0);
Serial.print ("Grow week selected V = ");
Serial.println (A1);
Serial.print ("Pump selected V = ");
Serial.println (A2);
delay(dealyTime);
}

void loop() {
  //Conditions to make a mix.
  //Example:
  //V1 & 20L tank selected, then makeMix pressed. 
  //Each pump runs according to the V1 column below, and each pump?Run is muliplied the tank size.
  //Tank size is simply a multiplier of the values in the table below. 10L is x1.
  //pump0 runs for 0.5 x pump0Run
  //pump1 runs for 0.5 x pump1Run
  //pump2 runs for 1.0 x pump2Run
  //pump3 runs for 0.0 x pump3Run
  //pump4 runs for 0.0 x pump4Run
  //pump5 runs for 0.0 x pump5Run
}

const byte pumpCount = 6;
const byte weekCount = 11;
const byte dose[pumpCount][weekCount] = {
  //For this table 10ml is x1 the pump?Run, 5ml is x0.5, 20ml is x2, 0ml is x0.0 multiplier.
// V1  V2  V3  F1  F2  F3  F4  F5  F6  F7  FLU
  { 5, 10, 20, 20, 15, 15, 15, 15, 15, 15,   0}, //pump0
  { 5, 10, 20, 20, 15, 15, 15, 15, 15, 15,   0}, //pump1
  {10, 20, 20,  0,  0, 20, 20, 20, 20, 20,   0}  //pump2
  { 0,  0, 20, 20, 20, 20, 20, 20, 20, 20,  20}  //pump3
  { 0,  0,  0,  0, 50, 50, 50, 50, 50, 50,   0}  //pump4
  { 0,  0,  0, 15, 15, 15, 15, 15, 15, 15,  15}  //pump5
};

void loop() {
  //Conditions to claibrate a pump
pumpVolt=analogRead(pumpPin);

while(pumpVolt<0.7)
  calPump pump0Run
  digitalWrite(pump0, HIGH);

}
}

Hi @TomGeorge ,
I have electronics and hardware experience, but no programming or Arduino experience. The only programing I have done is through the Paul McWhorter YouTube video series that I have been watching and learning along.

I have also played with some of the example sketches in the Arduino IDE as originally I wanted to use a 2x16 LCD controller that I got from Jaycar to control this project. After looking into displaying text I thought it would be much easier to get a simple version running first, then maybe upgrade later as I understand how everything works.

Thanks for your advise. I am currently working out the resistor values for the analogue inputs.

Hi @alto777 ,
I started using the wokwi.com site and found you can not use analogue inputs. I will have to use individual switches for the inputs. Once I get that sorted I will post for you guys to have a look at.

The wokwi supports analog inputs. The same pins that work for that in real life are also analog inputs in the simulator.

I often use a slide fader (potentiometer) hooked to an analaog input. On the same hand, many of the sensors the simulator offers use analog outputs, those are usually connected to analog inputs.

So I do t know what you tried and didn't try, or exactly what you aren't being able to do. Yet.

a7

Thanks! I will introduce sliders for my selector switches. Really cool site BTW. I was enjoying using it until there was no selector switches.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.