mirror of
https://github.com/rene-dev/stmbl.git
synced 2024-12-24 01:22:16 +00:00
wire saving
This commit is contained in:
parent
5ca9075f2f
commit
7ad0175e31
6
conf/template/en.txt
Normal file
6
conf/template/en.txt
Normal file
@ -0,0 +1,6 @@
|
||||
load en
|
||||
en0.rt_prio = 2
|
||||
en0.en_in = 1
|
||||
fault0.en = en0.en_out0
|
||||
en0.fault = fault0.fault
|
||||
en0.time = 1
|
4
conf/template/encws_fb0.txt
Normal file
4
conf/template/encws_fb0.txt
Normal file
@ -0,0 +1,4 @@
|
||||
link enc_fb0
|
||||
link uvw_fb0
|
||||
uvw0.mode = 1
|
||||
enc_fb0.en_index = 0
|
14
conf/template/uvw_fb0.txt
Normal file
14
conf/template/uvw_fb0.txt
Normal file
@ -0,0 +1,14 @@
|
||||
load uvw
|
||||
uvw0.rt_prio = 3
|
||||
uvw0.u = io0.fb0a
|
||||
uvw0.v = io0.fb0b
|
||||
uvw0.w = io0.fb0z
|
||||
|
||||
uvw0.amp = adc0.amp0
|
||||
|
||||
fb_switch0.com_pos = uvw0.pos
|
||||
fb_switch0.com_abs_pos = uvw0.pos
|
||||
fb_switch0.com_state = uvw0.state
|
||||
fb_switch0.com_polecount = conf0.com_fb_polecount
|
||||
conf0.com_fb_polecount = conf0.polecount
|
||||
fault0.com_fb_error = uvw0.error
|
@ -45,7 +45,7 @@ static void nrt_init(void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
PIN(p5) = 5; //u + w = -1.047198
|
||||
PIN(p6) = 3; //v + w = -3.141593
|
||||
PIN(p7) = -1; //fault
|
||||
PIN(en_time) = 0.02;
|
||||
PIN(en_time) = 0.01;
|
||||
}
|
||||
|
||||
static void rt_func(float period, void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
@ -65,7 +65,7 @@ static void rt_func(float period, void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
t[6] = PIN(p6);
|
||||
t[7] = PIN(p7);
|
||||
PIN(rpos) = rpos;
|
||||
if(rpos < 0 | PIN(amp) < 0.5){
|
||||
if(PIN(amp) < 0.75){
|
||||
PIN(error) = 1.0;
|
||||
PIN(state) = 0.0;
|
||||
PIN(timer) = 0.0;
|
||||
@ -73,20 +73,24 @@ static void rt_func(float period, void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
else{
|
||||
switch((int) PIN(mode)){
|
||||
case 0:
|
||||
PIN(state) = 3.0;
|
||||
PIN(error) = 0.0;
|
||||
PIN(pos) = mod((float)t[rpos] / 6.0 * 2.0 * M_PI);
|
||||
if(t[rpos] < 0.0){
|
||||
PIN(state) = 3.0;
|
||||
PIN(error) = 0.0;
|
||||
PIN(pos) = mod((float)t[rpos] / 6.0 * 2.0 * M_PI);
|
||||
}
|
||||
else{
|
||||
PIN(error) = 1.0;
|
||||
PIN(state) = 0.0;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if(PIN(timer) < PIN(en_time) / 2.0){
|
||||
PIN(pos) = mod((float)t[rpos] / 6.0 * 2.0 * M_PI);
|
||||
}
|
||||
if(PIN(timer) > PIN(en_time)){
|
||||
PIN(state) = 2.0;
|
||||
PIN(error) = 0.0;
|
||||
PIN(timer) += period;
|
||||
}
|
||||
else{
|
||||
PIN(timer) += period;
|
||||
PIN(state) = 2.0;
|
||||
PIN(error) = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ static void rt_func(float period, void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
PIN(cos0l) = co0[ADC_GROUPS - 1];
|
||||
PIN(sin0) = sin0all / (float)ADC_GROUPS;
|
||||
PIN(cos0) = cos0all / (float)ADC_GROUPS;
|
||||
PIN(amp0) = PIN(amp0) * 0.99 + sqrtf(s * s + c * c) * 0.01;
|
||||
PIN(amp0) = PIN(amp0) * 0.9 + sqrtf(s * s + c * c) * 0.1;
|
||||
#ifdef FB1
|
||||
s = V_DIFF(ADC_DMA_Buffer[ADC_OVER_FB0] & 0x0000ffff, 1);
|
||||
c = V_DIFF(ADC_DMA_Buffer[ADC_OVER_FB0] >> 16, 1);
|
||||
@ -151,7 +151,7 @@ static void rt_func(float period, void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
PIN(cos1l) = co1[ADC_GROUPS - 1];
|
||||
PIN(sin1) = sin1all / (float)ADC_GROUPS;
|
||||
PIN(cos1) = cos1all / (float)ADC_GROUPS;
|
||||
PIN(amp1) = PIN(amp1) * 0.99 + sqrtf(s * s + c * c) * 0.01;
|
||||
PIN(amp1) = PIN(amp1) * 0.9 + sqrtf(s * s + c * c) * 0.1;
|
||||
#endif
|
||||
|
||||
// if(PIN(res_en) > 0.0) {
|
||||
|
Loading…
Reference in New Issue
Block a user