Servus Stefan,
Bilder von dem jetzigen wilden Aufbau, oh weh,nicht das jemand auf die Idee kommt, dann so alles zu betreiben ;-).
Es liegen an manchen Bauteilen 230 V an, da sollte man schon wissen wo hingelangt werden kann.
Die Stückliste, wobei ja vieles Geschmackssache ist, Taster oder Drehgeber, Display mit 20 x 4 oder weniger, 7 Segmentanzeige ...
1. Arduino Micro, Leonardo, Micro Pro
2. LC Display HD ( 44780 oder vergleichbares )
3. PCF 8574 ( I2C Bus, Baustein für 8 digitale IO (Ein / Ausgänge ), um das Display über den I2C Bus zu treiben
4. 4 Taster, was gefällt ( 5 Volt werden geschalten, also nichts wildes )
5. Vakuumsensor ( Art. Nr.: SHOP DRTR-I2C-RV1 Drucktransmitter Edelstahl G1/4" -1-1 bar relativ I2C )
^^ da gehen auch Andere, was gefällt ( Die Berechnung muss angepasst werden )
6. Ein einfaches Relais, für die ersten Tests habe ich ein Arduino Shield verwendet( hat den Vorteil, das keine Schaltung drumherum erfunden werden muss ). Vorsicht hier wird mit 230 V DC gearbeitet, das kann echt gefährlich werden. Im nächsten Schritt tausche ich das einfache Relais gegen ein Solid State Lastrelais aus. Ich erhoffe mir dadurch weniger Verschleiß (im Relais) beim Schalten( Stichwort: schalten im Nulldurchgang ).
7. Europlatine, Kabel, 330 Ohm Widerstände, Stecker
8. eine Pumpe, Pneumatikschläuche, Fittinge usw.
Also die nächste Modifikation wird ein Drehgeber ( Rotary Switch ) sein.
Ich hatte mir die ganze Zeit den Kopf zerbrochen, wie ich den Vacuum Startwert, veränderbar speichern kann.
Mich nervt es das ich zu beginn, auf den Tasten rumdrücken muss um den ersten Wert einzustellen. Dann dachte ich mir einen Startwert von -300 mBar als default ist toll... Falls der aber ned passt, muss ich wieder viel rumdrücken.
Schreiben im EEPROM entfällt, da er nur 100.000 Schreibzyklen aushält :-(.
Dann kam mir die Idee, wieso nicht einen Drehgeber zum Einstellen des Vorgabewertes nehmen. Das lässt sich viel besser handhaben, als dieses blöde Tasten drücken. Drehen fertig,
Wer kann denn Platinen ätzen und Layouts entwerfen, da wäre noch viel Potential zum verbessern vorhanden.
Hier mal der aktuelle Code, es sind nur kleine Dinge behoben, Drehgeber kommt später.
Code:
/*
* Vacuumcontrol ( Build 28. Nov 2016, 16:35 )
*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <heiko.weber@gmx.net> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Heiko Weber
* ----------------------------------------------------------------------------
* https://en.wikipedia.org/wiki/Beerware
* https://de.wikipedia.org/wiki/Beerware
*
*
* sketch for Arduino Micro / Leonardo
*
* don't use it for your Atomic Powerplant or SpaceStation
*
* Sensor: B&B I2C vacuumsensor ( 0x78 )
* Display: 16x2 LC Display ( 0x20 )
* Pushbuttons direct connected to digital Pin 5, 6, 7
* one Pushbutton for further use ( digital Pin 4 )
*
* #######################################################
* aa = Value 1 from Sensor
*
* for these values look at the sensor datasheet
* OUT_max = 128
* OUT_min = 0
* P_max = 1000 mBar
* P_min = -1000 mBar
*
* for the calculation look at the sensor datasheet
* OUT_max - OUT_min
* S = ------------------- = 0.064
* P_max - P_min
*
* (aa) - P_min
* Pressure = ----------------- + P min
* S
* #######################################################
*
*/
#include <Bounce2.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20, 16, 2);
#define sensor 0x78
int PumpenPin = 11; // Pump connected to digital pin 11
int ValvePin = 10; // 3/2 way valve connected to digital pin 10
byte PumpenBypass = 0;
byte PumpStop = 0;
byte setDisplay = 0;
byte aa;
int WantPressure = 300;
int maxPumpPressure = 910;
int minPressure = 0 ;
int Hysteresis = 30 ;
int ActPressure = 0 ;
int ButtonDebounce = 2 ; // interval in ms
int counter = 200 ; // clear the display every 200 loops
int Button1 = 4; // pushbutton connected to digital pin 4
int Button2 = 5; // pushbutton connected to digital pin 5
int Button3 = 6; // pushbutton connected to digital pin 6
int Button4 = 7; // pushbutton connected to digital pin 7
enum PumpStates {
Off, On
};
enum PumpStates state = On;
// debounce Buttons from software side
Bounce debouncer1 = Bounce();
Bounce debouncer2 = Bounce();
Bounce debouncer3 = Bounce();
Bounce debouncer4 = Bounce();
// get data from the I2C pressure Sensor
void getdata(byte *a)
{
Wire.requestFrom(sensor,1); //Sends content of first registers
*a = Wire.read(); //first byte recieved stored here
}
// Calculate the value given from the sensor to human readable ( mBar )
void getpressure()
{
getdata(&aa);
ActPressure = aa / 0.064 - 1000 ;
// if you don't have a sensor, give some valid ( 0 upto -1000) value here uncomment the following
// ActPressure = -310;
}
// Setup routine place everything you want to do once at startup
void setup()
{
// initialize the I2C us
Wire.begin();
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Vakuumsteuerung ");
lcd.setCursor(0, 1);
lcd.print("Vers 1.02b, init");
pinMode(PumpenPin, OUTPUT); // sets the digital pin 11 as output
pinMode(ValvePin, OUTPUT); // sets the digital pin 10 as output
pinMode(Button1, INPUT_PULLUP); // sets the digital pin 4 as input
pinMode(Button2, INPUT_PULLUP); // sets the digital pin 5 as input
pinMode(Button3, INPUT_PULLUP); // sets the digital pin 6 as input
pinMode(Button4, INPUT_PULLUP); // sets the digital pin 7 as input
debouncer1.attach(Button4);
debouncer1.interval(ButtonDebounce); // interval in ms
debouncer2.attach(Button3);
debouncer2.interval(ButtonDebounce); // interval in ms
debouncer3.attach(Button2);
debouncer3.interval(ButtonDebounce); // interval in ms
debouncer4.attach(Button1);
debouncer4.interval(ButtonDebounce); // interval in ms
delay(1000);
lcd.clear();
}
void loop()
{
// Update the Bounce instances
debouncer1.update();
debouncer2.update();
debouncer3.update();
debouncer4.update();
// Get the updated value when button is pressed
int value1 = debouncer1.fell();
int value2 = debouncer2.fell();
int value3 = debouncer3.read();
int value4 = debouncer4.read();
// do something with the button value1
if (value1 == 0)
{
if (WantPressure < maxPumpPressure) {
WantPressure = WantPressure + 10;
}
}
// do something with the button value2
if (value2 == 0)
{
if (WantPressure > 0 ) {
WantPressure = WantPressure - 10;
}
}
// do something with the button value3
if (value3 == 0)
{
PumpenBypass=1;
} else {
PumpenBypass=0;
}
// do something with the button value4
if (value4 == 0)
{
PumpStop=1;
} else {
PumpStop=0;
}
//// begin write to Display
if ( counter == 200 ){
lcd.setCursor(0, 0);
lcd.print("Soll: ");
lcd.setCursor(6, 0);
lcd.print(" "); // clear Display at Row 0 Colum 5
lcd.setCursor(0, 1);
lcd.print("Ist: ");
lcd.setCursor(6, 1); // clear Display at Row 1 Colum 5
lcd.print(" ");
counter = 0 ;
}
lcd.setCursor(6, 0);
lcd.print(WantPressure);
lcd.setCursor(6, 1);
lcd.print(-ActPressure);
//// end write to Display
//// Begin Hysteresis for Pump
getpressure();
minPressure=WantPressure-Hysteresis;
if ( (state == On) && (-ActPressure > maxPumpPressure) || (state == On) && ( -ActPressure > ( WantPressure + 10 )) )
state = Off;
if ( (state == Off) && (-ActPressure < minPressure) || (state == Off) && ( PumpenBypass == 1 ))
state = On;
if ((state == On) && ( PumpStop == 1 ))
state = Off;
//// End Hysteresis for Pump
digitalWrite(PumpenPin, state);
counter = counter + 1 ;
/* whenever I got my 2/3 way valve delivered
* digitalWrite(ValvePin, state );
*/
/* for debugging enable serial output, just uncomment the *
//////begin only for debug needed /////
* Serial.begin(9600);
* Serial.print ("Counter");Serial.println(counter);
* Serial.print("Wanted Pressure: ");Serial.println(WantPressure);
* Serial.print("Act Pressure: ");Serial.println(-ActPressure);
* Serial.print("max Pump Pressure: ");Serial.println(maxPumpPressure);
* Serial.print("min Pressure: ");Serial.println(minPressure);
///////end only for debug needed ////
*/
}