AWind
PumpController.h
1 /*
2 AWind.h - Arduino window library support for Color TFT LCD Boards
3 Copyright (C)2016 Andrei Degtiarev. All right reserved
4 
5 You can find the latest version of the library at
6 https://github.com/AndreiDegtiarev/AWind
7 
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the CC BY-NC-SA 3.0 license.
10 Please see the included documents for further information.
11 
12 Commercial use of this library requires you to buy a license that
13 will allow commercial use. This includes using the library,
14 modified or not, as a tool to sell products.
15 
16 The license applies to all part of the library including the
17 examples and tools supplied with the library.
18 */
19 #pragma once
20 
23 {
24  static const uint32_t _pumpRelayPin=13;
25  static const uint32_t _stepperEnablePin = 10;
26  static const uint32_t _stepperDirPin=12;
27  static const uint32_t _stepperStepPin=11;
28  static const uint32_t _stepperM0Pin=13;
29  static const uint32_t _stepperM1Pin=14;
30  static const uint32_t _stepperM2Pin=8;
31  static const uint32_t _stepperMotorSteps=200;
32 #ifndef DEMO_SENSORS
33  DRV8825 _stepper;
34 #endif
35 public:
37 #ifndef DEMO_SENSORS
38  : _stepper(_stepperMotorSteps, _stepperDirPin, _stepperStepPin, _stepperM0Pin, _stepperM1Pin, _stepperM2Pin)
39 #endif
40  {
41  pinMode(_stepperEnablePin, OUTPUT);
42  pinMode(_pumpRelayPin, OUTPUT);
43  stopPump();
44  }
45  void initVacuumValve()
46  {
47 #ifndef DEMO_SENSORS
48  _stepper.setMicrostep(8);
49  _stepper.setRPM(5);
50 #endif
51  //connectVesselToVaccum();
52  disconnectVesselFromVaccum();
53  delay(1 * 1000);
54  }
55  void disconnectVesselFromVaccum()
56  {
57  rotateStepper(95);
58  }
59  void connectVesselToVaccum()
60  {
61  rotateStepper(-95);
62  }
63  void startVacuum()
64  {
65  startPump();
66  pause();
67  connectVesselToVaccum();
68  }
69  void stopVacuum()
70  {
71  stopPump();
72  pause();
73  disconnectVesselFromVaccum();
74  }
75  void startPump()
76  {
77  digitalWrite(_pumpRelayPin, LOW);
78  }
79  void stopPump()
80  {
81  digitalWrite(_pumpRelayPin, HIGH);
82  }
83  void rotateStepper(double angle)
84  {
85  digitalWrite(_stepperEnablePin, HIGH);
86 #ifndef DEMO_SENSORS
87  _stepper.rotate(angle);
88 #endif
89  digitalWrite(_stepperEnablePin, LOW);
90  }
91  void pause()
92  {
93  delay(1000);
94  }
95 };
Implements pump control logic.
Definition: PumpController.h:22