×
INDI Library v1.8.5 Released (19 Apr 2020)

April 2020 release of INDI Library v1.8.5 introduces new drivers while providing fixes and improvements to existing devices and core framework.

Need help operating an arduino uno and kstars

3 months 3 weeks ago
constant1462
Expert Boarder
Expert Boarder
Posts: 84
More
Topic Author
Need help operating an arduino uno and kstars #49294
Hello
I already posted a message on the Kstars section, but I'm putting it back here.
so here it is, I created a little arduino program to open the roof of my observatory with buttons and limit switches.
But now, how do I get Kstars to control my program?
Or how do I know which command to write in "C language" to control my program that I can put in place of my OPEN and CLOSE buttons?

I'm telling you all right now that I'm starting in C language, so I think I'm missing a lot of things for kstars to communicate with my program on the arduino uno board.

thanks again for your help

And I don't speak English very well, unfortunately.

Translated with www.DeepL.com/Translator (free version)

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

3 months 3 weeks ago
sterne-jaeger
Platinum Boarder
Platinum Boarder
Posts: 497
Karma: 6
More
Need help operating an arduino uno and kstars #49298
Maybe the easiest way is to write an INDI driver. There is already an indi-duino package available in indi-3rdparty. It contains sample drivers for several use cases.

- Wolfgang

TSA-120 + FSQ-85 + GSO 150/750 | Avalon Linear + M-zero | Moravian G2-8300 + ASI 1600mm pro + ASI 294mc pro | KStars/INDI on Raspberry Pi 4 with Raspbian 10
The following user(s) said Thank You constant1462

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

3 months 3 weeks ago
constant1462
Expert Boarder
Expert Boarder
Posts: 84
More
Topic Author
Need help operating an arduino uno and kstars #49302
Hello
Thank you for your answer, but how do we get to
"Perhaps the simplest way is to write an INDI driver. "

What do I have to write at the beginning of my CODE on the arduino if I want to
have for example the function: CONNECTION = CONNECT?

With
"There's already an indi-duino package available in indi-3rdparty"

Thank you
Christophe

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

3 months 3 weeks ago 3 months 3 weeks ago by constant1462.
constant1462
Expert Boarder
Expert Boarder
Posts: 84
More
Topic Author
Need help operating an arduino uno and kstars #49318
how do i know which order Kstars sends to open the roof of the dome at the arduino?

I give you my code ,but most write in french
/*Program to open the roof of my Observatory.
With 2 buttons Open,Close and an Emergency Stop.
With realy supply power
There are also 2 limit switches and a control as the telescope and of course the park position.*/

const int ledRepos = 3;         // LedWaiting
const int RelaisOuverture1 = 4; // Open relay1
const int RelaisOuverture2 = 5; // Open relay2
const int RelaisFermeture1 = 6; // Close relay1
const int RelaisFermeture2 = 7; // Close relay2
const int BoutonOpen = A0;      // Open button
const int BoutonClose = A1;     // Close button
const int BoutonStop = A2;      // Stop button
const int FinOuverture = 12;    // limit switche Open
const int FinFermeture = 10;    // limit switche Close
const int Telescope_Parc =2;    // park position switche
const int BoutonRelais   =A3;   // Power supply control
const int pinRelais      =8;    // Power supply relay
  
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);  //  LedWaiting
  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);  //  LedWaiting
      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);  //  LedWaiting
      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);  //  LedWaiting
      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);  //  LedWaiting
      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);  //  LedWaiting
      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

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

3 months 3 weeks ago
constant1462
Expert Boarder
Expert Boarder
Posts: 84
More
Topic Author
Need help operating an arduino uno and kstars #49320
If you want, I can translate the entire code into English.
if it will help you help me.

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

3 months 3 weeks ago
sterne-jaeger
Platinum Boarder
Platinum Boarder
Posts: 497
Karma: 6
More
Need help operating an arduino uno and kstars #49322
Hi Christophe,
no need to translate, my French is sufficient.

As far as I understand your Arduino code, you have buttons to control your dome. Or what are "BoutonOpen" and "BoutonClose"?

What you first need to think about is how to connect your Arduino with another software running outside of the Arduino.

I think the easiest way is using the serial interface of the Arduino and read and write through this interface. I guess you have your Arduino connected via USB. If you for example read and write to the USB device, you could for example write a specific INDI driver for your dome, that reads and writes on this USB device.

Does it make sense to you?

- Wolfgang

TSA-120 + FSQ-85 + GSO 150/750 | Avalon Linear + M-zero | Moravian G2-8300 + ASI 1600mm pro + ASI 294mc pro | KStars/INDI on Raspberry Pi 4 with Raspbian 10

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

3 months 3 weeks ago
constant1462
Expert Boarder
Expert Boarder
Posts: 84
More
Topic Author
Need help operating an arduino uno and kstars #49330
Hello Wolfgang
Then you understand very well, I have indeed 3 buttons to have a manual control from inside my observatory.
Open Button, Close Button and Stop Button.

My idea was to be able to connect my arduino to my PC which is in my observatory where I can connect remotely.

The problem is that I don't know how to make the two communicate together.
I have already had trouble making the code of the arduino, because I begin in the C language.

I understand that Kstars is controlling an arduino, but that I have to add in my CODE to make it work.

I think that the ideal would have been to find the command that will be put in the place of my open and close buttons, but I'm not sure it's possible.

The other solution is to implement a program in parallel or in the CODE I wrote so that both work but with priority to the command from Kstars.

But is it possible?

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

3 months 3 weeks ago
sterne-jaeger
Platinum Boarder
Platinum Boarder
Posts: 497
Karma: 6
More
Need help operating an arduino uno and kstars #49337
Well, Christophe, I’m afraid its not that easy. You need to do two things to get it working:
  1. Change your Arduino code so that it may react upon commands from the Serial interface. Simply call google with “arduino serial command”
  2. Write your own INDI dome driver that communicates with your Arduino over the commands you define. As an example, you could take a closer look to the Maxdome implementation
If you have written your own driver, you could simply select your driver as dome and use the observatory UI of kstars to control your dome.

Wolfgang

TSA-120 + FSQ-85 + GSO 150/750 | Avalon Linear + M-zero | Moravian G2-8300 + ASI 1600mm pro + ASI 294mc pro | KStars/INDI on Raspberry Pi 4 with Raspbian 10

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

3 months 3 weeks ago
wotalota
Expert Boarder
Expert Boarder
Posts: 138
More
Need help operating an arduino uno and kstars #49338
I have an indi driver that communicates to a arduino client. I wrote the serial communication between the two using an ASCII protocol. Since then I see there are libraries that would have probably saved a bunch of code. But it is generally working. It is a modification of the rolloff roof simulator driver and works with the observatory control so it can close the roof during bad weather. The functions are as you describe open, close abort. I can post the code of both sides somewhere for you to copy which will give you an example of one approach.

If you have not already done so, I would suggest you at least browse the material under the develop menu at the top of the web page.

Regards
Tom

Mach1, TS86SDQ, ASI071, ASI174, OAG, focusPro

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

3 months 3 weeks ago
constant1462
Expert Boarder
Expert Boarder
Posts: 84
More
Topic Author
Need help operating an arduino uno and kstars #49343
Hello Tom
then I'd be interested in an example or the code you've developed.
And see if there's anything I can do to adapt it to mine.

Hello, Wolfgang.
My problem is I don't know how to write a driver and I'm not sure how to do it.
I've tried to understand, but since I use translators (since my English is not very good).
And I'm not even sure that even without that I'll understand how to do it.

best regards
Christophe

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

3 months 3 weeks ago
wotalota
Expert Boarder
Expert Boarder
Posts: 138
More
Need help operating an arduino uno and kstars #49346
See if the following folder and file is accessible to you.

my.pcloud.com/publink/show?code=kZaL7skZ...2bLwxV56lCGRESSCCYz7
rolloffino.tar.gz

It contains the Arduino sketch, the rest is the INDI driver and what is needed to build it as a 3rd Party driver and make it accessible in Ekos. There are a couple of notes to myself in there since I forget everything after a week or two. A first step might be to learn how to build INDI and a 3rd party driver. If you are using the nightly builds this can be reduced to a few directions and scripts. I have not tried to locate the sources for a particular stable release but expect that is possible.

Mach1, TS86SDQ, ASI071, ASI174, OAG, focusPro
Attachments:

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

3 months 3 weeks ago
constant1462
Expert Boarder
Expert Boarder
Posts: 84
More
Topic Author
Need help operating an arduino uno and kstars #49357
hello
Thanks for the files!
But could you explain a little bit about your files.
Because I don't understand them all, alas.

Because the ready file on the arduino program is much shorter than the rolloffino files and what is the difference between the two files?
rolloffino?

As you can see, I'm a beginner.

Thanks again for your help

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

Time to create page: 0.652 seconds