mirror of
https://gitlab.com/fabinfra/fabhardware/absaugungsklappensteuerung.git
synced 2025-06-11 19:13:20 +02:00
auf VSCode mit PlatformIO umgestellt.
This commit is contained in:
23
Arduino/motor/src/KlappenAblauf.cpp
Normal file
23
Arduino/motor/src/KlappenAblauf.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include "KlappenAblauf.h"
|
||||
|
||||
// Constructors/Destructors
|
||||
//
|
||||
|
||||
|
||||
KlappenAblauf::~KlappenAblauf()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
|
||||
// Accessor methods
|
||||
//
|
||||
|
||||
|
||||
// Other methods
|
||||
//
|
||||
|
||||
|
52
Arduino/motor/src/KlappenAblauf.h
Normal file
52
Arduino/motor/src/KlappenAblauf.h
Normal file
@ -0,0 +1,52 @@
|
||||
|
||||
#ifndef KLAPPENABLAUF_H
|
||||
#define KLAPPENABLAUF_H
|
||||
|
||||
#include "KlappenSteuerung.h"
|
||||
|
||||
|
||||
/**
|
||||
* class KlappenAblauf
|
||||
*
|
||||
*/
|
||||
|
||||
class KlappenAblauf : public KlappenSteuerung
|
||||
{
|
||||
public:
|
||||
// Constructors/Destructors
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* Empty Constructor
|
||||
*/
|
||||
KlappenAblauf();
|
||||
|
||||
/**
|
||||
* Empty Destructor
|
||||
*/
|
||||
virtual ~KlappenAblauf();
|
||||
|
||||
// Static Public attributes
|
||||
//
|
||||
|
||||
// Public attributes
|
||||
//
|
||||
|
||||
protected:
|
||||
// Static Protected attributes
|
||||
//
|
||||
|
||||
// Protected attributes
|
||||
//
|
||||
|
||||
private:
|
||||
// Static Private attributes
|
||||
//
|
||||
|
||||
// Private attributes
|
||||
//
|
||||
|
||||
};
|
||||
|
||||
#endif // KLAPPENABLAUF_H
|
72
Arduino/motor/src/KlappenSteuerung.cpp
Normal file
72
Arduino/motor/src/KlappenSteuerung.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
#include "KlappenSteuerung.h"
|
||||
|
||||
// Constructors/Destructors
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* @param pinA
|
||||
* @param pinB
|
||||
* @param pinPwm
|
||||
* @param pinSense
|
||||
* @param id
|
||||
*/
|
||||
KlappenSteuerung::KlappenSteuerung(int pin_A, int pin_B, int pin_Pwm, int pin_Sense, int i_d)
|
||||
{
|
||||
initAttributes();
|
||||
pinA = pin_A;
|
||||
pinB = pin_B;
|
||||
pinPwm = pin_Pwm;
|
||||
pinSense = pin_Sense;
|
||||
id = i_d;
|
||||
}
|
||||
|
||||
KlappenSteuerung::~KlappenSteuerung()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
|
||||
// Accessor methods
|
||||
//
|
||||
|
||||
|
||||
// Other methods
|
||||
//
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
void KlappenSteuerung::setup()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
void KlappenSteuerung::loop()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param open
|
||||
*/
|
||||
void KlappenSteuerung::setOpen(bool open)
|
||||
{
|
||||
}
|
||||
|
||||
void KlappenSteuerung::initAttributes()
|
||||
{
|
||||
pinA = -1;
|
||||
pinB = -1;
|
||||
pinPwm = -1;
|
||||
pinSense = -1;
|
||||
id = -1;
|
||||
status = NICHTS;
|
||||
}
|
||||
|
88
Arduino/motor/src/KlappenSteuerung.h
Normal file
88
Arduino/motor/src/KlappenSteuerung.h
Normal file
@ -0,0 +1,88 @@
|
||||
|
||||
#ifndef KLAPPENSTEUERUNG_H
|
||||
#define KLAPPENSTEUERUNG_H
|
||||
|
||||
#include "statusKlappen.h"
|
||||
|
||||
/**
|
||||
* class KlappenSteuerung
|
||||
*
|
||||
*/
|
||||
|
||||
class KlappenSteuerung
|
||||
{
|
||||
public:
|
||||
// Constructors/Destructors
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* Empty Constructor
|
||||
*/
|
||||
//KlappenSteuerung();
|
||||
|
||||
/**
|
||||
* Empty Destructor
|
||||
*/
|
||||
virtual ~KlappenSteuerung();
|
||||
|
||||
// Static Public attributes
|
||||
//
|
||||
|
||||
// Public attributes
|
||||
//
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param pinA
|
||||
* @param pinB
|
||||
* @param pinPwm
|
||||
* @param pinSense
|
||||
* @param id
|
||||
*/
|
||||
KlappenSteuerung(int pinA, int pinB, int pinPwm, int pinSense, int id);
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
void setup();
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
void loop();
|
||||
|
||||
|
||||
/**
|
||||
* @param open
|
||||
*/
|
||||
void setOpen(bool open);
|
||||
|
||||
protected:
|
||||
// Static Protected attributes
|
||||
//
|
||||
|
||||
// Protected attributes
|
||||
//
|
||||
|
||||
int pinA;
|
||||
int pinB;
|
||||
int pinPwm;
|
||||
int pinSense;
|
||||
int id;
|
||||
statusKlappen status;
|
||||
|
||||
private:
|
||||
// Static Private attributes
|
||||
//
|
||||
|
||||
// Private attributes
|
||||
//
|
||||
|
||||
|
||||
void initAttributes();
|
||||
|
||||
};
|
||||
|
||||
#endif // KLAPPENSTEUERUNG_H
|
69
Arduino/motor/src/main.cpp
Normal file
69
Arduino/motor/src/main.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "pins.h"
|
||||
#include "KlappenSteuerung.h"
|
||||
|
||||
|
||||
void Ablauf();
|
||||
void AblaufSekunde();
|
||||
|
||||
KlappenSteuerung klappe1 (M1A , M1B , M1PWM , M1SENSE , 5 );
|
||||
KlappenSteuerung klappe2 (M2A , M2B , M2PWM , M2SENSE , 2 );
|
||||
KlappenSteuerung klappe3 (M3A , M3B , M3PWM , M3SENSE , 23 );
|
||||
KlappenSteuerung klappe4 (M4A , M4B , M4PWM , M4SENSE , 1 );
|
||||
|
||||
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
klappe1.setup();
|
||||
klappe2.setup();
|
||||
klappe3.setup();
|
||||
klappe4.setup();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
klappe1.loop();
|
||||
klappe2.loop();
|
||||
klappe3.loop();
|
||||
klappe4.loop();
|
||||
Ablauf();
|
||||
}
|
||||
|
||||
void Ablauf(){
|
||||
static unsigned long alteZeit;
|
||||
static unsigned int summeZeit;
|
||||
unsigned long neueZeit;
|
||||
unsigned int deltaZeit;
|
||||
|
||||
|
||||
neueZeit = millis();
|
||||
deltaZeit = (unsigned int) (neueZeit - alteZeit);
|
||||
alteZeit = neueZeit;
|
||||
summeZeit += deltaZeit;
|
||||
|
||||
if(summeZeit >= 1000){ // eine Sekunde
|
||||
summeZeit -= 1000;
|
||||
AblaufSekunde();
|
||||
}
|
||||
}
|
||||
|
||||
void AblaufSekunde(){
|
||||
static unsigned int sekunden;
|
||||
sekunden ++;
|
||||
|
||||
switch(sekunden){
|
||||
case 1:
|
||||
klappe1.setOpen(true);
|
||||
break;
|
||||
|
||||
case 11:
|
||||
klappe1.setOpen(false);
|
||||
break;
|
||||
|
||||
case 19:
|
||||
sekunden = 0;
|
||||
break;
|
||||
}
|
||||
}
|
28
Arduino/motor/src/pins.h
Normal file
28
Arduino/motor/src/pins.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef PINS_H
|
||||
#define PINS_H
|
||||
|
||||
|
||||
|
||||
#define M1A 2
|
||||
#define M1B 3
|
||||
#define M1PWM 5
|
||||
#define M1SENSE 1
|
||||
|
||||
#define M2A 4
|
||||
#define M2B 7
|
||||
#define M2PWM 6
|
||||
#define M2SENSE 2
|
||||
|
||||
#define M3A 8
|
||||
#define M3B 11
|
||||
#define M3PWM 9
|
||||
#define M3SENSE 3
|
||||
|
||||
#define M4A 12
|
||||
#define M4B 13
|
||||
#define M4PWM 10
|
||||
#define M4SENSE 4
|
||||
|
||||
|
||||
|
||||
#endif // PINS_H
|
15
Arduino/motor/src/statusKlappen.h
Normal file
15
Arduino/motor/src/statusKlappen.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef STATUS_H
|
||||
#define STATUS_H
|
||||
|
||||
typedef enum statusKlappenenum{
|
||||
NICHTS,
|
||||
|
||||
}statusKlappen;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user