The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
[7820 FW]Custom Bode APP doesn't work anymore on emulator ? ["1/2 SOLVED"]
05-14-2015, 11:16 AM (This post was last modified: 05-14-2015 03:00 PM by dg1969.)
Post: #1
[7820 FW]Custom Bode APP doesn't work anymore on emulator ? ["1/2 SOLVED"]
edit with some comments on the code and the attachment file first forgot...
---
Hi,

Few time ago I wrote an basic custom App for BODE plot based on FUNCTION APP... On the physical prime [FW7820] no problem, everything works like before. But on the new emulator ( new FW 7820 ) the plot view seem to be dead, unresponsive... I can't use these app on emulator...

If someone have an idea... and time to look at...

I know my code is perhaps not readable (french language inside I know is not a good idea for worldwide exchange :o).

Usage is very basic: Place your transfert function (in term of X) in symb view. Transfer functions must be write without float numbers. F1(X)=1/(1+0.2*X) doesn't works... but F1(X)=1/(1+1/2*X)^2 is ok...

In SYMB view you can place 1 to 10 transfer functions in term of 'X', example:
Code:

Code:
F1(X)=(1+2*X)/(1+2*X+1/10*X^2)^2*e^(-2*X)

Actually the exponential term must be at the end of the expression (see the example above) not very powerful but it do the job to model a pure delay.

Then press PLOT to choose step response (here occur the problem on emulator) , Bode module or Bode phase (x axis is in term of LOG10(pulsation)) . There is no automatic scale.

You have to escape from plot view (pressing num or symb again) if you want to choose another plot...


If you find some time I would like to learn and improve my practice through constructive criticism ... Thanks ;o)

In attach file you will find the binary version of the app...
here is the code:
Code:

copie_les_fonctions(); //copy transfert func from SYMB view to liste_fonctions
replace_les_fonctions(); //copy transfert func from liste_fonctions to SYMB view
place_les_modules(); //copy magnitude expressions from liste_modules to SYMB
place_les_phases(); //copy phase expressions from liste_phases to SYMB
place_les_rep_temp(); //copy step resp expressions from liste_rep_temp to SYMB
calcule_modules(); // expressions magnitudes calculation
calcule_phases(); // calc phases expressions
calcule_rep_temp(); // calc step response expressions
Symb();

export liste_fonctions:=MAKELIST(0,X,1,10); //copy of transfert func
export liste_modules:={}; // magnitude expr when calculated are there
export liste_phases:={}; // phase expr are save here
export liste_rep_temp:={}; // step resp expr are here
recalc_module:=MAKELIST(1,X,1,10); // flag are set to 1 if recompute is need for magnitude
recalc_phase:=MAKELIST(1,X,1,10); // flag if phase recompute
recalc_temp:=MAKELIST(1,X,1,10); // flag if step resp need to be recompute
modif:=0; // if the user come on symb view these flag tell that some modifications may occur on transfert expr

copie_les_fonctions()
begin
  local k;
  for k from 1 to 10 do
    if ISCHECK(k MOD 10) then
      if EVAL(EXPR("F"+k MOD 10)≠liste_fonctions(k)) then
        IFERR liste_fonctions(k):=EXPR("F"+k MOD 10) then MSGBOX("Erreur de copie sur F"+k MOD 10) end;
        recalc_module(k):=1;
        recalc_phase(k):=1;
        recalc_temp(k):=1; 
      end; 
    end;
  end;
  modif:=0;
end;

replace_les_fonctions()
begin
  local k;
  for k from 1 to length(liste_fonctions) do
    if ISCHECK(k MOD 10) then  
      expr("F"+k MOD 10+":=liste_fonctions("+k+")");
    end;
  end;
end;

place_les_modules()
begin
  local k;
  for k from 1 to length(liste_modules) do
     if ISCHECK(k MOD 10) then 
       expr("F"+k MOD 10+":=liste_modules("+k+")");
     end;
  end;
end;

place_les_phases()
begin
  local k;
  for k from 1 to length(liste_phases) do
     if ISCHECK(k MOD 10) then
       expr("F"+k MOD 10+":=liste_phases("+k+")");
     end;
  end;
end;

place_les_rep_temp()
begin
  local k;
  for k from 1 to length(liste_rep_temp) do
     if ISCHECK(k MOD 10) then
       expr("F"+k MOD 10+":=liste_rep_temp("+k+")");
     end;
  end;
end;

calcule_modules()
begin
  local k;
    for k from 1 to length(liste_fonctions) do
       if ISCHECK(k MOD 10) AND recalc_module(k) then
         liste_modules(k):=20*LOG(ABS(subst(liste_fonctions(k),'X','i*ALOG(X)')));
         recalc_module(k):=0; 
       end;
    end;
end;

calcule_phases()
BEGIN
local k,j,r,retard;
local f, a,num,denomi,cnum,cdenom,phi;
  for k from 1 to length(liste_fonctions) do
     if ISCHECK(k MOD 10) AND recalc_phase(k) then
       f:=replace(string(liste_fonctions(k)),"X","x");
       r:=instring(f,"e");
       if r then
                retard:=right(f,size(f)-1-r);
                f:=left(f,r-2);
       end;       
       a:=CAS.froot(f,"x");
       num:=string(CAS.numer(f));
       denomi:=string(CAS.denom(f));
       cnum:=CAS.lcoeff(num,"x");
       cdenom:=CAS.lcoeff(denomi,"x");
       phi:=string(ARG(cnum/cdenom)); 
       FOR j FROM 1 TO length(a) STEP 2 DO
           IF RE(a(j))<>0 THEN 
                phi:=phi+"+"+a(j+1)+"*ATAN(("+IM(a(j))+"-X)/("+RE(a(j))+"))";
           ELSE IF a(j)==0 THEN
                    phi:=phi+"+"+a(j+1)+"*90";
                ELSE phi:=phi+"+"+a(j+1)+"*90*SIGN(X-"+IM(a(j))+")";
                END;   
           END; //fin IF
       END; //fin FOR j
     if r then phi:=phi+"+"+replace(retard,"x","X") end;
     phi:="'"+replace(phi,"X","ALOG(X)")+"'";
    liste_phases(k):=EXPR(phi);
    recalc_phase(k):=0;
   end; //fin if ischek
 end; //fin for k

END;

calcule_rep_temp()
begin
   local f, k;
     for k from 1 to length(liste_fonctions) do
        if ISCHECK(k MOD 10) AND recalc_temp(k) then
          f:=REPLACE(STRING(liste_fonctions(k)),"X","x");
          f:=f+"*1/x,x,x";
          f:="'("+REPLACE(STRING(CAS.ilaplace(f)),"x","X")+")*PIECEWISE(X<0,0,X≥0,1)'";
          IF instring(f,"ilaplace") 
            THEN MSGBOX("Problème avec F"+k MOD 10); CONTINUE;
            ELSE liste_rep_temp(k):=EXPR(f);
          END;
          recalc_temp(k):=0;
        end;
     end;
end;


Symb()
begin
  modif:=1;
  replace_les_fonctions;
  STARTVIEW(0,1);
end;

Plot()
begin
  local choix;
  if modif then copie_les_fonctions end;
  CHOOSE(choix,"Choisissez un type de tracé",{"Module","phase","réponse indicielle"});
  CASE
   IF choix==1 THEN calcule_modules; place_les_modules;Ytick:=20 END;
   IF choix==2 THEN calcule_phases; place_les_phases;Ytick:=45 END;
   IF choix==3 THEN calcule_rep_temp; place_les_rep_temp; Xmin:=−0.2 END;
   //DEFAULT
  END;
  STARTVIEW(1,1);
end;

START()
begin
 replace_les_fonctions;
 STARTVIEW(0,1);
end;


Attached File(s)
.zip  Bode.hpappdir.zip (Size: 2.29 KB / Downloads: 5)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
[7820 FW]Custom Bode APP doesn't work anymore on emulator ? ["1/2 SOLVED"] - dg1969 - 05-14-2015 11:16 AM



User(s) browsing this thread: 1 Guest(s)