Hello,
until now i use some code like the following one to read 6 PWM-Signals in an array to work with them:
 
#include "mbed.h"
#include "PwmIn.h"
...
PwmIn K1_Sig_In (p5);
PwmIn K2_Sig_In (p6);
PwmIn K3_Sig_In (p7);
PwmIn K4_Sig_In (p8); 
PwmIn K5_Sig_In (p9);
PwmIn K6_Sig_In (p10); 
...
main(){
...
   Signal_input[0] = K1_Sig_In.pulsewidth();
   Signal_input[1] = K2_Sig_In.pulsewidth();
   Signal_input[2] = K3_Sig_In.pulsewidth();
   Signal_input[3] = K4_Sig_In.pulsewidth();
   Signal_input[4] = K5_Sig_In.pulsewidth();
   Signal_input[5] = K6_Sig_In.pulsewidth();
   ...
   for (int z = 0; z < 6; z++) {
      if (Signal_input[z] < Signal_input_alt[z] - Aenderungsgrenze) Signal_input[z] = Signal_input_alt[z] - Aenderungsgrenze;
      if (Signal_input[z] > Signal_input_alt[z] + Aenderungsgrenze) Signal_input[z] = Signal_input_alt[z] + Aenderungsgrenze;
      ...
   }
...
}
My quastion is how could i do something like this:
 
...
main(){
...
   for (int z = 0; z < 6; z++) {
      Signal_input[z] = K[z]_Sig_In.pulsewidth();
                          ^
                          |
   //*****                This part is my problem ;-)
      if (Signal_input[z] < Signal_input_alt[z] - Aenderungsgrenze) Signal_input[z] = Signal_input_alt[z] - Aenderungsgrenze;
      if (Signal_input[z] > Signal_input_alt[z] + Aenderungsgrenze) Signal_input[z] = Signal_input_alt[z] + Aenderungsgrenze;
      ...
   }
...
}
Of course there is much more code inclusive definitions (all marked with these "...") of the variables and so on in my program, but this is the relevant part of it i think.
Knows anyone a way to do something like this? It is not very important, program works also in my way, but it looks nicer i think... ;-)
Thanks and with best reguards,
Steff
                    
                 
                
             
        
Hello,
until now i use some code like the following one to read 6 PWM-Signals in an array to work with them:
#include "mbed.h" #include "PwmIn.h" ... PwmIn K1_Sig_In (p5); PwmIn K2_Sig_In (p6); PwmIn K3_Sig_In (p7); PwmIn K4_Sig_In (p8); PwmIn K5_Sig_In (p9); PwmIn K6_Sig_In (p10); ... main(){ ... Signal_input[0] = K1_Sig_In.pulsewidth(); Signal_input[1] = K2_Sig_In.pulsewidth(); Signal_input[2] = K3_Sig_In.pulsewidth(); Signal_input[3] = K4_Sig_In.pulsewidth(); Signal_input[4] = K5_Sig_In.pulsewidth(); Signal_input[5] = K6_Sig_In.pulsewidth(); ... for (int z = 0; z < 6; z++) { if (Signal_input[z] < Signal_input_alt[z] - Aenderungsgrenze) Signal_input[z] = Signal_input_alt[z] - Aenderungsgrenze; if (Signal_input[z] > Signal_input_alt[z] + Aenderungsgrenze) Signal_input[z] = Signal_input_alt[z] + Aenderungsgrenze; ... } ... }My quastion is how could i do something like this:
... main(){ ... for (int z = 0; z < 6; z++) { Signal_input[z] = K[z]_Sig_In.pulsewidth(); ^ | //***** This part is my problem ;-) if (Signal_input[z] < Signal_input_alt[z] - Aenderungsgrenze) Signal_input[z] = Signal_input_alt[z] - Aenderungsgrenze; if (Signal_input[z] > Signal_input_alt[z] + Aenderungsgrenze) Signal_input[z] = Signal_input_alt[z] + Aenderungsgrenze; ... } ... }Of course there is much more code inclusive definitions (all marked with these "...") of the variables and so on in my program, but this is the relevant part of it i think.
Knows anyone a way to do something like this? It is not very important, program works also in my way, but it looks nicer i think... ;-)
Thanks and with best reguards, Steff