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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231 | /* File: EL3164.h
* This file is part of the program ethercatcpp-core
* Program description : EtherCAT driver libraries for UNIX
* Copyright (C) 2017-2024 - Robin Passama (LIRMM / CNRS) Arnaud Meline
* (LIRMM / CNRS) Benjamin Navarro (LIRMM / CNRS). All Right reserved.
*
* This software is free software: you can redistribute it and/or modify
* it under the terms of the CeCILL-C license as published by
* the CEA CNRS INRIA, either version 1
* of the License, or (at your option) any later version.
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* CeCILL-C License for more details.
*
* You should have received a copy of the CeCILL-C License
* along with this software. If not, it can be found on the official
* website of the CeCILL licenses family (http://www.cecill.info/index.en.html).
*/
/**
* @file beckhoff_terminals/EL3164.h
* @author Robin Passama (maintainer)
* @author Felix Perchreau (original)
* @brief EtherCAT driver for beckhoff EL3164 device.
* @date December 2022
* @ingroup ethercatcpp-core
* @example example_EL3164.cpp
*/
#pragma once
#include <ethercatcpp/slave_device.h>
/*! \namespace ethercatcpp
*
* Root namespace for common and general purpose ethercatcpp packages
*/
namespace ethercatcpp {
/** @brief This class describe the EtherCAT driver for a beckhoff EL3164 device
*
* This driver permit to communicate with a "beckhoff EL3164" through an
* EtherCAT bus. The EL3164 EtherCAT Terminal is an interface for the direct
* connection of 4-channel analog input terminal -10 ... +10 V.
*/
class EL3164 : public SlaveDevice {
public:
/**
* @brief Constructor of EL3164 class
*/
EL3164();
virtual ~EL3164();
//! This enum define open circuit detection pin.
enum channel_id_t {
channel_1, //!< Channel 1
channel_2, //!< Channel 2
channel_3, //!< Channel 3
channel_4 //!< Channel 4
};
/**
* @brief Get value provided by a channel
*
* @param [in] channel desired channel (choose in channel_id_t)
* @return value of specified channel
*/
int channel_value(channel_id_t channel) const;
/**
* @brief Check if value of channel is below measuring range
*
* @param [in] channel desired channel (choose in channel_id_t)
* @return TRUE if available, FALSE otherwise
*/
bool under_range(channel_id_t channel) const;
/**
* @brief Check if value of channel exceeds measuring range
*
* @param [in] channel desired channel (choose in channel_id_t)
* @return TRUE if available, FALSE otherwise
*/
bool over_range(channel_id_t channel) const;
// /**
// * @brief Function used to check Limit 1 monitoring
// *
// * @param [in] channel desired channel (choose in channel_id_t)
// * @return 0: not active, 1: value is smaller than limit value 1, 2: value
// is larger than limit value 1, 3: Value is equal to limit value 1
// */
// int check_Limit_1_Monitoring(channel_id_t channel);
//
// /**
// * @brief Function used to check Limit 2 monitoring
// *
// * @param [in] channel desired channel (choose in channel_id_t)
// * @return 0: not active, 1: value is smaller than limit value 1, 2: value
// is larger than limit value 1, 3: Value is equal to limit value 1
// */
// int check_Limit_2_Monitoring(channel_id_t channel);
// add fct to set limit 1 and 2 value and fct to enable limit 1 and 2 if
// used
/**
* @brief Check if an error is detected (invalid data)
*
* @param [in] channel desired channel (choose in channel_id_t)
* @return TRUE if error notified, FALSE otherwise
*/
bool error(channel_id_t channel) const;
/**
* @brief Check if no new process data was available
*
* @param [in] channel desired channel (choose in channel_id_t)
* @return TRUE if sync error notified, FALSE otherwise
*/
bool sync_error(channel_id_t channel) const;
/**
* @brief Check if channel current value is valud
*
* @param [in] channel desired channel (choose in channel_id_t)
* @return TRUE if valid, FALSE otherwise
*/
bool valid(channel_id_t channel) const;
/**
* @brief Check if channel value has been updated since last call to updated
*
* @param [in] channel desired channel (choose in channel_id_t)
* @return true if updated, FALSE otherwise
*/
bool updated(channel_id_t channel) const;
/**
* @brief Print human raedable state of all available channels
*/
void print_all_channels() const;
private:
void unpack_status_buffer();
int8_t last_updated_;
bool updated_[4];
void check_updated(channel_id_t);
struct data_channel_t {
uint16_t status_word;<--- struct member 'data_channel_t::status_word' is never used.
int16_t data_value;<--- struct member 'data_channel_t::data_value' is never used.
};
// Status variable
data_channel_t channel_1_; // 0x6000
data_channel_t channel_2_; // 0x6010
data_channel_t channel_3_; // 0x6020
data_channel_t channel_4_; // 0x6030
};
} // namespace ethercatcpp
// Unsued Datas
// bool enable_Limit_1(channel_id_t channel, bool state);
// bool enable_Limit_2(channel_id_t channel, bool state);
// //PDO config for 1 channel, Index 8010 for channel 2, Index 8020 for channel
// 3, Index 8030 for channel 4
//
// Index: 8000 Datatype: 0000 Objectcode: 09 Name: AI Settings
// Sub: 00 Datatype: 0005 Bitlength: 0008 Obj.access: 0007 Name:
// SubIndex 000
// Value :0x18 24
// Sub: 01 Datatype: 0001 Bitlength: 0001 Obj.access: 033f Name:
// Enable user scale
// Value :FALSE
// Sub: 02 Datatype: 0800 Bitlength: 0003 Obj.access: 033f Name:
// Presentation
// Value :Unknown type
// Sub: 05 Datatype: 0001 Bitlength: 0001 Obj.access: 033f Name:
// Siemens bits
// Value :FALSE
// Sub: 06 Datatype: 0001 Bitlength: 0001 Obj.access: 033f Name:
// Enable filter
// Value :FALSE
// Sub: 07 Datatype: 0001 Bitlength: 0001 Obj.access: 033f Name:
// Enable limit 1
// Value :FALSE
// Sub: 08 Datatype: 0001 Bitlength: 0001 Obj.access: 033f Name:
// Enable limit 2
// Value :FALSE
// Sub: 0a Datatype: 0001 Bitlength: 0001 Obj.access: 033f Name:
// Enable user calibration
// Value :FALSE
// Sub: 0b Datatype: 0001 Bitlength: 0001 Obj.access: 033f Name:
// Enable vendor calibration
// Value :TRUE
// Sub: 0e Datatype: 0001 Bitlength: 0001 Obj.access: 033f Name: Swap
// limit bits
// Value :FALSE
// Sub: 11 Datatype: 0003 Bitlength: 0010 Obj.access: 033f Name: User
// scale offset
// Value :0x0000 0
// Sub: 12 Datatype: 0004 Bitlength: 0020 Obj.access: 033f Name: User
// scale gain
// Value :0x00010000 65536
// Sub: 13 Datatype: 0003 Bitlength: 0010 Obj.access: 033f Name: Limit
// 1
// Value :0x0000 0
// Sub: 14 Datatype: 0003 Bitlength: 0010 Obj.access: 033f Name: Limit
// 2
// Value :0x0000 0
// Sub: 15 Datatype: 0801 Bitlength: 0010 Obj.access: 033f Name:
// Filter settings
// Value :Unknown type
// Sub: 17 Datatype: 0003 Bitlength: 0010 Obj.access: 033f Name: User
// calibration offset
// Value :0x0000 0
// Sub: 18 Datatype: 0003 Bitlength: 0010 Obj.access: 033f Name: User
// calibration gain
// Value :0x4000 16384
//
//
// Index: 800f Datatype: 0000 Objectcode: 09 Name: AI Vendor data
// Sub: 00 Datatype: 0005 Bitlength: 0008 Obj.access: 0007 Name:
// SubIndex 000
// Value :0x02 2
// Sub: 01 Datatype: 0003 Bitlength: 0010 Obj.access: 003f Name:
// Calibration offset
// Value :0xfffffffb -5
// Sub: 02 Datatype: 0003 Bitlength: 0010 Obj.access: 003f Name:
// Calibration gain
|