×

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

Bi-monthly release with minor bug fixes and improvements

Need help operating an arduino uno and kstars

  • Posts: 311
  • Thank you received: 42
I wonder if it would be practical to have something for roll off roofs similar to the Weather Meta driver. A built in driver that could send/receive a set of generic commands to a controller so that one did not need to be able to program and maintain a driver in the INDI environment in order to automate a roof.
4 years 1 month ago #49365

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

  • Posts: 250
  • Thank you received: 3
hello Wolfgang
Do you have an example of the simplest possible code (C language) that works with the Kstars interface.
I don't need the dome to have the goto function, since I only have the roof.
So that I can understand it and see what it does when I modify it.

because so far I've only found super complicated code.

Thanks
Christophe
4 years 1 month ago #49405

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

  • Posts: 1185
  • Thank you received: 370
Hi Christophe,
well, at the end all code is complicated - except for the own code :-)

Lets give it a try. If you really want to integrate your roof into Kstars, you need to write your own INDI driver. It might look very complicated at the beginning. So a good point for starting to program INDI drivers, take the examples distributed with the INDI sources. There is a good tutorial available.

If you are familiar with building INDI from its sources and first basics of INDI drivers, you could continue playing around with the DomeSimulator. This simulator has more or less all functionality on board except for the connection to a real dome via USB or similar.

On the other side, you need to add functionality to your Arduino driver so that it can be controlled via the Serial device. Here is a snippet from my weather station that shows how this works in principle:
<code>
void setup() {
Serial.begin(9600);
// wait for serial port to connect. Needed for native USB
while (!Serial) continue;
}

...

void loop() {


while (Serial.available() > 0) {
switch (Serial.read()) {
case 'v':
sendCurrentVersion();
break;
case 'w':
sendSensorData();
break;
}
}

delay(50);
}
</code>

This simple code recognises two single character commands: 'v' and 'w'. If a 'v' is received, the current version is printed, if 'w' is received, the sensor data is printed to the Serial interface.

So in your case, as a first step, it would be sufficient if the commands like 'o' for opening the roof and 'c' for closing the roof are recognised. As a first step, simply use the Serial Monitor of the Arduino IDE to test your driver.

OK, ok, I know, that was quite lengthy. Maybe you start first with the Serial communication of your Arduino. As soon as it is working, just come back and we will do the next step.

- Wolfgang
Last edit: 4 years 1 month ago by Wolfgang Reissenberger.
4 years 1 month ago #49412

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

  • Posts: 250
  • Thank you received: 3
hello Wolfgang
Then I think you trust me too much.
I just figured out the code for my arduino in C.

what I manage to do, and I have no merit, is to make the relays work with firmdata from Kstars...

But I'm willing to learn ..............
Christophe
4 years 1 month ago #49417

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

  • Posts: 1185
  • Thank you received: 370
Aaah, never surrender. Coding is just about bringing characters into the right sequence :-)

Give it a try with the serial interface, that's by far the easiest part.

- Wolfgang
4 years 1 month ago #49422

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

  • Posts: 250
  • Thank you received: 3
've been trying this copying the tutorial, just to see.
Doesn't it work?
Can you explain to me why he won't
#include "indibase/defaultdevice.h"

Well, I'm sure I did, but I'll give you the code. I'm sure you know it.
#include "indibase/defaultdevice.h"
 
class SimpleDevice : public INDI::DefaultDevice
{
public:
    SimpleDevice();
 
protected:
    bool Connect();
    bool Disconnect();
    const char *getDefaultName();
 
};
#include
 
#include "simpledevice.h"
 
std::unique_ptr simpleDevice(new SimpleDevice());
/**************************************************************************************
** Return properties of device.
***************************************************************************************/
void ISGetProperties (const char *dev)
{
 simpleDevice->ISGetProperties(dev);
}
 
/**************************************************************************************
** Process new switch from client
***************************************************************************************/
void ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n)
{
 simpleDevice->ISNewSwitch(dev, name, states, names, n);
}
 
/**************************************************************************************
** Process new text from client
***************************************************************************************/
void ISNewText (const char *dev, const char *name, char *texts[], char *names[], int n)
{
 simpleDevice->ISNewText(dev, name, texts, names, n);
}
 
/**************************************************************************************
** Process new number from client
***************************************************************************************/
void ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n)
{
 simpleDevice->ISNewNumber(dev, name, values, names, n);
}
 
/**************************************************************************************
** Process new blob from client
***************************************************************************************/
void ISNewBLOB (const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n)
{
    simpleDevice->ISNewBLOB(dev, name, sizes, blobsizes, blobs, formats, names, n);
}
 
/**************************************************************************************
** Process snooped property from another driver
***************************************************************************************/
void ISSnoopDevice (XMLEle *root)
{
  INDI_UNUSED(root);
}
**************************************************************************************
** Client is asking us to establish connection to the device
***************************************************************************************/
bool SimpleDevice::Connect()
{
    IDMessage(getDeviceName(), "Simple device connected successfully!");
    return true;
}
 
/**************************************************************************************
** Client is asking us to terminate connection to the device
***************************************************************************************/
bool SimpleDevice::Disconnect()
{
    IDMessage(getDeviceName(), "Simple device disconnected successfully!");
    return true;
}
/**************************************************************************************
** INDI is asking us for our default device name
***************************************************************************************/
const char * SimpleDevice::getDefaultName()
{
    return "Simple Device";
}
4 years 1 month ago #49437

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

  • Posts: 1185
  • Thank you received: 370
The right way to include defaultdevice.h is:
#include "defaultdevice.h"
4 years 1 month ago #49440

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

  • Posts: 250
  • Thank you received: 3
I always make a mistake.
4 years 1 month ago #49443

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

  • Posts: 1185
  • Thank you received: 370
Are you working on Arduino code within the Arduino IDE? The code you posted above does not contain StandardFirmata.
4 years 1 month ago #49445

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

  • Posts: 250
  • Thank you received: 3
Yes I Writing with arduino IDE
But that means it's not the code.

I need to set up something different to run this CODE
Last edit: 4 years 1 month ago by Porchet.
4 years 1 month ago #49449

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

  • Posts: 1185
  • Thank you received: 370
Right. For INDI, QtCreator is a good IDE.
4 years 1 month ago #49456

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

  • Posts: 250
  • Thank you received: 3
hello
Don't worry if sometimes I take time to answer, because I don't live where you live, but I live in Switzerland, so there may be a time difference with your country.
Last edit: 4 years 1 month ago by Porchet.
4 years 1 month ago #49464

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

Time to create page: 0.829 seconds