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 | /* File: KL2284.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/KL2284.h
* @author Robin Passama
* @brief EtherCAT driver for beckhoff KL2284 module mounted on a BK1150.
* @date February 2020.
* @ingroup ethercatcpp-core
* @example beckhoff_BK1150_KL2284_example.cpp
*/
#pragma once
#include <ethercatcpp/beckhoff_terminals/KL_extensions.h>
/*! \namespace ethercatcpp
*
*/
namespace ethercatcpp {
/** @brief This class describe the driver for a beckhoff KL2284 device
*
* @details KL2284 driver allows to communicate with a beckhoff KL2284 module
* that can be plugged on a BK1150 ethercat slave in order to communicate
* through an EtherCAT bus. The KL2284 is a Hbridge used to control 4 DC motors
* with rotation direction switching.
* @see BK1150
*/
class KL2284 : public KLExtensionCard {
public:
/**
* @brief Constructor of KL2284 class
*/
KL2284();
/**
* @brief Destructor of KL2284 class
*/
~KL2284() = default;
/**
* @brief Copy Constructor of KL2284 class
*/
KL2284(const KL2284&) = default;
/**
* @brief Move Constructor of KL2284 class
*/
KL2284(KL2284&&) = default;
/**
* @brief assignement operator of KL2284 class
*/
KL2284& operator=(const KL2284&) = default;
/**
* @brief Move assignement operator of KL2284 class
*/
KL2284& operator=(KL2284&&) = default;
/**
* @brief Defines internal indexes of controllable motors
*
*/
enum motor_seletion_t {
motor_1 = 0, //!< Motor 1 (A1)
motor_2 = 2, //!< Motor 2 (A2)
motor_3 = 4, //!< Motor 3 (A3)
motor_4 = 6 //!< Motor 4 (A4)
};
/**
* @brief Defines h-bridge state
*
*/
enum motor_rotation_t { direct, reverse, stopped, error };
/**
* @brief Activate a motor in direct or reverse directions
* @details The rotation direction depend on connection on device Ax and Ax'
* not a standardize clokcwise or trigonometric rotation
* @param [in] motor to move (choose in motor_seletion_t)
* @param [in] rotation: rotation direction
*/
void control_motor(motor_seletion_t motor, motor_rotation_t rotation);
/**
* @brief get state of a motor
*
* @param motor index of the motor (from 0 to 4)
* @return motor_rotation_t the direction of rotation for the motor
*/
motor_rotation_t motor_state(motor_seletion_t motor) const;
/**
* @brief Tell whether the module is a digital or non digital module.
* @return always true
*/
bool digital() const final;
protected:
virtual void update_command_buffer();<--- Function in derived class
virtual uint16_t size_out();<--- Function in derived class
private:
// Command variable
uint8_t command_word_;
};
} // namespace ethercatcpp
|