Dateien nach "/" hochladen
This commit is contained in:
parent
2b1857a256
commit
c2032cd261
|
@ -0,0 +1,120 @@
|
|||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
|
||||
|
||||
#define PIN_INDUCT_SWITCH 4
|
||||
#define PIN_ENCODER 5
|
||||
#define PIN_VARIAC_LIMIT_BACK 2
|
||||
#define PIN_VARIAC_LIMIT_FOR 3
|
||||
#define PIN_ARM_STOP 7
|
||||
#define PIN_ARM_SPEED 9
|
||||
#define PIN_ARM_DIRECT 10
|
||||
#define PIN_STEPMOTOR_ABLE 8
|
||||
#define PIN_STEPMOTOR_DIRECT 6
|
||||
#define PIN_STEPMOTOR_CLOCK 12
|
||||
#define PIN_XRAY 13
|
||||
#define PIN_FILAMENT_SWITCH 11
|
||||
|
||||
/*
|
||||
#define AnalogWrite(...) analogWrite(__VA_ARGS__);
|
||||
#define AnalogWriteAttach(...);
|
||||
#define AnalogWriteSetup(..);*/
|
||||
|
||||
#elif defined(ESP32) || defined(ARDUINO_ARCH_ESP32)
|
||||
|
||||
#define PIN_INDUCT_SWITCH 34
|
||||
#define PIN_ENCODER 35
|
||||
#define PIN_VARIAC_LIMIT_BACK 36
|
||||
#define PIN_VARIAC_LIMIT_FOR 39
|
||||
#define PIN_ARM_STOP 4
|
||||
#define PIN_ARM_SPEED 25
|
||||
#define PIN_ARM_DIRECT 18
|
||||
#define PIN_STEPMOTOR_ABLE 19
|
||||
#define PIN_STEPMOTOR_DIRECT 16
|
||||
#define PIN_STEPMOTOR_CLOCK 17
|
||||
#define PIN_XRAY 13
|
||||
#define PIN_FILAMENT_SWITCH 26
|
||||
/*
|
||||
* ESP32 Polyfill Lib
|
||||
#define AnalogWrite(...) ledcWrite(__VA_ARGS__);
|
||||
#define AnalogWriteAttach(...) ledcAttachPin(__VA_ARGS__);
|
||||
#define AnalogWriteSetup(...) ledcSetup(__VA_ARGS__);*/
|
||||
#endif
|
||||
|
||||
#define CONTROLMSG
|
||||
|
||||
#ifdef CONTROLMSG
|
||||
#define CONTROLMSG(...) Serial.println(__VA_ARGS__)
|
||||
#else
|
||||
#define CONTROLMSG(...)
|
||||
#endif
|
||||
|
||||
//#define DEBUGMSG
|
||||
|
||||
#ifdef DEBUGMSG
|
||||
#define debugMSG(...) Serial.println(__VA_ARGS__)
|
||||
#else
|
||||
#define debugMSG(...)
|
||||
#endif
|
||||
|
||||
#define SYSMSG
|
||||
|
||||
#ifdef SYSMSG
|
||||
#define sysMSG(...) Serial.println(__VA_ARGS__)
|
||||
#else
|
||||
#define sysMSG(...)
|
||||
#endif
|
||||
|
||||
|
||||
#define Commands
|
||||
#ifdef Commands
|
||||
String commandList[13] = {"PULS",
|
||||
"ANGL",
|
||||
"SPCL",
|
||||
"SPCC",
|
||||
"RES",
|
||||
"VARF",
|
||||
"VARB",
|
||||
"TEST",
|
||||
"RXON",
|
||||
"STFI",
|
||||
"RXSH",
|
||||
"SCAN",
|
||||
};
|
||||
|
||||
String cmdListText[13] = {" | Drehen der Gantry auf eine variablen Encoderposition (als Parameter mit dem Befehl übergeben).",
|
||||
" | Drehen der Gantry auf eine variable Winkelposition (als Parameter mit dem Befehl übergeben).",
|
||||
" | Einstellen der Drehgeschwindigkeit (als Parameter mit dem Befehl übergeben) für Drehungen im Uhrzeigersinn (clockwise). Der Wert muss zwischen 0 und 255 (8 Bit) liegen.",
|
||||
" | Einstellen der Drehgeschwindigkeit (als Parameter mit dem Befehl übergeben) für Drehungen gegen den Uhrzeigersinn (counter clockwise). Der Wert muss zwischen 0 und 255 (8 Bit) liegen.",
|
||||
" | Ausführen der RESET-Sequenz. Dabei wird die Gantry auf eine definierte Null-Position gefahren.",
|
||||
" | Verfährt den Variac um eine variable Anzahl an Schrittmotorschritten (als Parameter mit dem Befehl übergeben) vorwärts (forward).",
|
||||
" | Verfährt den Variac um eine variable Anzahl an Schrittmotorschritten (als Parameter mit dem Befehl übergeben) rückwärts (backward).",
|
||||
" | Führt einen Kommunikationstest durch, der prüft, ob der Arduino erfolgreich mit dem Computer kommunizieren kann.",
|
||||
" | Führt einen Röntgenschuss aus. Diese Funktion steuert nur die Röhre alleine, ohne das Filament an, was bedeutet, dass diese Funktion alleine keinen gültigen (Röntgenstrahlung emittierenden) Röntgenschuss generiert.",
|
||||
" | Ändert den Status (als Parameter mit dem Befehl übergeben) des Filaments. Eins (1) schaltet das Filament ein, null (0) schaltet es aus.",
|
||||
" | Führt einen gültigen Röntgenschuss aus (ACHTUNG: es werden Röntgenstrahlen emittiert). Schaltet vor der Emission das Filament ein, lässt dieses vorglühen, führt einen Schuss aus und deaktiviert anschließend das Filament.",
|
||||
" | Führt eine SCAN-Sequenz aus, welche die Gantry um einen variablen Winkel (als Parameter mit dem Befehl übergeben) drehen lässt und dabei nach einem bestimmten Muster (z.B. jedes fünfte Winkelgrad) einen Röntgenschuss ausführt (ACHTUNG: es werden Röntgenstrahlen emittiert). Dabei wird im Vorfeld des Scans das Filament aktiviert und im Anschluss deaktiviert."
|
||||
};
|
||||
#define PULS 0
|
||||
#define ANGL 1
|
||||
#define SPCL 2
|
||||
#define SPCC 3
|
||||
#define RES 4
|
||||
#define VARF 5
|
||||
#define VARB 6
|
||||
#define TEST 7
|
||||
#define RXON 8
|
||||
#define STFI 9
|
||||
#define RXSH 10
|
||||
#define SCAN 11
|
||||
#define GRP 12
|
||||
|
||||
#define NtClSpeed 200
|
||||
#define NtCcSpeed 200
|
||||
#define NtClSpeedSlow 100
|
||||
#define NtCcSpeedSlow 100
|
||||
#define PreHeatTime 10000
|
||||
#define CoolDownTime 10000
|
||||
#define XRayTime 120
|
||||
#define XRayMaxTime 300
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,47 @@
|
|||
#ifndef DVT_FILAMENTCLASS_H
|
||||
#define DVT_FILAMENTCLASS_H
|
||||
|
||||
|
||||
#include "DVT_Types.h"
|
||||
#include "DVT_MainClass.h"
|
||||
|
||||
class Filament {
|
||||
private:
|
||||
DVT_State_t CurState;
|
||||
bool Heat = false;
|
||||
public:
|
||||
Filament(bool State) {
|
||||
this->CurState.State = State;
|
||||
FILAMENT_SWITCH.SetState(State);
|
||||
}
|
||||
void SetFilamentState(bool State) {
|
||||
if (State != this->CurState.State) {
|
||||
this->CurState.State = State;
|
||||
this->CurState.Time = millis();
|
||||
FILAMENT_SWITCH.SetState(State);
|
||||
debugMSG("New State : " + String(this->CurState.State) + " Time: " + String(this->CurState.Time));
|
||||
} else {
|
||||
debugMSG("Same as Old State : " + String(this->CurState.State) + " Time: " + String(this->CurState.Time));
|
||||
}
|
||||
}
|
||||
bool GetFilamentState() {
|
||||
return FILAMENT_SWITCH.GetState();
|
||||
}
|
||||
bool Heated() {
|
||||
if (this->CurState.State == HIGH && this->CurState.Time + PreHeatTime <= millis() && Heat == false) {
|
||||
Heat = true;
|
||||
sysMSG("SYSTEM: Heated");
|
||||
return true;
|
||||
}
|
||||
if (Heat && this->CurState.State == LOW && this->CurState.Time + CoolDownTime <= millis() && Heat == true) {
|
||||
Heat = false;
|
||||
sysMSG("SYSTEM: Cold");
|
||||
}
|
||||
return Heat;
|
||||
}
|
||||
};
|
||||
|
||||
Filament FILAMENT = Filament(false);
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,65 @@
|
|||
#ifndef DVT_GANTRYCLASS_H
|
||||
#define DVT_GANTRYCLASS_H
|
||||
|
||||
#include "DVT_MainClass.h"
|
||||
|
||||
class Gantry {
|
||||
private:
|
||||
int nt_cl_speed;
|
||||
int nt_cc_speed;
|
||||
long CurEncoderPos;
|
||||
long NewEncoderPos;
|
||||
public:
|
||||
Gantry(int nt_cl_speed, int nt_cc_speed) {
|
||||
this->nt_cl_speed = nt_cl_speed;
|
||||
this->nt_cc_speed = nt_cc_speed;
|
||||
}
|
||||
void Start() {
|
||||
ARM_STOP.SetState(HIGH);
|
||||
sysMSG("SYSTEM: Gantry Started");
|
||||
}
|
||||
void Stop() {
|
||||
ARM_STOP.SetState(LOW);
|
||||
sysMSG("SYSTEM: Gantry Stopped");
|
||||
ARM_SPEED.SetAnalogState(0);
|
||||
}
|
||||
void ClRotation() {
|
||||
ARM_DIRECT.SetState(LOW);
|
||||
ARM_SPEED.SetAnalogState(this->nt_cl_speed);
|
||||
debugMSG("Clockwise Rotation");
|
||||
}
|
||||
void CcRotation() {
|
||||
ARM_DIRECT.SetState(HIGH);
|
||||
ARM_SPEED.SetAnalogState(this->nt_cc_speed);
|
||||
debugMSG("Counter Clockwise Rotation");
|
||||
}
|
||||
void SetClSpeed(int Speed) {
|
||||
if (Speed >= 0 && Speed <= 255) {
|
||||
this->nt_cl_speed = Speed;
|
||||
debugMSG("nt_cl_speed : " + String(Speed));
|
||||
} else {
|
||||
debugMSG("Invalid value : " + String(Speed) + " is not in range (0-255)");
|
||||
}
|
||||
}
|
||||
void SetCcSpeed(int Speed) {
|
||||
if (Speed >= 0 && Speed <= 255) {
|
||||
this->nt_cc_speed = Speed;
|
||||
debugMSG("nt_cc_speed : " + String(Speed));
|
||||
} else {
|
||||
debugMSG("Invalid value : " + String(Speed) + " is not in range (0-255)");
|
||||
}
|
||||
}
|
||||
int GetClSpeed() {
|
||||
debugMSG("nt_cl_speed : " + String(this->nt_cl_speed));
|
||||
return this->nt_cl_speed;
|
||||
}
|
||||
int GetCcSpeed() {
|
||||
debugMSG("nt_cc_speed : " + String(this->nt_cc_speed));
|
||||
return this->nt_cc_speed;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Gantry GANTRY = Gantry(NtClSpeed, NtCcSpeed);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,44 @@
|
|||
#ifndef DVT_VARIACLASS_H
|
||||
#define DVT_VARIACLASS_H
|
||||
|
||||
#include "DVT_Types.h"
|
||||
#include "DVT_MainClass.h"
|
||||
|
||||
int Limit = 0;
|
||||
|
||||
void IRAM_ATTR ISRVariacBack() {
|
||||
Limit = 2;
|
||||
STEPMOTOR_ABLE.SetState(HIGH);
|
||||
}
|
||||
void IRAM_ATTR ISRVariacFor() {
|
||||
Limit = 1;
|
||||
STEPMOTOR_ABLE.SetState(HIGH);
|
||||
}
|
||||
|
||||
class Variac {
|
||||
private:
|
||||
public:
|
||||
Variac() {
|
||||
}
|
||||
void Start() {
|
||||
STEPMOTOR_ABLE.SetState(LOW);
|
||||
attachInterrupt(VARIAC_LIMIT_BACK.GetPin(),ISRVariacBack,RISING);
|
||||
attachInterrupt(VARIAC_LIMIT_FOR.GetPin(),ISRVariacFor,RISING);
|
||||
debugMSG("Variac Started");
|
||||
}
|
||||
void Stop() {
|
||||
STEPMOTOR_ABLE.SetState(HIGH);
|
||||
detachInterrupt(VARIAC_LIMIT_BACK.GetPin());
|
||||
detachInterrupt(VARIAC_LIMIT_FOR.GetPin());
|
||||
debugMSG("Variac Stopped");
|
||||
}
|
||||
void Run() {
|
||||
|
||||
}
|
||||
void SetSteps() {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,46 @@
|
|||
#ifndef DVT_XRAYCLASS_H
|
||||
#define DVT_XRAYCLASS_H
|
||||
|
||||
|
||||
#include "DVT_MainClass.h"
|
||||
|
||||
class XRay {
|
||||
private:
|
||||
DVT_State_t CurState;
|
||||
int xray_time;
|
||||
public:
|
||||
XRay(int Time) {
|
||||
if (Time <= XRayMaxTime && Time != 0)
|
||||
this->xray_time = Time;
|
||||
else
|
||||
this->xray_time = XRayTime;
|
||||
}
|
||||
void Signal() {
|
||||
if (!this->CurState.State) {
|
||||
this->CurState.State = true;
|
||||
this->CurState.Time = millis();
|
||||
XRAY_SWITCH.SetState(this->CurState.State);
|
||||
sysMSG("SYSTEM: XRAY Started");
|
||||
}
|
||||
}
|
||||
void RunTime()
|
||||
{
|
||||
if (this->CurState.State && millis() >= this->CurState.Time + this->xray_time) {
|
||||
this->CurState.State = false;
|
||||
XRAY_SWITCH.SetState(this->CurState.State);
|
||||
sysMSG("SYSTEM: XRAY Stopped");
|
||||
}
|
||||
}
|
||||
void SetTime(int Time) {
|
||||
if (Time <= XRayMaxTime && Time != 0)
|
||||
this->xray_time = Time;
|
||||
else
|
||||
this->xray_time = XRayTime;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
XRay XRAY = XRay(XRayTime);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue