Loging process modified. Now logging time, position, 3xpwm.
authorMartin Prudek <prudemar@fel.cvut.cz>
Sat, 16 May 2015 20:30:34 +0000 (22:30 +0200)
committerMartin Prudek <prudemar@fel.cvut.cz>
Sat, 16 May 2015 20:30:34 +0000 (22:30 +0200)
pmsm-control/test_sw/cmd_proc.c
pmsm-control/test_sw/main_pmsm.c
pmsm-control/test_sw/pmsm_state.h

index a0b0592..953567e 100644 (file)
@@ -8,6 +8,7 @@
 #define PRUM_SOUC      6183
 
 static char doPrint = 1;
+static char error = 0;
 
 /*
  * \brief
@@ -135,7 +136,13 @@ static void logInit(struct rpi_state* state){
        state->log_col_count=LOG_DEF_COL;
        for (r=0;r<LOG_ROWS;r++){
                state->logs[r]=malloc(state->log_col_count*sizeof(int));
+               if (state->logs[r]==NULL){
+                       error=1;
+                       state->log_col_count=-1;
+                       return;
+               }
        }
+       state->doLogs=1;
 }
 
 /*
@@ -182,7 +189,6 @@ static void setLogSEM(struct rpi_state* state){
        /* spustim zachytavani logu */
        }else{
                logInit(state);
-               state->doLogs=1;
                sem_post(&state->thd_par_sem);
        }
 }
@@ -290,4 +296,7 @@ void printData(struct rpi_state* state){
        printf("duty=%d\n",s.duty);
        if (s.index_ok) printf("index ok\n");
        if (s.commutate) printf("commutation in progress\n");
+       if (s.doLogs) printf("logujeme\n");
+       if (error) printf("error pri maloc logs!! \n");
+
 }
index bd676e4..65df8f1 100644 (file)
@@ -126,16 +126,24 @@ void makeLog(){
        }
        rps.logs[0][rps.log_col]=(int)rps.tf_count;
        rps.logs[1][rps.log_col]=(int)rps.spi_dat->pozice;
+       rps.logs[2][rps.log_col]=(int)rps.pwm1;
+       rps.logs[3][rps.log_col]=(int)rps.pwm2;
+       rps.logs[4][rps.log_col]=(int)rps.pwm3;
 
        rps.log_col++;
-
+     /*
         if (rps.log_col==rps.log_col_count-1){
                rps.log_col_count*=2;
                rps.log_col_count%=MAX_LOGS;
                for (r=0;r<LOG_ROWS;r++){
                        rps.logs[r]=realloc(rps.logs[r],rps.log_col_count*sizeof(int));
+                       if (rps.logs[r]==NULL){
+                               rps.doLogs=0;
+                               rps.error=1;
+                       }
                }
         }
+     */
 }
 
 /*
index a148e1c..d645791 100644 (file)
@@ -8,10 +8,10 @@
 #define MAX_DUTY       170
 #define MAX_SPEED      (7*OLD_POS_NUM)
 
-#define LOG_ROWS       2
-#define LOG_DEF_COL    500
+#define LOG_ROWS       5
+#define LOG_DEF_COL    1000
 #define MAX_LOGS       1000
-#define LOG_PERIOD     10
+#define LOG_PERIOD     5
 
 struct rpi_in;