-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.h
148 lines (107 loc) · 3.93 KB
/
config.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
/*
config.h
Copyright (C) 2020 Niryo
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NIRYO_CONFIG_H
#define NIRYO_CONFIG_H
/*
* Firmware version : 1.1.0
*/
#define NIRYO_STEPPER_VERSION_MAJOR 1
#define NIRYO_STEPPER_VERSION_MINOR 1
#define NIRYO_STEPPER_VERSION_PATCH 0
/*
* All constants for Niryo One are defined below
*/
/*
* ----------- A4954 Driver -------------
*/
#define KEEP_RESISTANCE_WHEN_DETACHED 1
//Defines for pins:
#define IN_1 15
#define IN_2 17
#define IN_3 3
#define IN_4 8
#define VREF_1 9
#define VREF_2 4
//for faster digitalWrite:
#define IN_1_HIGH() (REG_PORT_OUTSET1 = PORT_PB08)
#define IN_1_LOW() (REG_PORT_OUTCLR1 = PORT_PB08)
#define IN_2_HIGH() (REG_PORT_OUTSET0 = PORT_PA04)
#define IN_2_LOW() (REG_PORT_OUTCLR0 = PORT_PA04)
#define IN_3_HIGH() (REG_PORT_OUTSET0 = PORT_PA09)
#define IN_3_LOW() (REG_PORT_OUTCLR0 = PORT_PA09)
#define IN_4_HIGH() (REG_PORT_OUTSET0 = PORT_PA06)
#define IN_4_LOW() (REG_PORT_OUTCLR0 = PORT_PA06)
#define ledPin_HIGH() (REG_PORT_OUTSET0 = PORT_PA21)
#define ledPin_LOW() (REG_PORT_OUTCLR0 = PORT_PA21)
#define iMAX 2.0
#define rSense 0.150
#define uMAX 90 //(255/3.3)*(iMAX*10*rSense) // 255 for 8-bit pwm, 1023 for 10 bit, must also edit analogFastWrite
#define UMAX_95_PERCENT (int)(0.95 * uMAX) // 219
#define UMAX_90_PERCENT (int)(0.90 * uMAX) // 207
#define UMAX_85_PERCENT (int)(0.85 * uMAX) // 196
#define UMAX_80_PERCENT (int)(0.80 * uMAX) // 184
#define UMAX_75_PERCENT (int)(0.75 * uMAX) // 173
#define UMAX_70_PERCENT (int)(0.70 * uMAX) // 161
#define UMAX_65_PERCENT (int)(0.65 * uMAX) // 150
#define UMAX_60_PERCENT (int)(0.60 * uMAX) // 138
#define UMAX_55_PERCENT (int)(0.55 * uMAX) // 127
#define UMAX_50_PERCENT (int)(0.50 * uMAX) // 115
#define UMAX_45_PERCENT (int)(0.45 * uMAX) // 103
#define UMAX_40_PERCENT (int)(0.40 * uMAX) // 92
#define UMAX_35_PERCENT (int)(0.35 * uMAX) // 80
#define UMAX_30_PERCENT (int)(0.30 * uMAX) // 69
#define UMAX_25_PERCENT (int)(0.25 * uMAX) // 57
#define UMAX_20_PERCENT (int)(0.20 * uMAX) // 46
#define UMAX_15_PERCENT (int)(0.15 * uMAX) // 34
#define UMAX_10_PERCENT (int)(0.10 * uMAX) // 23
#define UMAX_05_PERCENT (int)(0.05 * uMAX) // 11
#define UMAX_DEFAULT UMAX_25_PERCENT
#define UMAX_PID UMAX_50_PERCENT
#define spr 200
#define aps 360.0/ spr // angle per step
/*
* ----------- CAN bus -------------
*/
#define CAN_BROADCAST_ID 5
#define CAN_CMD_MODE 0x07
#define CAN_CMD_RESET 0x19 // not yet implemented
#define CAN_DATA_CONVEYOR_STATE 0x07
#define CAN_DATA_POSITION 0x03
#define CAN_DATA_DIAGNOSTICS 0x08
#define CAN_DATA_CALIBRATION_RESULT 0x09
#define CAN_DATA_FIRMWARE_VERSION 0x10
// see https://github.com/arduino/ArduinoCore-samd/blob/master/variants/arduino_zero/variant.cpp
#define CAN_PIN_CS 16 // PB09
#define CAN_PIN_INT 38 // PA13
/*
* ----------- Stepper controller -------------
*/
#define STEPPER_CPR 200
#define STEPPER_CONVEYOR_OFF 20
#define STEPPER_CONVEYOR_ON 21
#define CAN_UPDATE_CONVEYOR_ID 23
#define STEPPER_DEFAULT_MICRO_STEPS 8
#define ONE_FULL_STEP 1800
/*
* ----------- Driver temperature sensor -------------
*/
#define TEMPERATURE_SENSOR_PIN A4
/*
* ----------- Fan -------------
*/
#define FAN_PIN 6 // PA20
#define fan_HIGH() (REG_PORT_OUTSET0 = PORT_PA20)
#define fan_LOW() (REG_PORT_OUTCLR0 = PORT_PA20)
#endif