Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB_Dewpoint #2064

Closed
kris969 opened this issue May 27, 2024 · 5 comments
Closed

USB_Dewpoint #2064

kris969 opened this issue May 27, 2024 · 5 comments
Assignees

Comments

@kris969
Copy link

kris969 commented May 27, 2024

I have developed an Raspberry HAT based on an Arduino nano for this driver. I will publish it as public, in the following days, just time for me to finish all necessary files for this repo.
Here is the 3D view of this HAT:
image

It just finished all tests and it works fine with the USB_Dewpoint indi driver.
I just have a suggestion concerning calibrations witch have currently limited to a range of [0 to +9].
Could it be possible to have a range of [-9 to +9]?

@knro
Copy link
Contributor

knro commented May 28, 2024

@jpaana Any issues with updating calibration range as proposed above?

@jpaana
Copy link
Contributor

jpaana commented May 28, 2024

Unfortunately the protocol to communicate with USB_Dewpoint is very limited, all commands need to be exactly 6 characters long and the command to set the calibration (SCAnnn) has only one digit per channel (1, 2, ambient) so the values really can be only 0-9. If you want negative values too, and as you have control of how your device interprets those values I suggest biasing the range with for example -4 so then 0 really means -4, 4 means 0 and 9 means 5. Unfortunately the values shown in the INDI gui would still be 0-9 though.

@kris969
Copy link
Author

kris969 commented May 29, 2024 via email

@jpaana
Copy link
Contributor

jpaana commented May 29, 2024

The protocol I'm talking about is the one used when talking to the device over serial port, not the INDI protocol. That protocol is fixed by the device firmware so we can't change it for the current USB_Dewpoint devices. There isn't a real document about the protocol as I just reverse engineered it by snooping traffic from the Windows program to the device and back, but the commands are listed in the beginning of usb_dewpoint.h in the driver. The command in question to set calibration values for example is there as #define UDP_CALIBRATION_CMD "SCA%1u%1u%1u" // channel 1-2-A, value 0-9
which is then used as format string with snprintf call to format the values to suitable format:

bool USBDewpoint::setCalibrations(unsigned int ch1, unsigned int ch2, unsigned int ambient)
{
    char cmd[UDP_CMD_LEN + 1];
    char resp[UDP_RES_LEN];

    snprintf(cmd, UDP_CMD_LEN + 1, UDP_CALIBRATION_CMD, ch1, ch2, ambient);
    return sendCommand(cmd, resp);
}

%1u means one digit of unsigned decimal input value, so if the input values are for example ch1 = 1, ch2 = 3 and ambient = 7 then the string sent to the device is SCA137. The device protocol is such that each command is exactly 6 characters and the device responds after it receives them. There is no start/stop markers of any kind which makes the protocol quite fragile to desynchronization, which is why there is a Resync function that sends up to 5 space characters to get an error message which gets the device and driver back in sync.

As your device is not actually USB_Dewpoint and you can change the firmware to do what ever you want, there's no reason to limit yourself to the USB_Dewpoint driver as such, except it being a simple way to get started. So you could make a new driver for your particular device and modify it to your heart's content :) There are also other similar devices like https://github.com/jbrazio/arduheater for which I also made a driver at one point when someone asked, but I don't think it's included in INDI as it wasn't really tested. And for example #2024 is an alternative as well.

@kris969
Copy link
Author

kris969 commented May 29, 2024 via email

@knro knro closed this as completed Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants