Welcome, Guest
Username: Password: Remember me
14 Nov 2018
Glad to announce of release of INDI Library v1.7.5 on 2018-11-14. A few drivers were added in this release as we continue to improve & stabilize existing drivers.
Read More...
  • Page:
  • 1

TOPIC: Cooling of CCD via pyindi

Cooling of CCD via pyindi 5 months 3 weeks ago #26218

Hello Together,

it is my first post here and I have a few questions about the usage of pyindi.

My setup is a Raspberry Pi 3 B with Ubuntu Mate,
I followed the tutorial on indilib.org/develop/indi-python-bindings.html

To obtain a proper installation I had to install libz3-dev, libcfitsio-dev and libnova-dev.
A symbolic link from /lib/arm-linux-gnueabihf/libz.so.1 to /lib/arm-linux-gnueabihf/libz.so was needed
otherwise I had the error message ld can not find lz

The following code is working with a "Atik 383L+ CCD" and with a "ZWO CCD ASI120MC"
and is close to the example: indilib.org/develop/tutorials/151-time-l...ith-indi-python.html :
import sys, time, logging
import PyIndi
import numpy as np

exp_time=sys.argv[1]
name=sys.argv[2]
  
class IndiClient(PyIndi.BaseClient):
 
    device = None
 
    def __init__(self):
        super(IndiClient, self).__init__()
        self.logger = logging.getLogger('PyQtIndi.IndiClient')
        self.logger.info('creating an instance of PyQtIndi.IndiClient')
    def newDevice(self, d):
        self.logger.info("new device " + d.getDeviceName())
        if d.getDeviceName() == "Atik 383L+ CCD":
            print ("found Atik 383L+ CCD")
            self.logger.info("Atik 383L+ CCD")
            # save reference to the device in member variable
            self.device = d
        '''
        if d.getDeviceName() == "ZWO CCD ASI120MC":
            print ("found ZWO CCD ASI120MC")
            self.logger.info("ZWO CCD ASI120MC")
            # save reference to the device in member variable
            self.device = d
        '''
    def newProperty(self, p):
        self.logger.info("new property "+ p.getName() + " for device "+ p.getDeviceName())
        if self.device is not None and p.getName() == "CONNECTION" and p.getDeviceName() == self.device.getDeviceName():
            self.logger.info("Got property CONNECTION for CCD Simulator!")
            # connect to device
            self.connectDevice(self.device.getDeviceName())
            # set BLOB mode to BLOB_ALSO
            self.setBLOBMode(1, self.device.getDeviceName(), None)
        if p.getName() == "CCD_EXPOSURE":
            # take first exposure
            self.takeExposure()
    def removeProperty(self, p):
        self.logger.info("remove property "+ p.getName() + " for device "+ p.getDeviceName())

    def newBLOB(self, bp):
	    #self.logger.info("new BLOB "+ bp.name)
	    # get image data
	    img = bp.getblobdata()
	    import io
	    # write image data to StringIO buffer
	    blobfile = io.BytesIO(img)
	    # open a file and save buffer to disk
	    with open("/home/user/Desktop/"+name+".fit", "wb") as f:
	        f.write(blobfile.getvalue())
	    # start new exposure for timelapse images!
	    # self.takeExposure()
	    # disconnect from server
	    self.disconnectServer()

    def newSwitch(self, svp):
        self.logger.info ("new Switch "+ svp.name + " for device "+ svp.device)
    def newNumber(self, nvp):
        self.logger.info("new Number "+ nvp.name + " for device "+ nvp.device)
    def newText(self, tvp):
        self.logger.info("new Text "+ tvp.name + " for device "+ tvp.device)
    def newLight(self, lvp):
        self.logger.info("new Light "+ lvp.name + " for device "+ lvp.device)
    def newMessage(self, d, m):
        #self.logger.info("new Message "+ d.messageQueue(m))
        pass
    def serverConnected(self):
        print("Server connected ("+self.getHost()+":"+str(self.getPort())+")")
    def serverDisconnected(self, code):
        self.logger.info("Server disconnected (exit code = "+str(code)+","+str(self.getHost())+":"+str(self.getPort())+")")
    def takeExposure(self):
        self.logger.info(">>>>>>>>")
        #get current exposure time
        exp = self.device.getNumber("CCD_EXPOSURE")
        exp[0].value = np.float(exp_time)
        # send new exposure time to server/device
        self.sendNewNumber(exp)
  
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO)
 
# instantiate the client
indiclient=IndiClient()
# set indi server localhost and port 7624
indiclient.setServer("localhost",7624)
# connect to indi server
print("Connecting to indiserver")
if (not(indiclient.connectServer())):
     print("No indiserver running on "+indiclient.getHost()+":"+str(indiclient.getPort())+" - Try to run")
     print("  indiserver indi_simulator_telescope indi_simulator_ccd")
     sys.exit(1)
  
# start endless loop, client works asynchron in background
while True:
    time.sleep(1)

So now I have a program, which takes an exposure of specified length and generate a file at the Desktop, but how do I control the cooling of the camera via python.
Do I just need to set the CCD_TEMPERATURE and the camera is taking care of the control loop, or do I have to monitor the CCD_TEMPERATURE and then switch the CCD_COOLER on and off? Is there some example code for this, especially with some syntax example?

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

Cooling of CCD via pyindi 5 months 3 weeks ago #26235

  • Gilles
  • Gilles's Avatar
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 126
  • Karma: 2
  • Thank you received: 32
Hi
Your asi120 is cooled ??
Gilles

Edit : reading too fast, didn't see the Atik :)

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

Last Edit: by Gilles.

Cooling of CCD via pyindi 5 months 3 weeks ago #26239

Whenever I want to integrate a new feature to my python sequencer, I first start to read this page:
indilib.org/develop/developer-manual/101...ties.html#h2-general

Here, I see that there is the 'CCD_TEMPERATURE' property, which is of type Number, and is not readonly. It contains only one member which is "CCD_TEMPERATURE_VALUE". Of course, I guess you know that.

The next step is usually just to query/send the new value. To do so , I highly recommend you to use the class that you can find here:
github.com/GuLinux/indi-lite-tools/blob/...i_sequence/device.py

Then when you have instanciated your device, you can do something like this:
self.setNumber('CCD_TEMPERATURE', {'CCD_TEMPERATURE_VALUE': float(-30)}, sync=True, timeout=60)

In the device class, you can see that, setting the sync to true makes the client to wait for the server to update state to PyIndi.IPS_OK, PyIndi.IPS_IDLE. It has to be tested, but I guess that setting temperature may (or may not) return whenever the target temperature has been reached.

Good luck with coding you client.
Additional question, in your code, you wrote 'PyQtIndi.IndiClient' is it normal ? do you use a PyQt indiclient ?

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

Cooling of CCD via pyindi 4 months 3 weeks ago #26825

Hello Together,

fehlfarbe ( indilib.org/support/community/2262-fehlfarbe/profile.html ) helped me to get the temperature control working.

To read the device temperature I changed the "def newProperty()" function, it looks now like this:
  def newProperty(self, p):
        self.logger.info("new property "+ p.getName() + " for device "+ p.getDeviceName())
        if self.device is not None and p.getName() == "CONNECTION" and p.getDeviceName() == self.device.getDeviceName():
            self.logger.info("Got property CONNECTION for CCD Simulator!")
            # connect to device
            self.connectDevice(self.device.getDeviceName())
            # set BLOB mode to BLOB_ALSO
            self.setBLOBMode(1, self.device.getDeviceName(), None)
        if p.getName() == "CCD_TEMPERATURE":
            temp = self.device.getNumber("CCD_TEMPERATURE")
            print(temp[0].value)
            self.disconnectServer()
so it waits until the property "CCD_TEMPERATURE" is available and prints its value.

To change the temperature set-point one can use the following:
    def newProperty(self, p):
        self.logger.info("new property "+ p.getName() + " for device "+ p.getDeviceName())
        if self.device is not None and p.getName() == "CONNECTION" and p.getDeviceName() == self.device.getDeviceName():
            self.logger.info("Got property CONNECTION for CCD Simulator!")
            # connect to device
            self.connectDevice(self.device.getDeviceName())
            # set BLOB mode to BLOB_ALSO
            self.setBLOBMode(1, self.device.getDeviceName(), None)
        if p.getName() == "CCD_TEMPERATURE":
            temp = self.device.getNumber("CCD_TEMPERATURE")
            temp[0].value=np.float(1)                        ### new temperature to reach
            self.sendNewNumber(temp)
            self.disconnectServer()

This sets the temperature to 1°C and sends this new set-point to the server.
The temperature is then regulated internally to the new set-point.
With the first example of "newProperty()" you can watch the temperature drop and finally stabilize at the new temperature.

Thanks.

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

Last Edit: by spektroskopie.
  • Page:
  • 1
Time to create page: 0.126 seconds

Login



3rd Party

Choose from the numerous 3rd party INDI drivers to suit your needs!

Got Problem?

Check out the FAQ, the forum, and the bug tracking system to resolve any issues you might have!
You can also subscribe to INDI newsletter and development mailing lists to get the latest updates on INDI!


Gallery

Replica

Why INDI

Replica