Voici mon module d"alimentation pour les lampes de calibration d'un spectrographe echelle (NOUT):
Une alim 220 V --> 5 et 12 V
Une carte Arduino uno
Un module de 4 relais
Le sketch Arduino:
const int analogPinSol = 2;//Solenoid
const int analogPinRelco = 3; //Relco
const int analogPinTung = 4; // Tunsten
const int analogPinLed = 5;
int incomingByte; // a variable to read incoming serial data from processing
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the pin as outputs:
pinMode(analogPinSol, OUTPUT);
pinMode(analogPinRelco, OUTPUT);
pinMode(analogPinLed, OUTPUT);
pinMode(analogPinTung, OUTPUT);
digitalWrite(analogPinSol, LOW);
digitalWrite(analogPinRelco, LOW);
digitalWrite(analogPinTung, LOW);
digitalWrite(analogPinLed, LOW);
}
void loop() {
if (Serial.available() > 0) {
incomingByte = Serial.read();
// send orders to Arduino Uno from the order sent by Processing sketch
if (incomingByte == 'A') {
digitalWrite(analogPinSol, HIGH);
digitalWrite(analogPinRelco, HIGH);
}
if (incomingByte == 'B') {
digitalWrite(analogPinSol, HIGH);
digitalWrite(analogPinTung, HIGH);
}
if (incomingByte == 'C') {
digitalWrite(analogPinSol, LOW);
digitalWrite(analogPinLed, HIGH);
}
if (incomingByte == 'L') {
digitalWrite(analogPinSol, LOW);
digitalWrite(analogPinRelco, LOW);
digitalWrite(analogPinLed, LOW);
digitalWrite(analogPinTung, LOW);
}
}
}
Pour la commande, j'ai utilisé Processing (https://processing.org/)
Interface graphique:
Sketch Processing:
import processing.serial.*;
float boxX;
float boxY;
int boxSize = 20;
int Xbox = 80;
int Ybox =40;
int dX1 = 100;
int dX2 = 200;
int dX3 = 300;
int dY1 = 50;
int dY2 = 100;
int dY3 = 150;
int alertTung = 120;
int t0;
int t1;
int duree;
boolean Relco = false;
boolean Led = false;
boolean Tung = false;
color vert =color(0,255,0);
color rouge =color(255,0,0);
color bleu = color(0,0,255);
color gris =color(100,100,100);
color grisclair = color(200,200,200);
color blanc =color(255,255,255);
boolean mouseOverBox = false;
Serial port;
void setup() {
size(400, 200);
boxX = width / 2.0;
boxY = height / 2.0;
rectMode(RADIUS);
println(Serial.list());
port = new Serial(this, Serial.list()[2], 9600);
background(200,200,200);
rectMode(CENTER);
fill(bleu);
text("ON", 20,55);
text("OFF", 20,105);
text("Relco", dX1-Xbox/2, 20);
text("Tung", dX2-Xbox/2, 20);
text("Led", dX3-Xbox/2, 20);
fill(gris);
rect(dX1, dY1, Xbox, Ybox);
fill(gris);
rect(dX2, dY1, Xbox, Ybox);
fill(gris);
rect(dX3, dY1, Xbox, Ybox);
fill(blanc);
rect(dX1, dY3, Xbox, Ybox/2);
fill(blanc);
rect(dX2, dY3, Xbox, Ybox/2);
fill(blanc);
rect(dX3, dY3, Xbox, Ybox/2);
fill(rouge);
rect(dX1, dY2, Xbox, Ybox);
fill(rouge);
rect(dX2, dY2, Xbox, Ybox);
fill(rouge);
rect(dX3, dY2, Xbox, Ybox);
}
void draw() {
int h = hour();
int m = minute();
int s = second();
textSize(14);
delay(100);
// 1. Relco
if (mouseX > dX1 - Xbox/2 && mouseX < dX1 + Xbox/2 &&
mouseY > dY1 - Ybox/2 && mouseY < dY1 + Ybox/2 && mousePressed && Led == false && Relco == false && Tung == false) {
Relco = true;
fill(vert);
rect(dX1, dY1, Xbox, Ybox);
fill(gris);
rect(dX1, dY2, Xbox, Ybox);
port.write('A');
t0 = second()+minute()*60+hour()*3600;
}
if (mouseX > dX1 - Xbox/2 && mouseX < dX1 + Xbox/2 &&
mouseY > dY2 - Ybox/2 && mouseY < dY2 + Ybox/2 && mousePressed && Relco == true) {
Relco = false;
fill(rouge);
rect(dX1, dY2, Xbox, Ybox);
fill(gris);
rect(dX1, dY1, Xbox, Ybox);
port.write('L');
fill(blanc);
rect(dX1, dY3, Xbox, Ybox/2);
}
if (Relco == true){
fill(blanc);
rect(dX1, dY3, Xbox, Ybox/2);
t1 = h*3600+m*60+s;
duree = t1 - t0;
fill(0,0,255);
text(duree + " s", dX1-5, dY3+5);
}
// 2. Tung
if (mouseX > dX2 - Xbox/2 && mouseX < dX2 + Xbox/2 &&
mouseY > dY1 - Ybox/2 && mouseY < dY1 + Ybox/2 && mousePressed && Led == false && Relco == false && Tung == false) {
Tung = true;
fill(vert);
rect(dX2, dY1, Xbox, Ybox);
fill(gris);
rect(dX2, dY2, Xbox, Ybox);
port.write('B');
t0 = second()+minute()*60+hour()*3600;
}
if (mouseX > dX2 - Xbox/2 && mouseX < dX2 + Xbox/2 &&
mouseY > dY2 - Ybox/2 && mouseY < dY2 + Ybox/2 && mousePressed && Tung == true) {
Tung = false;
fill(rouge);
rect(dX2, dY2, Xbox, Ybox);
fill(gris);
rect(dX2, dY1, Xbox, Ybox);
port.write('L');
fill(blanc);
rect(dX2, dY3, Xbox, Ybox/2);
}
if (Tung == true){
fill(blanc);
rect(dX2, dY3, Xbox, Ybox/2);
t1 = h*3600+m*60+s;
duree = t1 - t0;
fill(0,0,255);
text(duree + " s", dX2-5, dY3+5);
}
// 3. LED
if (mouseX > dX3 - Xbox/2 && mouseX < dX3 + Xbox/2 &&
mouseY > dY1 - Ybox/2 && mouseY < dY1 + Ybox/2 && mousePressed && Led == false && Relco == false && Tung == false) {
Led = true;
fill(vert);
rect(dX3, dY1, Xbox, Ybox);
fill(gris);
rect(dX3, dY2, Xbox, Ybox);
port.write('C');
t0 = second()+minute()*60+hour()*3600;
}
if (mouseX > dX3 - Xbox/2 && mouseX < dX3 + Xbox/2 &&
mouseY > dY2 - Ybox/2 && mouseY < dY2 + Ybox/2 && mousePressed && Led == true) {
Led = false;
fill(rouge);
rect(dX3, dY2, Xbox, Ybox);
fill(gris);
rect(dX3, dY1, Xbox, Ybox);
port.write('L');
fill(blanc);
rect(dX3, dY3, Xbox, Ybox/2);
fill(grisclair);
noStroke();
rect(dX3, dY3+30, Xbox, Ybox-5);
}
if (Led == true){
fill(blanc);
rect(dX3, dY3, Xbox, Ybox/2);
t1 = h*3600+m*60+s;
duree = t1 - t0;
fill(0,0,255);
text(duree + " s", dX3-5, dY3+5);
if (duree > alertTung){
fill(255,0,0);
text("Durée Max", dX3-35, dY3+30);
Tung = false;
fill(rouge);
rect(dX3, dY2, Xbox, Ybox);
fill(gris);
rect(dX3, dY1, Xbox, Ybox);
port.write('L');
fill(blanc);
rect(dX3, dY3, Xbox, Ybox/2);
fill(grisclair);
noStroke();
rect(dX3, dY3+30, Xbox, Ybox-5);
}
}
}
Alimentation lampes calibration
-
- Posts: 1522
- Joined: Fri Sep 23, 2011 1:01 pm
- Location: Rouen
- Contact:
Alimentation lampes calibration
François Teyssier
http://www.astronomie-amateur.fr
http://www.astronomie-amateur.fr
-
- Posts: 1247
- Joined: Thu Sep 29, 2011 6:35 am
- Location: Rhône Alpes FRANCE
- Contact:
Re: Alimentation lampes calibration
Super comme réalisation François !!!
Cela peut être décliné pour n'importe quel commande de lampe de calibration.
Merci pour le partage.
Cela peut être décliné pour n'importe quel commande de lampe de calibration.
Merci pour le partage.
LHIRES III #5, LISA, e-Shel, C14, RC400 Astrosib, AP1600
http://o.garde.free.fr/astro/Spectro1/Bienvenue.html
http://o.garde.free.fr/astro/Spectro1/Bienvenue.html
-
- Posts: 625
- Joined: Thu Nov 03, 2011 8:50 pm
Re: Alimentation lampes calibration
Bonjour François,
Many thanks for that for your job, that is a useful tool for the NOU_T echelle spectrograph, and as Olivier said for a lot of other ones.
Really we needed this device and software.
Amicalement, Joan.
Many thanks for that for your job, that is a useful tool for the NOU_T echelle spectrograph, and as Olivier said for a lot of other ones.
Really we needed this device and software.
Amicalement, Joan.
-
- Posts: 191
- Joined: Tue Aug 16, 2016 12:11 am
Re: Alimentation lampes calibration
Félicitations François,
Superbe réalisation !
Michel VERLINDEN
Superbe réalisation !
Michel VERLINDEN
-
- Posts: 24
- Joined: Mon Apr 15, 2019 4:33 pm
Re: Alimentation lampes calibration
Belle réalisation, vraiment intéressant !
Merci pour le partage François
Matthieu
Merci pour le partage François
Matthieu