forked from kalnajslab/MCB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReel.h
133 lines (118 loc) · 3.64 KB
/
Reel.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
/*
* Reel.h
* Definition of a class to control the reel
* Author: Alex St. Clair
* January 2018
*
* This file defines an Arduino library (C++ class) that controls
* the reel. It inherits from the Technosoft class, which implements
* communication with the Technosoft motor controllers.
*
* Units:
* - Revolutions: rot
* - Speed: rpm
* - Acc: rot/s^2
*/
#ifndef REEL_H
#define REEL_H
#include "Arduino.h"
#include "HardwareSerial.h"
#include "WProgram.h"
#include "Technosoft.h"
#include "TML_Instructions_Addresses.h"
#include "StorageManagerMCB.h"
#include <stdint.h>
// general info
#define REEL_AXIS 1
#define MAX_REVOLUTIONS 8000.0 // rot
// conversion factors that depend on the instrument
#ifdef INST_RACHUTS // defined in HardwareMCB.h
#define REEL_UNITS_PER_REV 24000.0
#define SPEED_CONVERSION 0.32
#define DEFAULT_FULL_SPEED 250.0 // rpm
#define DEFAULT_DOCK_SPEED 80.0 // rpm
#define ACC_CONVERSION 0.01537
#define DEFAULT_ACC 8.0 // rot/s^2
#define MAX_ACC 8.2 // rot/s^2
#define MAX_SPEED 400.0 // rpm
#endif
#ifdef INST_FLOATS // defined in HardwareMCB.h
#define REEL_UNITS_PER_REV 344.0
#define SPEED_CONVERSION 0.00459 // iu/rpm
#define DEFAULT_FULL_SPEED 20.0 // rpm
#define DEFAULT_DOCK_SPEED 20.0 // rpm
#define ACC_CONVERSION 0.00022
#define DEFAULT_ACC 80 // rot/s^2
#define MAX_ACC 82 // rot/s^2
#define MAX_SPEED 100.0 // rpm
#endif
// Technosoft function addresses
// MCB-SOLO ebox configuration for Flight_System_V6_EmCamVariable
//#ifdef INST_RACHUTS // defined in HardwareMCB.h
//#define STOP_PROFILE_R 0x402C
//#define REEL_VARIABLE_R 0x4031
//#define CAM_SETUP_R 0x4043
//#define CAM_STOP_R 0x4051
//#define BRAKE_ON_R 0x4057
//#define BRAKE_OFF_R 0x405C
//#endif
// From RACHuTS_v6_EmCamVariable_Mondo
#ifdef INST_RACHUTS // defined in HardwareMCB.h
#define STOP_PROFILE_R 0x403E
#define REEL_VARIABLE_R 0x402C
#define CAM_SETUP_R 0x4049
#define CAM_STOP_R 0x4043
#define BRAKE_ON_R 0x404F
#define BRAKE_OFF_R 0x4054
#endif
//Below are the addresses in the code from Dougs Git
// #ifdef INST_RACHUTS // defined in HardwareMCB.h
// #define STOP_PROFILE_R 0x403E
// #define REEL_VARIABLE_R 0x402C
// #define CAM_SETUP_R 0x4049
// #define CAM_STOP_R 0x4043
// #define BRAKE_ON_R 0x4057
// #define BRAKE_OFF_R 0x405C
// #endif
///old ebox configuration FLOATS_Sey
//#ifdef INST_FLOATS // defined in HardwareMCB.h
//#define STOP_PROFILE_R 0x4026
//#define REEL_VARIABLE_R 0x402B
//#define CAM_SETUP_R 0x4046
//#define CAM_STOP_R 0x4054
//#define BRAKE_ON_R 0x405A
//#define BRAKE_OFF_R 0x405F
//#endif
#ifdef INST_FLOATS // defined in HardwareMCB.h
#define STOP_PROFILE_R 0x403F
#define REEL_VARIABLE_R 0x4024
#define CAM_SETUP_R 0x404A
#define CAM_STOP_R 0x4044
#define BRAKE_ON_R 0x4058
#define BRAKE_OFF_R 0x405D
#endif
// Position logging in case of power cycle
#define POS_LOG_FILE FSW_DIR "pos_log.dat"
class Reel : public Technosoft {
public:
Reel(uint8_t expeditor_axis);
bool SetPosition(float new_pos);
bool SetPosition(int32_t new_pos);
bool UpdatePosition();
bool UpdateSpeed();
void SetToStoredPosition();
bool StopProfile();
bool ReelIn(float num_revolutions, float speed, float acc);
bool ReelOut(float num_revolutions, float speed, float acc);
bool CamSetup();
bool CamStop();
bool BrakeOn();
bool BrakeOff();
void EmergencyStop();
void RemoveEmergencyStop();
int32_t absolute_position; // in encoder units (24000 per rotation)
float speed;
private:
StorageManagerMCB storageManager; // supports multiple objects
};
#endif