forked from EGG-electric-unicycle/firmware-gen2_boards
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.h
executable file
·57 lines (46 loc) · 1.32 KB
/
main.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
/*
* EGG Electric Unicycle firmware
*
* Copyright (C) Casainho, 2015, 2106.
*
* Released under the GPL License, Version 3
*/
#ifndef _MAIN_H_
#define _MAIN_H_
// Define for the NVIC IRQChannel Preemption Priority
// lower number has higher priority
#define ADC_ANALOG_WATCHDOG_PRIORITY 0
#define HALL_SENSORS_PRIORITY 1
#define TIM2_PRIORITY 2
// State machine
#define COAST 0
#define RUNNING 1
#define OVER_MAX_CURRENT 2
#define OVER_CURRENT 3
// Battery voltage
// voltage measured values:
// 20V | 0.75V
// 30V | 1.12V
// 40V | 1.50V
// 50V | 1.88V
// 60V | 2.25V
// about 38mv for each 1V
// Phase current
// Voltage measured values:
// 4.7A | 1.77V
// 2.8A | 1.74V
// 0A | 1.71V
// -2.8A | 1.68V
// -4.7A | 1.65V
// about 12.7mv for each 1A
#define K_ADC_VOLTAGE 161 // amplified 100k
// Motor
#define MOTOR_MAX_CURRENT 1 // Define max motor current (used on adc.c)
#define MOTOR_MAX_SPEED 20000 // meter per hour
//#define MOTOR_MIN_SPEED 5000 // meter per hour -- walking speed is 5km/h
#define MOTOR_MIN_SPEED 0 // meter per hour -- walking speed is 5km/h
#define MOTOR_SPEED_CONVERSION 0.5574 // convert hall sensor signal period (each 10us) to motor speed
extern unsigned int machine_state;
void delay_ms (unsigned int ms);
void printDouble(double v, int decimalDigits);
#endif /* _MAIN_H_ */