]> rtime.felk.cvut.cz Git - fpga/rpi-motor-control.git/blob - pmsm-control/test_sw/pmsm_state.h
Speed regulation with zero error.
[fpga/rpi-motor-control.git] / pmsm-control / test_sw / pmsm_state.h
1 #ifndef PMSM_STATE
2 #define PMSM_STATE
3
4 #include <stdint.h>
5 #include <semaphore.h>
6
7 #define OLD_POS_NUM     50
8 #define MAX_DUTY        170
9 #define MAX_SPEED       (7*OLD_POS_NUM)
10
11 struct rpi_in;
12
13 struct rpi_state{
14         struct rpi_in* spi_dat;         /* spi data */
15         sem_t thd_par_sem;              /* data metual exlusion access */
16         uint8_t test;                   /* configuratin byte - pwm enabl. bits etc. */
17         uint32_t tf_count;              /* number of transfer*/
18
19         uint16_t index_dist;            /* distance to index position */
20         unsigned char index_ok;         /* we have actual index position */
21
22         uint16_t pwm1, pwm2, pwm3;      /* pwm duty cycles*/
23         uint16_t t_pwm1, t_pwm2, t_pwm3;/* debug*/
24
25         int duty;                       /* duty cycle of pwm */
26         int desired_pos;                /* desired position */
27         int old_pos[OLD_POS_NUM];       /* old  positions */
28         int desired_spd;                /* desired speed */
29         int speed;
30
31         char commutate;                 /* zapina prepocet duty na jednotlive pwm */
32         char pos_reg_ena;               /* position regulation enable */
33         char spd_reg_ena;               /* speed rugulation enable */
34
35         int spd_err_sum;                /* for speed pid regulator */
36 };
37
38 #endif /*PMSM_STATE*/