Librairie pour contrôler un moteur connecté à un contrôleur SDC21XX
Dependencies: CANopen_Node Roboteq_SDC_serie
Dependents: TCP_Server_Example
Fork of SDC21XX_Motor by
SDC21XX_Motor.cpp@0:1c0bc44980e0, 2016-06-01 (annotated)
- Committer:
- kkoichy
- Date:
- Wed Jun 01 15:03:34 2016 +0000
- Revision:
- 0:1c0bc44980e0
- Child:
- 1:a677037eca0a
V1.0; Created class and basic methods to controll a motor connected to a SDC21XX motor driver
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kkoichy | 0:1c0bc44980e0 | 1 | #include "SDC21XX_Motor.h" |
kkoichy | 0:1c0bc44980e0 | 2 | |
kkoichy | 0:1c0bc44980e0 | 3 | |
kkoichy | 0:1c0bc44980e0 | 4 | namespace mbed { |
kkoichy | 0:1c0bc44980e0 | 5 | |
kkoichy | 0:1c0bc44980e0 | 6 | SDC21XX_Motor::SDC21XX_Motor(uint8_t _node_id, CAN * _can, uint8_t _channel, uint32_t _reductor): channel(_channel), reductor(_reductor), RB(_node_id, _can) |
kkoichy | 0:1c0bc44980e0 | 7 | { |
kkoichy | 0:1c0bc44980e0 | 8 | |
kkoichy | 0:1c0bc44980e0 | 9 | } |
kkoichy | 0:1c0bc44980e0 | 10 | void SDC21XX_Motor::GoAngle(int16_t _angle) |
kkoichy | 0:1c0bc44980e0 | 11 | { |
kkoichy | 0:1c0bc44980e0 | 12 | RB.SetPosition(_angle*1024/360*reductor, channel); |
kkoichy | 0:1c0bc44980e0 | 13 | } |
kkoichy | 0:1c0bc44980e0 | 14 | |
kkoichy | 0:1c0bc44980e0 | 15 | int16_t SDC21XX_Motor::GetAngle() |
kkoichy | 0:1c0bc44980e0 | 16 | { |
kkoichy | 0:1c0bc44980e0 | 17 | return RB.ReadAbsoluteEncoderCount(channel); |
kkoichy | 0:1c0bc44980e0 | 18 | } |
kkoichy | 0:1c0bc44980e0 | 19 | |
kkoichy | 0:1c0bc44980e0 | 20 | void SDC21XX_Motor::SetChannel(uint8_t _channel) |
kkoichy | 0:1c0bc44980e0 | 21 | { |
kkoichy | 0:1c0bc44980e0 | 22 | channel = _channel; |
kkoichy | 0:1c0bc44980e0 | 23 | } |
kkoichy | 0:1c0bc44980e0 | 24 | |
kkoichy | 0:1c0bc44980e0 | 25 | uint8_t SDC21XX_Motor::GetChannel(void) |
kkoichy | 0:1c0bc44980e0 | 26 | { |
kkoichy | 0:1c0bc44980e0 | 27 | return channel; |
kkoichy | 0:1c0bc44980e0 | 28 | } |
kkoichy | 0:1c0bc44980e0 | 29 | |
kkoichy | 0:1c0bc44980e0 | 30 | void SDC21XX_Motor::SetReductor(uint32_t _reductor) |
kkoichy | 0:1c0bc44980e0 | 31 | { |
kkoichy | 0:1c0bc44980e0 | 32 | reductor = _reductor; |
kkoichy | 0:1c0bc44980e0 | 33 | } |
kkoichy | 0:1c0bc44980e0 | 34 | |
kkoichy | 0:1c0bc44980e0 | 35 | uint32_t SDC21XX_Motor::GetReductor(void) |
kkoichy | 0:1c0bc44980e0 | 36 | { |
kkoichy | 0:1c0bc44980e0 | 37 | return reductor; |
kkoichy | 0:1c0bc44980e0 | 38 | } |
kkoichy | 0:1c0bc44980e0 | 39 | |
kkoichy | 0:1c0bc44980e0 | 40 | void SDC21XX_Motor::SetNodeID(uint8_t _node_id) |
kkoichy | 0:1c0bc44980e0 | 41 | { |
kkoichy | 0:1c0bc44980e0 | 42 | RB.SetNodeID(_node_id); |
kkoichy | 0:1c0bc44980e0 | 43 | } |
kkoichy | 0:1c0bc44980e0 | 44 | |
kkoichy | 0:1c0bc44980e0 | 45 | uint8_t SDC21XX_Motor::GetNodeID(void) |
kkoichy | 0:1c0bc44980e0 | 46 | { |
kkoichy | 0:1c0bc44980e0 | 47 | return RB.GetNodeID(); |
kkoichy | 0:1c0bc44980e0 | 48 | } |
kkoichy | 0:1c0bc44980e0 | 49 | |
kkoichy | 0:1c0bc44980e0 | 50 | void SDC21XX_Motor::SetCan(CAN * _can) |
kkoichy | 0:1c0bc44980e0 | 51 | { |
kkoichy | 0:1c0bc44980e0 | 52 | RB.SetCan(_can); |
kkoichy | 0:1c0bc44980e0 | 53 | } |
kkoichy | 0:1c0bc44980e0 | 54 | |
kkoichy | 0:1c0bc44980e0 | 55 | CAN* SDC21XX_Motor::GetCan(void) |
kkoichy | 0:1c0bc44980e0 | 56 | { |
kkoichy | 0:1c0bc44980e0 | 57 | return RB.GetCan(); |
kkoichy | 0:1c0bc44980e0 | 58 | } |
kkoichy | 0:1c0bc44980e0 | 59 | |
kkoichy | 0:1c0bc44980e0 | 60 | |
kkoichy | 0:1c0bc44980e0 | 61 | }//end namespace |