Jean-Philippe replied to the topic 'Moonlite focuser protocol' in the forum. 7 years ago

HelgeMK wrote: Hi Craig,

I am not sure if useful, I followed those instructions when "rebuilding" the moonlite focuser - see this link:

github.com/Hansastro/Focuser

In the library for the LM335 (lm335-cpp), which is used here as sensor, the following formula is applied (to the end of the lib), maybe you can leverage:

return (500.0*analogRead(this->aquisitionPin)/1024.0) - 273.15;


Be careful with the formula. I remarked that the temperature is not quite right. I think the factor 500 come from some try and error. It is something in my list of thing to improve. (I am the author of the library)

The conversion from Celsius to Hex is not very difficult. You can find it in the github repository in the Moonlite.cpp file. At the end. For the temperature the function "convertLongToChar" is what you looking for probably.

What happened with negative value... I am not sure of that... Check the function before using it. I have to verify that. I don't remember well.

For your question about how to code 20.5 in signed hex. There is a trick. In the protocol such values are not transfered as they are but they are multiplied by 2. Then you don't have to transfer a floating point value. That explain why the display is always with round or .5 values and nothing in between. (See the file Focuser.ino line 106)

The compensation is not used to calculate the temperature. This value is used to readjust the focus when the temperature changes. You focus, note the temperature and the number of steps of the focuser. You wait some times until the temperature is not the same. You refocus and note again the temperature and the number of steps. You know the differences for the temperature and the position between the two measures and you can calculate a step/degree value. This is the compensation value.

Jean-Phi

Read More...