QHYCCD

QHY600M - Read Modes switch does not working

QHY600M - Read Modes switch does not working
« on: August 26, 2020, 05:29:58 PM »
I'm new owner of QHY600M camera. I'm using this camera on Linux system.
I use following software:
INDI 1.8.6 - main library for control camera
CCDCiel - main program for taking images

INDI 1.8.6 has support QHY SDK version 20.7.26.
I have no problem when I use camera with default settings - I can change gain / offset / taking images.
But problem appear if I try to change Read Mode even when I changed Read Mode to the same mode. Camera back to normal after driver restart (I don't need disconnect camera or switch of power).
Then I received following log:
Code: [Select]
2020-08-26T22:50:46.340  Start new log
2020-08-26T22:51:15.542  QHY CCD QHY600M-a7ca3c4: [INFO] Connected to QHY600M-a7ca3c438f7ea8e27.
2020-08-26T22:51:15.542  QHY CCD QHY600M-a7ca3c4: [INFO] Using QHY SDK version 20.7.26
2020-08-26T22:51:15.542  QHY CCD QHY600M-a7ca3c4: [INFO] Number of read modes: 4
2020-08-26T22:51:15.542  QHY CCD QHY600M-a7ca3c4: [INFO] Camera exposure limits: Min: 0.000001s Max: 3600s Step 0s
2020-08-26T22:51:15.551  QHY CCD QHY600M-a7ca3c4: [INFO] Current read mode: 0
2020-08-26T22:51:15.551  QHY CCD QHY600M-a7ca3c4: [INFO] Gain Settings: Value: 30 Min: 0 Max: 200 Step 1
2020-08-26T22:51:15.551  QHY CCD QHY600M-a7ca3c4: [INFO] Offset Settings: Value: 30 Min: 0 Max: 255 Step 1
2020-08-26T22:51:15.551  QHY CCD QHY600M-a7ca3c4: [INFO] USB Traffic Settings: Value: 50 Min: 0 Max: 60 Step 3
2020-08-26T22:51:20.147  QHY CCD QHY600M-a7ca3c4: [INFO] Upload settings set to local only.
2020-08-26T22:51:27.546  QHY CCD QHY600M-a7ca3c4: [WARNING] Telescope focal length is missing.
2020-08-26T22:51:27.546  QHY CCD QHY600M-a7ca3c4: [WARNING] Telescope aperture is missing.
2020-08-26T22:51:27.546  QHY CCD QHY600M-a7ca3c4: [INFO] Image saved to /mnt/ramdisk/ccdciel_tmp.fits
2020-08-26T22:51:37.606  QHY CCD QHY600M-a7ca3c4: [INFO] Read mode updated to 0
2020-08-26T22:51:37.606  QHY CCD QHY600M-a7ca3c4: [INFO] GetQHYCCDReadModeResolution in this ReadMode: imageW: 9600 imageH: 6422
2020-08-26T22:51:46.116  QHY CCD QHY600M-a7ca3c4: [INFO] Set QHYCCD ROI resolution (24,0) (9600,6422) failed (-1)
2020-08-26T23:02:43.623  QHY CCD QHY600M-a7ca3c4: [INFO] Read mode updated to 0
2020-08-26T23:02:43.623  QHY CCD QHY600M-a7ca3c4: [INFO] GetQHYCCDReadModeResolution in this ReadMode: imageW: 9600 imageH: 6422
2020-08-26T23:02:55.826  QHY CCD QHY600M-a7ca3c4: [INFO] Set QHYCCD ROI resolution (24,0) (9600,6422) failed (-1)
and
Code: [Select]
2020-08-26T22:51:45.859 2: Start single preview
2020-08-26T22:51:46.116 0: QHY CCD QHY600M-a7ca3c4: Error
2020-08-26T22:51:46.217 9: Abort
2020-08-26T22:52:50.892 0: QHY CCD QHY600M-a7ca3c4: No response from camera!
2020-08-26T22:52:50.993 9: Abort
I don't know why switching Read Mode does not working and how to fix this error.



Re: QHY600M - Read Modes switch does not working
« Reply #1 on: August 27, 2020, 03:37:29 PM »
I found bug in "qhy_ccd.cpp" file in area where "Read Modes Control" is performed.
Code read area resolution by following fuction:
Code: [Select]
GetQHYCCDReadModeResolution(m_CameraHandle, ReadModeN[0].value, &imageRMw, &imageRMh);
But unfortunately function read total numbers of pixels to variables: [ imageRMw / imageRMh ]
including inactive pixels - for QHY600M they are: 9600x6422 (camera can not return image in this size).
I added code which test this values with effective area resolution and replace wrong values.
Whole corrected block of code is below and it is working correctly:
Code: [Select]
        //////////////////////////////////////////////////////////////////////
        /// Read Modes Control
        //////////////////////////////////////////////////////////////////////
        else if (!strcmp(name, ReadModeNP.name))
        {
            uint32_t imageRMw, imageRMh;
            double newReadMode = ReadModeN[0].value;
            double chipw, chiph, pixelw, pixelh;
            IUUpdateNumber(&ReadModeNP, values, names, n);
            int rc;

            // Current effective area for mode [NEW CODE]
            uint32_t effROI_subX, effROI_subY, effROI_subW, effROI_subH;
            rc = GetQHYCCDEffectiveArea(m_CameraHandle, &effROI_subX, &effROI_subY, &effROI_subW, &effROI_subH);
            if (rc == QHYCCD_SUCCESS)
            {
                LOGF_INFO("GetQHYCCDEffectiveArea: subX :%d subY: %d subW: %d subH: %d", effROI_subX, effROI_subY,
                           effROI_subW, effROI_subH);
            }
            // Current effective area for mode [NEW CODE]

            // Set readout mode
            rc = SetQHYCCDReadMode(m_CameraHandle, ReadModeN[0].value); // [NEW CODE] declaration int rc removed
            if (rc == QHYCCD_SUCCESS)
            {
                LOGF_INFO("Read mode updated to %.f", ReadModeN[0].value);

                // Get resolution
                GetQHYCCDReadModeResolution(m_CameraHandle, ReadModeN[0].value, &imageRMw, &imageRMh);

                // Test image resolution values if they are greater than effective area resolution then replace imageRMw / imageRMh values [NEW CODE]
                if(imageRMw > effROI_subW || imageRMh > effROI_subH) {
                    LOGF_INFO("GetQHYCCDReadModeResolution in this ReadMode: [ imageW: %u > imageEAW: %u ] / [ imageH: %u > imageEAH: %u ]", imageRMw,effROI_subW,imageRMh,effROI_subH);
                    imageRMw = effROI_subW;
                    imageRMh = effROI_subH;
                }
                // Test image resolution values if they are greater than effective area resolution then replace imageRMw / imageRMh values [NEW CODE]

                LOGF_INFO("GetQHYCCDReadModeResolution in this ReadMode: imageW: %d imageH: %d", imageRMw, imageRMh);

                ReadModeNP.s = IPS_OK;
                saveConfig(true, ReadModeNP.name);
                uint32_t nbuf, imagew, imageh, bpp;
                if (isSimulation())
                {
                    pixelh = pixelw = 5.4;
                    bpp             = 8;
                }
                else
                {
                    int ret = GetQHYCCDChipInfo(m_CameraHandle, &chipw, &chiph, &imagew, &imageh, &pixelw, &pixelh, &bpp);

                    /* JM: We need GetQHYCCDErrorString(ret) to get the string description of the error, please implement this in the SDK */
                    if (ret != QHYCCD_SUCCESS)
                    {
                        LOGF_ERROR("Error: GetQHYCCDChipInfo() (%d)", ret);
                        return false;
                    }

                }

                SetCCDParams(imageRMw, imageRMh, bpp, pixelw, pixelh);
                nbuf = imageRMw * imageRMh * PrimaryCCD.getBPP() / 8;
                PrimaryCCD.setFrameBufferSize(nbuf);

                if (HasStreaming())
                {
                    Streamer->setPixelFormat(INDI_MONO);
                    Streamer->setSize(imageRMw, imageRMh);
                }


            }
            else
            {
                ReadModeNP.s = IPS_ALERT;
                ReadModeN[0].value = newReadMode;
                LOGF_ERROR("Failed to update read mode: %d", rc);
            }

            IDSetNumber(&ReadModeNP, nullptr);
            return true;
        }

 

Re: QHY600M - Read Modes switch does not working
« Reply #2 on: September 01, 2020, 04:27:19 PM »
Patch has been applied to new GIT  version INDI 3rdparty code: https://github.com/indilib/indi-3rdparty.
Now I can switch the 'Read Mode' without trouble in INDI panel and it is working well with CCDCiel program. The patch was tested with QHY600M camera only.

ma_rs

Re: QHY600M - Read Modes switch does not working
« Reply #3 on: September 03, 2020, 10:23:58 PM »
For the Resolution problem, you can try "GetQHYCCDEffectiveArea" function;
I have some problem in running indi 1.8.6 now, and can not reproduce the issue correctly, but basically, after you change the read mode, camera needs some time to response next command
I try CCDCiel  connect 600M with Ascom, it looks ok
I will try to fix my new indi and reproduce that issue again, hopefully, I can find a way to fix that

Re: QHY600M - Read Modes switch does not working
« Reply #4 on: September 12, 2020, 07:25:21 AM »
Quote
I have some problem in running indi 1.8.6 now, and can not reproduce the issue correctly, but basically, after you change the read mode, camera needs some time to response next command
No, camera work without problems after I change read mode.
Quote
For the Resolution problem, you can try "GetQHYCCDEffectiveArea" function;
INDI can detect camera effective area, but when I switched 'Read Mode' in INDI panel then program lost its effective area configuration. In patch I've fixed this bug and it is INDI GIT.