×

INDI Library v2.0.6 is Released (02 Feb 2024)

Bi-monthly release with minor bug fixes and improvements

What are the kstars orders for arduino

  • Posts: 250
  • Thank you received: 3
Hello
I've created a program to control the opening of the roof of my observatory by means of POWER, OPEN, CLOSE and STOP buttons.

Now, I would like to parallel the kstars commands to be able to do it remotely.
But I haven't found it and I don't know how to do it.

Who can help me, thank you.
4 years 1 month ago #49152

Please Log in or Create an account to join the conversation.

You need to create an INDI Dome driver for this. Fortunately, there is a simple driver you can base your work on: github.com/indilib/indi/blob/master/drivers/dome/roll_off.cpp

So just edit the driver and put your commands in the right places.
4 years 1 month ago #49153

Please Log in or Create an account to join the conversation.

  • Posts: 250
  • Thank you received: 3
hello
so I'm putting in my code that I wrote for my observatory.
Do you think I can adapt it to the one you gave me?

But unfortunately I wrote it in French

<code>// OUVERTURE TOIT OBSERVATOIRE
// Avec fin de 2 fin de course et une position Parc
// Commande manuel Open,Close et Stop
// commande a distance

const int ledRepos = 3;
const int RelaisOuverture1 = 4;
const int RelaisOuverture2 = 5;
const int RelaisFermeture1 = 6;
const int RelaisFermeture2 = 7;
const int BoutonOpen = A0; //8
const int BoutonClose = A1;
const int BoutonStop = A2;
const int FinOuverture = 12;
const int FinFermeture = 10;
const int Telescope_Parc =2;
const int BoutonRelais =A3;
const int pinRelais =8;

int BoutonOpenState = 0;
int BoutonCloseState = 0;
int FinOuvertureState = 0;
int FinFermetureState = 0;
int Telescope_ParcState = 0;
int BoutonStopState = 0;

bool BoutonRelaisState = LOW; // *****

//les états possible
enum {Repos, Ouverture, Ouvert, Fermeture, Fermer};
int etat = Repos;

bool estAlimente = false; //*****

// le N° des connection et fonction
void setup() {
pinMode(ledRepos, OUTPUT);
pinMode(RelaisOuverture1, OUTPUT);
pinMode(RelaisOuverture2, OUTPUT);
pinMode(RelaisFermeture1, OUTPUT);
pinMode(RelaisFermeture2, OUTPUT);

pinMode(BoutonOpen, INPUT_PULLUP);
pinMode(BoutonClose, INPUT_PULLUP);
pinMode(BoutonStop, INPUT_PULLUP);
pinMode(FinOuverture, INPUT_PULLUP);
pinMode(FinFermeture, INPUT_PULLUP);
pinMode(Telescope_Parc, INPUT_PULLUP);


}// fin setup


void position_toit () { // début des statuts pour le loop
switch (etat) { // début du switch avec les possibilté
case Repos:
digitalWrite(ledRepos, HIGH);
digitalWrite(RelaisOuverture1, LOW);
digitalWrite(RelaisOuverture2, LOW);
digitalWrite(RelaisFermeture1, LOW);
digitalWrite(RelaisFermeture2, LOW);
if (BoutonOpenState == LOW && Telescope_ParcState == LOW ) {
etat = Ouverture;
delay(30);
}
else if(BoutonCloseState == LOW && FinFermetureState == HIGH ){
etat = Fermeture;
delay(30);
}
break;
case Ouverture:
digitalWrite(ledRepos, LOW);
digitalWrite(RelaisOuverture1, HIGH);
digitalWrite(RelaisOuverture2, HIGH);
digitalWrite(RelaisFermeture1, LOW);
digitalWrite(RelaisFermeture2, LOW);
if (FinOuvertureState == LOW) {
etat = Ouvert;
delay(30);
}
else if(Telescope_ParcState == HIGH || BoutonStopState == LOW) {
etat = Repos;
delay(30);
}
break;
case Ouvert:
digitalWrite(ledRepos, HIGH);
digitalWrite(RelaisOuverture1, LOW);
digitalWrite(RelaisOuverture2, LOW);
digitalWrite(RelaisFermeture1, LOW);
digitalWrite(RelaisFermeture2, LOW);
if (BoutonCloseState == LOW && Telescope_ParcState == LOW ) {
etat = Fermeture;
delay(30);
}
break;
case Fermeture:
digitalWrite(ledRepos, LOW);
digitalWrite(RelaisOuverture1, LOW);
digitalWrite(RelaisOuverture2, LOW);
digitalWrite(RelaisFermeture1, HIGH);
digitalWrite(RelaisFermeture2, HIGH);
if (FinFermetureState == LOW) {
etat = Fermer;
delay(30);
}
else if(Telescope_ParcState == HIGH || BoutonStopState == LOW) {
etat = Repos;
delay(30);

}
break;
case Fermer:
digitalWrite(ledRepos, LOW);
digitalWrite(RelaisOuverture1, LOW);
digitalWrite(RelaisOuverture2, LOW);
digitalWrite(RelaisFermeture1, LOW);
digitalWrite(RelaisFermeture2, HIGH);
etat = Repos;
break;
} //fin switch

}// fin void

void loop() {
BoutonRelaisState = digitalRead (BoutonRelais) ;
if (BoutonRelaisState == HIGH) {
estAlimente = !estAlimente; // ****
delay (30);
}
if (estAlimente) {
digitalWrite (pinRelais, HIGH);

// début du programme des fonctions
BoutonOpenState = digitalRead (BoutonOpen) ;
BoutonCloseState = digitalRead (BoutonClose) ;
FinOuvertureState = digitalRead (FinOuverture) ;
FinFermetureState = digitalRead (FinFermeture) ;
Telescope_ParcState = digitalRead (Telescope_Parc);
BoutonStopState = digitalRead (BoutonStop);
position_toit() ;

} else digitalWrite (pinRelais, LOW);

} // fin loop ou programme
</code>
Last edit: 4 years 1 month ago by Porchet.
4 years 1 month ago #49154

Please Log in or Create an account to join the conversation.

  • Posts: 250
  • Thank you received: 3
What you need to know is how to find the name of the order,
like open, close, and power.
Last edit: 4 years 1 month ago by Porchet.
4 years 1 month ago #49155

Please Log in or Create an account to join the conversation.

  • Posts: 250
  • Thank you received: 3
Hello Knro
Then I have a problem with the driver you gave me.
When I put it on the arduino, it tells me it's got some code errors.
4 years 1 month ago #49478

Please Log in or Create an account to join the conversation.

That an INDI driver, it shouldn't be on Arduino, it's the C++ code that should be compiled on your Raspberry PI (or PC).
4 years 1 month ago #49479

Please Log in or Create an account to join the conversation.

  • Posts: 220
  • Thank you received: 27
Hi,

you need to create a serial event in your arduino code. That need to process charachters coming from the rpi or linux machine.
Then you define some commands like "#OPEN", "#CLOSE" (or whatever you like)
In the the loop where you process the buttons you should tes t if a valid command has arrived and act upon.

Then you change the driver that Jasem suggested and insert your commands there in the right place. Compile and test ....

(I can dig up some arduino examples, need a bit of time though)

Hope this helps

Paul
4 years 1 month ago #49481

Please Log in or Create an account to join the conversation.

  • Posts: 250
  • Thank you received: 3
I don't understand anything anymore...
I have to create an indi driver that I have to put on the PC?
And how do I install a new driver on kstars, if that's what I have to do ?

And then I have to create a link between the indi driver and the program on the arduino, is that right ?

So if I understood well, I will need help, guys, anyway I need help because I don't understand the C language or the others, alas.

I just created the program in C language for my arduino, with the help of some guys who helped me a lot and explained me how to do it and corrected the code.
4 years 1 month ago #49486

Please Log in or Create an account to join the conversation.

  • Posts: 220
  • Thank you received: 27
Had a look at the "dome controller" code that Jasem suggested. Need to investigate how that works first. Then I can maybe create an example.

Paul
4 years 1 month ago #49500

Please Log in or Create an account to join the conversation.

  • Posts: 250
  • Thank you received: 3
So we agree that Jasem's link is the driver in Kstars and we have to write the code in C for the arduino?

If that's the case, how do I get the Roll_off driver to connect to the arduino and what are the relevant commands to make my roof work?
4 years 1 month ago #49504

Please Log in or Create an account to join the conversation.

  • Posts: 220
  • Thank you received: 27
Hmmm; see you have cross posted this under a different name in another section of the forum. Seems you get help there, saves me valuable time!

Yes EKOS talks to a dome via a dome-driver. The dome driver talks to the dome controller (in this case an arduino) So you need to make:
1 : A driver on your indi machine accordining to the specs of a dome driver. And in this case talks to the Arduino
2: An arduino program that controls the hardware (difgital pins) and can get commands and report status to the "driver". This is usually done via serial commands.

Paul
4 years 1 month ago #49524

Please Log in or Create an account to join the conversation.

  • Posts: 250
  • Thank you received: 3
Hello
how to install an indi driver in kstars.
that's why I opened this position here.
And the other post will be how to communicate between the kstars driver and Arduino.

But the most important thing is that I didn't manage to install the indi driver that Jasem advised me to be able to modify it.
I even tried to create a driver as simple as possible according to a tutorial, but then how do you install it?

Thanks
Christophe
4 years 1 month ago #49526

Please Log in or Create an account to join the conversation.

Time to create page: 1.950 seconds