From: Martin Prudek Date: Sun, 10 May 2015 10:55:21 +0000 (+0200) Subject: Added detection os index signal lost. X-Git-Url: https://rtime.felk.cvut.cz/gitweb/fpga/rpi-motor-control.git/commitdiff_plain/067296cf27a01a3cb766e31c44d313707964d9c3 Added detection os index signal lost. --- diff --git a/pmsm-control/test_sw/main_pmsm.c b/pmsm-control/test_sw/main_pmsm.c index 12f236d..6e539b2 100644 --- a/pmsm-control/test_sw/main_pmsm.c +++ b/pmsm-control/test_sw/main_pmsm.c @@ -413,32 +413,52 @@ void comIndDist(){ uint16_t dist; uint16_t index = data.index_position; - if (index<2048){ - if (pos */ + if (pos */ /*proti smeru h.r. od indexu*/ dist=pos+2000-index; - }else if (pos<=index+2048){ + }else if (pos<=index+1999){ /*pozice e */ /*po smeru h.r. od indexu*/ dist=pos-index; - }else{ + }else if (pos */ + goto index_lost; + }else{ /*pozice e */ /*proti smeru h.r. od indexu - podtecena pozice*/ dist=pos-index-2096; } - }else{ - if (pos*/ + if (pos */ + goto index_lost; + }else if (pos */ + /*proti smeru h.r. od indexu*/ + dist=pos+2000-index; + }else if (pos<=index+1999){ /*pozice e */ + /*po smeru h.r. od indexu*/ + dist=pos-index; + }else { /*pozice e */ + goto index_lost; + } + }else{ /*index e<2097,4095> */ + if (pos<=index-2097){ /*pozice e<0,index-2097> */ /*po smeru h.r. od indexu - pretecena pozice*/ dist=4096+pos-index; - }else if (pos */ + goto index_lost; + }else if (pos */ /*proti smeru h.r. od indexu*/ dist=pos+2000-index; - }else{ + }else{ /*pozice e */ /*po smeru h.r. od indexu*/ dist=pos-index; } - } + rps.index_dist = dist; return; + + index_lost: + rps.index_ok=0; + return; } /* * \brief