Page 1 of 1

Arduino

Posted: 31 Jan 2024, 14:14
by frankvuijsters
Can anybody help me how to integrate Arduino-programms (for relays and servo's) into AstroArt-programms. I need that to also control remotely the calibration-lamps in my spectroscope and flip-mirror on it, together with all the other AstroArtprogramming.

Re: Arduino

Posted: 31 Jan 2024, 15:34
by AlessandroMaitan
Hi,
I'm currently using such an integration for opening and closing the roof of my observatory after checking the relevant status of either the telescope (it shall be parked) and the roof itself. This last control is made by using a magnetic switch. The relevant commands, that are defined in the Arduino sketch, are passed to Arduino via the serial port connected to Arduino itself. I guess that you have already developed the relevant sketch.

Alessandro

Re: Arduino

Posted: 04 Mar 2024, 18:12
by frankvuijsters
Hi,

what my issue is: the communication between Astro Art and Arduino via serial commands.
Not Arduino sketches only the interface with Astro Art.

Re: Arduino

Posted: 05 Mar 2024, 09:33
by AlessandroMaitan
Hi Frank,
I'd like to share the code calling Arduino to verify if the roof is opened or closed. It was developed several years ago by a friend for his own observatory. I modified a litlle the original one:

QUOTE
RoofStatusCheck()

End

Function RoofStatusCheck()

cmd_serl=7 'serial port set by Arduino
fed_1str$="ing1"
fed_2str$="ing2"

roof_opened="y"
roof_closed="y"

' LETTURA SENSORI IN INGRESSO ***************************************

' rilevatore di tetto aperto
if roof_opened="y" then
serial.connect(cmd_serl) 'connection to the serial port
pause(2)
serial.send(fed_1str$) 'lancio stringa di interrogazione ingresso 1
pause(2)
status_ig$=(serial.receive())
status_i1$=(status_ig$[1])
serial.disconnect()
if status_i1$="1" then print "Roof status: opened ("+status_i1$+")"
endif
'fine rilevatore di tetto aperto

'rilevatore di tetto chiuso
if roof_closed="y" then
serial.connect(cmd_serl) 'connessione alla porta seriale
pause(2)
serial.send(fed_2str$) 'lancio stringa di interrogazione ingresso 2
pause(2)
status_ig$=(serial.receive())
status_i2$=(status_ig$[1])
serial.disconnect()
if status_i2$="1" then print "Roof status: closed ("+status_i2$+")"
endif

'fine rilevatore di tetto chiuso

end function

UNQUOTE

Regards

Alessandro

Re: Arduino

Posted: 09 May 2024, 17:15
by frankvuijsters
Hi Alessandro,
thanks for your message.
It seems that the communication with Arduino via serial.connect works (checked with Serial.println) but the script does not go into the loop after the setup part.
The communication with serial.send(string) in Astro Art and Serial.receive () in my Arduino script does not work.
What is your script in Arduino to receive "ing1" or "ing2" correctly and execute further as you want?
It would be great when it also works with my spectroscope (Neon-lamp, Flat-lamp, servo for flip mirror).
I hope you will reply, frank

Re: Arduino

Posted: 10 May 2024, 19:58
by AlessandroMaitan
Hi Frank,
the part of the Arduino sketch to receive "ing1" and "ing2" is as follows:
QUOTE
// ******************
// **** INGRESSI ****
// ******************

fed1 = digitalRead(BUTTON1); // legge il valore dell'input e lo conserva
// controlla che l'input sia HIGH (pulsante premuto)
if (fed1 == HIGH) {
stato1 = 1;
}
else {
stato1 = 0;
}

fed2 = digitalRead(BUTTON2); // legge il valore dell'input e lo conserva
// controlla che l'input sia HIGH (pulsante premuto)
if (fed2 == HIGH) {
stato2 = 1;
}
else {
stato2 = 0;
}


fed3 = digitalRead(BUTTON3); // legge il valore dell'input e lo conserva
// controlla che l'input sia HIGH (pulsante premuto)
if (fed3 == HIGH) {
stato3 = 1;
}
else {
stato3 = 0;
}


val = Serial.readString();

if(val == "ing1" ){ //interrogo l'ingresso 1 (Apertura tetto)
Serial.println(stato1);
}
if(val == "ing2" ){ //interrogo l'ingresso 2 (Chiusura tetto)
Serial.println(stato2);
}

if(val == "ing3" ){ //interrogo l'ingresso 3 (Telescope park)
Serial.println(stato3);
}

UNQUOTE

unfortunately is written in Italian, but I think you can easily understand the meaning of the notes.
However I can send you the whole sketch as it is because I have not written it.
Hope this can help.
Alessandro

Re: Arduino

Posted: 11 May 2024, 08:25
by frankvuijsters
Goodmorning Allesandro,

What I saw that you use a "pause(2)" in the Astro Art script, maybe that is important, further I always used only the Arduino command "Serial.read()" or "Serial.parseInt()" but did not know the "Serial.ReadString()" command. I'm going to try.
On the other hand I use the "switch()"-command in stead of "if" statements.
When the script runs properly I'll send it to you.
Thanks, for your prompt and adequate reply.

see you laterr, frank

Re: Arduino

Posted: 12 May 2024, 06:27
by AlessandroMaitan
Hi Frank,
I would like to enclose the file file with the whole code for Arduino so you can have the full picture.

Alessandro