This commit is contained in:
Edward V. Emelianov 2025-02-23 22:41:07 +03:00
parent a9974aab04
commit 4fcb5af94b
5 changed files with 117 additions and 71 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 15.0.1, 2025-02-20T21:58:21. --> <!-- Written by QtCreator 15.0.1, 2025-02-23T22:39:22. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

View File

@ -65,7 +65,7 @@ static mcc_errcodes_t init(conf_t *c){
DBG("Bad value of MountReqInterval"); DBG("Bad value of MountReqInterval");
ret = MCC_E_BADFORMAT; ret = MCC_E_BADFORMAT;
} }
char buf[1024]; uint8_t buf[1024];
data_t d = {.buf = buf, .len = 0, .maxlen = 1024}; data_t d = {.buf = buf, .len = 0, .maxlen = 1024};
// read input data as there may be some trash on start // read input data as there may be some trash on start
if(!SSrawcmd(CMD_EXITACM, &d)) ret = MCC_E_FAILED; if(!SSrawcmd(CMD_EXITACM, &d)) ret = MCC_E_FAILED;

View File

@ -118,7 +118,7 @@ static void parse_encbuf(uint8_t databuf[ENC_DATALEN], struct timeval *tv){
// try to read 1 byte from encoder; return -1 if nothing to read or -2 if device seems to be disconnected // try to read 1 byte from encoder; return -1 if nothing to read or -2 if device seems to be disconnected
static int getencbyte(){ static int getencbyte(){
if(encfd < 0) return -1; if(encfd < 0) return -1;
uint8_t byte; uint8_t byte = 0;
fd_set rfds; fd_set rfds;
struct timeval tv; struct timeval tv;
do{ do{

View File

@ -18,6 +18,11 @@
#pragma once #pragma once
#ifdef __cplusplus
extern "C"
{
#endif
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <sys/time.h> #include <sys/time.h>
@ -55,8 +60,30 @@ typedef struct{
} data_t; } data_t;
typedef struct{ typedef struct{
uint8_t XBits; uint8_t motrev :1; // If 1, the motor encoder is incremented in the opposite direction
uint8_t YBits; uint8_t motpolarity :1; // If 1, the motor polarity is reversed
uint8_t encrev :1; // If 1, the axis encoder is reversed
uint8_t dragtrack :1; // If 1, we are in computerless Drag and Track mode
uint8_t trackplat :1; // If 1, we are in the tracking platform mode
uint8_t handpaden :1; // If 1, hand paddle is enabled
uint8_t newpad :1; // If 1, hand paddle is compatible with New hand paddle, which allows slewing in two directions and guiding
uint8_t guidemode :1; // If 1, we are in guide mode. The pan rate is added or subtracted from the current tracking rate
} xbits_t;
typedef struct{
uint8_t motrev :1; // If 1, the motor encoder is incremented in the opposite direction
uint8_t motpolarity :1; // If 1, the motor polarity is reversed
uint8_t encrev :1; // If 1, the axis encoder is reversed
/* If 1, we are in computerless Slew and Track mode
(no clutches; use handpad to slew; must be in Drag and Track mode too) */
uint8_t slewtrack :1;
uint8_t digin_sens :1; // Digital input from radio handpad receiver, or RA PEC Sensor sync
uint8_t digin :3; // Digital input from radio handpad receiver
} ybits_t;
typedef struct{
xbits_t XBits;
ybits_t YBits;
uint8_t ExtraBits; uint8_t ExtraBits;
uint16_t ain0; uint16_t ain0;
uint16_t ain1; uint16_t ain1;
@ -110,3 +137,8 @@ typedef struct{
} mount_t; } mount_t;
extern mount_t Mount; extern mount_t Mount;
#ifdef __cplusplus
}
#endif

View File

@ -23,43 +23,7 @@
#include "sidservo.h" #include "sidservo.h"
#if 0 /*********** base commands ***********/
// ASCII commands
#define U8P(x) ((uint8_t*)x)
// get binary data of all statistics
#define CMD_GETSTAT U8P("XXS")
// send short command
#define CMD_SHORTCMD U8P("XXR")
// send long command
#define CMD_LONGCMD U8P("YXR")
// get/set X/Y in motsteps
#define CMD_MOTX U8P("X")
#define CMD_MOTY U8P("Y")
// -//- in encoders' ticks
#define CMD_ENCX U8P("XZ")
#define CMD_ENCY U8P("YZ")
// normal stop X/Y
#define CMD_STOPX U8P("XN")
#define CMD_STOPY U8P("YN")
// emergency stop
#define CMD_EMSTOPX U8P("XG")
#define CMD_EMSTOPY U8P("YG")
// getters of motor's encoders per rev
#define CMD_GETXMEPR U8P("XXU")
#define CMD_GETYMEPR U8P("XXV")
// -//- axis encoders
#define CMD_GETXAEPR U8P("XXT")
#define CMD_GETYAEPR U8P("XXZ")
// exit ASCII checksum mode
#define CMD_EXITACM U8P("YXY0\r\xb8")
#endif
// get binary data of all statistics
#define CMD_GETSTAT "XXS"
// send short command
#define CMD_SHORTCMD "XXR"
// send long command
#define CMD_LONGCMD "YXR"
// get/set X/Y in motsteps // get/set X/Y in motsteps
#define CMD_MOTX "X" #define CMD_MOTX "X"
#define CMD_MOTY "Y" #define CMD_MOTY "Y"
@ -111,24 +75,97 @@
// normal stop X/Y // normal stop X/Y
#define CMD_STOPX "XN" #define CMD_STOPX "XN"
#define CMD_STOPY "YN" #define CMD_STOPY "YN"
// lower speed -> drag&track or slew&track
#define CMD_STOPTRACKX "XNT"
#define CMD_STOPTRACKY "YNT"
// emergency stop // emergency stop
#define CMD_EMSTOPX "XG" #define CMD_EMSTOPX "XG"
#define CMD_EMSTOPY "YG" #define CMD_EMSTOPY "YG"
// get/set X/Ybits // get/set X/Ybits
#define CMD_BITSX "XB" #define CMD_BITSX "XB"
#define CMD_BITSY "YB" #define CMD_BITSY "YB"
// getters of motor's encoders per rev
#define CMD_GETXMEPR "XXU" /*********** getters/setters without "Y" variant ***********/
#define CMD_GETYMEPR "XXV" // get handpad status (decimal)
#define CMD_HANDPAD "XK"
// get TCPU (deg F)
#define CMD_TCPU "XH"
// get firmware version *10
#define CMD_FIRMVER "XV"
// get motor voltage *10
#define CMD_MOTVOLTAGE "XJ"
// get/set current CPU clock (milliseconds)
#define CMD_MILLIS "XY"
// reset servo
#define CMD_RESET "XQ"
// clear to factory defaults
#define CMD_CLRDEFAULTS "XU"
// save configuration to flash ROM
#define CMD_WRITEFLASH "XW"
// read config from flash to RAM
#define CMD_READFLASH "XT"
// write to flash following full config (128 bytes + 2 bytes of checksum)
#define CMD_PROGFLASH "FC"
// read configuration (-//-)
#define CMD_DUMPFLASH "SC"
// get serial number
#define CMD_SERIAL "YV"
/*********** extended commands ***********/
// get/set latitute
#define CMD_LATITUDE "XXL"
// getters/setters of motor's encoders per rev
#define CMD_MEPRX "XXU"
#define CMD_MEPRY "XXV"
// -//- axis encoders // -//- axis encoders
#define CMD_GETXAEPR "XXT" #define CMD_AEPRX "XXT"
#define CMD_GETYAEPR "XXZ" #define CMD_AEPRY "XXZ"
// get/set slew rate
#define CMD_SLEWRATEX "XXA"
#define CMD_SLEWRATEY "XXB"
// get/set pan rate
#define CMD_PANRATEX "XXC"
#define CMD_PANRATEY "XXD"
// get/set platform tracking rate
#define CMD_PLATRATE "XXE"
// get/set platform up/down adjuster
#define CMD_PLATADJ "XXF"
// get/set platform goal
#define CMD_PLATGOAL "XXG"
// get/set guide rate
#define CMD_GUIDERATEX "XXH"
#define CMD_GUIDERATEY "XXI"
// get/set picservo timeout (seconds)
#define CMD_PICTMOUT "XXJ"
// get/set digital outputs of radio handpad
#define CMD_RADIODIGOUT "XXQ"
// get/set argo navis mode
#define CMD_ARGONAVIS "XXN"
// get/set local search distance
#define CMD_LOSCRCHDISTX "XXM"
#define CMD_LOSCRCHDISTY "XXO"
// get/set backlash
#define CMD_BACKLASHX "XXO"
#define CMD_BACKLASHY "XXP"
// get binary data of all statistics
#define CMD_GETSTAT "XXS"
// send short command
#define CMD_SHORTCMD "XXR"
// send long command
#define CMD_LONGCMD "YXR"
/*********** special ***********/
// exit ASCII checksum mode // exit ASCII checksum mode
#define CMD_EXITACM "YXY0\r\xb8" #define CMD_EXITACM "YXY0\r\xb8"
// controller status: // controller status:
// X# Y# XZ# YZ# XC# YC# V# T# X[AM] Y[AM] K# // X# Y# XZ# YZ# XC# YC# V# T# X[AM] Y[AM] K#
// X,Y - motor, XZ,YZ - encoder, XC,YC - current*100, V - voltage*10, T - temp (F), XA,YA - mode (A[uto]/M[anual]), K - handpad status bits // X,Y - motor, XZ,YZ - encoder, XC,YC - current*100, V - voltage*10, T - temp (F), XA,YA - mode (A[uto]/M[anual]), K - handpad status bits
#define CMD_GETSTAT "\r" #define CMD_GETSTATTEXT "\r"
// steps per revolution // steps per revolution
//#define X_MOT_STEPSPERREV (3325440.) //#define X_MOT_STEPSPERREV (3325440.)
@ -164,29 +201,6 @@
#define XencTOL (25.) #define XencTOL (25.)
typedef struct{
uint8_t motrev :1; // If 1, the motor encoder is incremented in the opposite direction
uint8_t motpolarity :1; // If 1, the motor polarity is reversed
uint8_t encrev :1; // If 1, the axis encoder is reversed
uint8_t dragtrack :1; // If 1, we are in computerless Drag and Track mode
uint8_t trackplat :1; // If 1, we are in the tracking platform mode
uint8_t handpaden :1; // If 1, hand paddle is enabled
uint8_t newpad :1; // If 1, hand paddle is compatible with New hand paddle, which allows slewing in two directions and guiding
uint8_t guidemode :1; // If 1, we are in guide mode. The pan rate is added or subtracted from the current tracking rate
} xbits_t;
typedef struct{
uint8_t motrev :1; // If 1, the motor encoder is incremented in the opposite direction
uint8_t motpolarity :1; // If 1, the motor polarity is reversed
uint8_t encrev :1; // If 1, the axis encoder is reversed
/* If 1, we are in computerless Slew and Track mode
(no clutches; use handpad to slew; must be in Drag and Track mode too) */
uint8_t slewtrack :1;
uint8_t digin_sens :1; // Digital input from radio handpad receiver, or RA PEC Sensor sync
uint8_t digin :3; // Digital input from radio handpad receiver
} ybits_t;
// all need data in one // all need data in one
typedef struct{ // 41 bytes typedef struct{ // 41 bytes
uint8_t ctrlAddr; // 0 a8 + controller address uint8_t ctrlAddr; // 0 a8 + controller address