-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathepos.h
167 lines (135 loc) · 3.45 KB
/
epos.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/**
* @file epos.h
* @brief Header for Maxon Motor EPOS serial port communication driver.
*/
#include <windows.h>
#include <stdint.h>
enum {
EPOS_CONTROL_WORD_INDEX=0x6040,
EPOS_MODES_OPERATION_INDEX=0x6060,
EPOS_VELOCITY_MODE_SP_INDEX=0x206B,
EPOS_POSITION_MODE_SP_INDEX=0x2062,
EPOS_TARGET_VELOCITY_INDEX=0x60FF,
EPOS_TARGET_POSITION_INDEX=0x607A,
EPOS_POSITION_ACTUAL_VALUE_INDEX=0x6064
} epos_obj_index_t;
enum {
EPOS_FAULT_RESET_CMD=0x0080,
EPOS_SHUTDOWN_CMD=0x0006,
EPOS_SWITCH_ON_CMD=0x0007,
EPOS_ENABLE_OPERATION_CMD=0x000F,
EPOS_HALT_CMD=0x0102,
EPOS_GOTO_POSITION_REL_CMD=0x007F,
EPOS_GOTO_POSITION_ABS_CMD=0x003F,
EPOS_GOTO_VELOCITY_CMD=0x000F
} epos_commands_t;
typedef enum {
EPOS_HOMING_MODE=0x06,
EPOS_PROFILE_VELOCITY_MODE=0x03,
EPOS_PROFILE_POSITION_MODE=0x01,
EPOS_POSITION_MODE=0xFF,
EPOS_VELOCITY_MODE=0xFE,
EPOS_CURRENT_MODE=0xFD,
EPOS_DIAGNOSTIC_MODE=0xFC,
EPOS_MASTER_ENCODER_MODE=0xFB,
EPOS_STEP_DIRECTION_MODE=0xFA
} epos_mode_t;
/**
* @brief Read from the EPOS object dictionary.
*
* It is a blocking function call.
*
* @returns 0 if success, nonzero otherwise.
*/
int epos_read_object(HANDLE file, uint16_t index, uint8_t subindex,
uint8_t nodeid, uint32_t *value_ptr);
/**
* @brief Write to the EPOS object dictionary.
*
* It is a blocking function call.
*
* @returns 0 if success, nonzero otherwise.
*/
int epos_write_object(HANDLE file, uint16_t index, uint8_t subindex,
uint8_t nodeid, uint32_t value);
/**
* @brief Open EPOS serial port.
*
* It is a blocking function call.
*
* @returns file handle
*/
HANDLE epos_open_port(const char *path);
/**
* @brief Send FAULT RESET command to epos.
*
* It is a blocking function call.
*
* @returns 0 if success, nonzero otherwise.
*/
int epos_fault_reset(HANDLE file, uint8_t nodeid);
/**
* @brief Send SHUTDOWN command to epos.
*
* It is a blocking function call.
*
* @returns 0 if success, nonzero otherwise.
*/
int epos_shutdown(HANDLE file, uint8_t nodeid);
/**
* @brief Send SWITCH ON command to epos.
*
* It is a blocking function call.
*
* @returns 0 if success, nonzero otherwise.
*/
int epos_switch_on(HANDLE file, uint8_t nodeid);
/**
* @brief Send ENABLE OPERATION command to epos.
*
* It is a blocking function call.
*
* @returns 0 if success, nonzero otherwise.
*/
int epos_enable_operation(HANDLE file, uint8_t nodeid);
/**
* @brief Send HALT command to epos.
*
* It is a blocking function call.
*
* @returns 0 if success, nonzero otherwise.
*/
int epos_halt(HANDLE file, uint8_t nodeid);
/**
* @brief Send GO TO RELATIVE POSITION command to epos.
*
* It is a blocking function call.
*
* @returns 0 if success, nonzero otherwise.
*/
int epos_goto_position_rel(HANDLE file, uint8_t nodeid);
/**
* @brief Send GO TO ABSOLUTE POSITION command to epos.
*
* It is a blocking function call.
*
* @returns 0 if success, nonzero otherwise.
*/
int epos_goto_position_abs(HANDLE file, uint8_t nodeid);
/**
* @brief Send GO TO VELOCITY command to epos.
*
* It is a blocking function call.
*
* @returns 0 if success, nonzero otherwise.
*/
int epos_goto_velocity(HANDLE file, uint8_t nodeid);
/**
* @brief Set epos mode of operation.
*
* It is a blocking function call.
*
* @returns 0 if success, nonzero otherwise.
*/
int epos_set_mode(HANDLE file, uint8_t nodeid, epos_mode_t mode);
int epos_set_target_position(HANDLE file, uint8_t nodeid, int32_t val);