si je mets un controle sur mon code ...
Publié : jeu. 19/févr./2009 18:42
tout d'abord merci à tous pour vos bouts de codes, celà m'a bien aidé.
mon code fonctionne bien, les résultats sont bons je les aient vérifiés sur un site j'ai trouvé les memes résultats.
il me reste des petites améliorations:
-> comment faire pour n'avoir que un chiffre apres la virgule pour la sortie L ? exemple 10.6 µH et non 10.6587 µH
si je veut un controle des valeurs n*c en fonction de la longueur b :
-> si n*c=b alors un message : les spires sont jointives.
-> si n*c<b alors un message : les spires ne sont pas jointives.
-> si n*c>b alors un message : erreur ! valeurs impossibles.
voici mon code fonctionnel !...
;programme de calcul d'inductance avec la formule de Nagaoka
;code du 18 février 2009
; résultats ok pour mémoire
Define L.D
Define A.D
Define B.D
Define C.D
Define N.D
Define K.D
OpenWindow(-1, 0, 0, 255, 150, "Calcul de self à air", $CF0001) ; fenetre principale
TextGadget(11, 0, 5, 200, 30, " Diamètre du mandrin en mm") ;a
TextGadget(12, 0, 35, 200, 30, " Longueur de la self en mm") ;b
TextGadget(13, 0, 65, 200, 30, " Diamètre du fil en mm") ;c
TextGadget(14, 0, 95, 200, 30, " Nombre de spires") ;n
TextGadget(15, 0, 125, 200, 30, " Inductance en µH") ;L
StringGadget(1, 200, 0, 50, 30, "") ;position a
StringGadget(2, 200, 30, 50, 30, "") ;position b
StringGadget(3, 200, 60, 50, 30, "") ;position c
StringGadget(4, 200, 90, 50, 30, "") ;position n
StringGadget(5, 200, 120, 50, 30, "") ;position L
Repeat
A = ValD(GetGadgetText(1) )
B = ValD(GetGadgetText(2) )
C = ValD(GetGadgetText(3) )
N = ValD(GetGadgetText(4) )
; conversion des cm en mm
A=A/10
B=B/10
C=C/10
; calcul du rayon théorique suivant Nagaoka
A=(A+C)/2
; ==========================tests pour coeficient K ============
If (2*(a/b))=0
k=1
EndIf
If (2*(a/b)) > 0.02 And (2*(a/b)) < 0.06
k=0.97
EndIf
If (2*(a/b)) > 0.07 And (2*(a/b)) < 0.11
K=0.959
EndIf
If (2*(a/b)) > 0.12 And (2*(a/b)) < 0.16
K=0.939
EndIf
If (2*(a/b)) > 0.17 And (2*(a/b)) < 0.21
K=0.92
EndIf
If (2*(a/b)) > 0.22 And (2*(a/b)) < 0.26
K=0.902
EndIf
If (2*(a/b)) > 0.27 And (2*(a/b)) < 0.31
K=0.884
EndIf
If (2*(a/b)) > 0.32 And (2*(a/b)) < 0.41
K=0.85
EndIf
If (2*(a/b)) > 0.42 And (2*(a/b)) < 0.51
K=0.818
EndIf
If (2*(a/b)) > 0.52 And (2*(a/b)) < 0.61
K=0.789
EndIf
If (2*(a/b)) > 0.62 And (2*(a/b)) < 0.71
K=0.761
EndIf
If (2*(a/b)) > 0.72 And (2*(a/b)) < 0.81
K=0.735
EndIf
If (2*(a/b)) > 0.82 And (2*(a/b)) < 0.91
K=0.711
EndIf
If (2*(a/b)) > 0.92 And (2*(a/b)) < 1.01
K=0.688
EndIf
If (2*(a/b)) > 1.02 And (2*(a/b)) < 1.26
K=0.638
EndIf
If (2*(a/b)) > 1.27 And (2*(a/b)) < 1.51
K=0.595
EndIf
If (2*(a/b)) > 1.52 And (2*(a/b)) < 1.76
K=0.558
EndIf
If (2*(a/b)) > 1.77 And (2*(a/b)) < 2.01
K=0.526
EndIf
If (2*(a/b)) > 2.02 And (2*(a/b)) < 2.51
K=0.472
EndIf
If (2*(a/b)) > 2.52 And (2*(a/b)) < 3.01
K=0.429
EndIf
If (2*(a/b)) > 3.02 And (2*(a/b)) < 3.51
K=0.394
EndIf
If (2*(a/b)) > 3.52 And (2*(a/b)) < 4.01
K=0.365
EndIf
If (2*(a/b)) > 4.02 And (2*(a/b)) < 5.01
K=0.32
EndIf
If (2*(a/b)) > 5.02 And (2*(a/b)) < 6.01
K=0.283
EndIf
If (2*(a/b)) > 6.02 And (2*(a/b)) < 7.01
K=0.258
EndIf
If (2*(a/b)) > 7.02 And (2*(a/b)) < 8.01
K=0.237
EndIf
If (2*(a/b)) > 8.02 And (2*(a/b)) < 9.01
K=0.219
EndIf
If (2*(a/b)) > 9.02 And (2*(a/b)) < 10.01
K=0.203
EndIf
If (2*(a/b)) > 10.02 And (2*(a/b)) < 25.01
K=0.105
EndIf
If (2*(a/b)) > 25.02 And (2*(a/b)) < 50.01
K=0.061
EndIf
If (2*(a/b)) > 50.02 And (2*(a/b)) < 75.01
K=0.043
EndIf
If (2*(a/b)) > 75.02 And (2*(a/b)) < 100.01
K=0.035
EndIf
If (2*(a/b)) > 100.02 And (2*(a/b)) < 200.01
K=0.019
EndIf
If (2*(a/b)) > 200.02 And (2*(a/b)) < 400.01
K=0.011
EndIf
;===================================formule de Nagaoka ==================
L = (0.0395*(a*a)*(n*n)*K) / b
If L <> AncienResultat
SetGadgetText(5, StrD(L) )
EndIf
AncienResultat = L
Until WaitWindowEvent() = 16
merci par avance.
mon code fonctionne bien, les résultats sont bons je les aient vérifiés sur un site j'ai trouvé les memes résultats.
il me reste des petites améliorations:
-> comment faire pour n'avoir que un chiffre apres la virgule pour la sortie L ? exemple 10.6 µH et non 10.6587 µH
si je veut un controle des valeurs n*c en fonction de la longueur b :
-> si n*c=b alors un message : les spires sont jointives.
-> si n*c<b alors un message : les spires ne sont pas jointives.
-> si n*c>b alors un message : erreur ! valeurs impossibles.
voici mon code fonctionnel !...
;programme de calcul d'inductance avec la formule de Nagaoka
;code du 18 février 2009
; résultats ok pour mémoire
Define L.D
Define A.D
Define B.D
Define C.D
Define N.D
Define K.D
OpenWindow(-1, 0, 0, 255, 150, "Calcul de self à air", $CF0001) ; fenetre principale
TextGadget(11, 0, 5, 200, 30, " Diamètre du mandrin en mm") ;a
TextGadget(12, 0, 35, 200, 30, " Longueur de la self en mm") ;b
TextGadget(13, 0, 65, 200, 30, " Diamètre du fil en mm") ;c
TextGadget(14, 0, 95, 200, 30, " Nombre de spires") ;n
TextGadget(15, 0, 125, 200, 30, " Inductance en µH") ;L
StringGadget(1, 200, 0, 50, 30, "") ;position a
StringGadget(2, 200, 30, 50, 30, "") ;position b
StringGadget(3, 200, 60, 50, 30, "") ;position c
StringGadget(4, 200, 90, 50, 30, "") ;position n
StringGadget(5, 200, 120, 50, 30, "") ;position L
Repeat
A = ValD(GetGadgetText(1) )
B = ValD(GetGadgetText(2) )
C = ValD(GetGadgetText(3) )
N = ValD(GetGadgetText(4) )
; conversion des cm en mm
A=A/10
B=B/10
C=C/10
; calcul du rayon théorique suivant Nagaoka
A=(A+C)/2
; ==========================tests pour coeficient K ============
If (2*(a/b))=0
k=1
EndIf
If (2*(a/b)) > 0.02 And (2*(a/b)) < 0.06
k=0.97
EndIf
If (2*(a/b)) > 0.07 And (2*(a/b)) < 0.11
K=0.959
EndIf
If (2*(a/b)) > 0.12 And (2*(a/b)) < 0.16
K=0.939
EndIf
If (2*(a/b)) > 0.17 And (2*(a/b)) < 0.21
K=0.92
EndIf
If (2*(a/b)) > 0.22 And (2*(a/b)) < 0.26
K=0.902
EndIf
If (2*(a/b)) > 0.27 And (2*(a/b)) < 0.31
K=0.884
EndIf
If (2*(a/b)) > 0.32 And (2*(a/b)) < 0.41
K=0.85
EndIf
If (2*(a/b)) > 0.42 And (2*(a/b)) < 0.51
K=0.818
EndIf
If (2*(a/b)) > 0.52 And (2*(a/b)) < 0.61
K=0.789
EndIf
If (2*(a/b)) > 0.62 And (2*(a/b)) < 0.71
K=0.761
EndIf
If (2*(a/b)) > 0.72 And (2*(a/b)) < 0.81
K=0.735
EndIf
If (2*(a/b)) > 0.82 And (2*(a/b)) < 0.91
K=0.711
EndIf
If (2*(a/b)) > 0.92 And (2*(a/b)) < 1.01
K=0.688
EndIf
If (2*(a/b)) > 1.02 And (2*(a/b)) < 1.26
K=0.638
EndIf
If (2*(a/b)) > 1.27 And (2*(a/b)) < 1.51
K=0.595
EndIf
If (2*(a/b)) > 1.52 And (2*(a/b)) < 1.76
K=0.558
EndIf
If (2*(a/b)) > 1.77 And (2*(a/b)) < 2.01
K=0.526
EndIf
If (2*(a/b)) > 2.02 And (2*(a/b)) < 2.51
K=0.472
EndIf
If (2*(a/b)) > 2.52 And (2*(a/b)) < 3.01
K=0.429
EndIf
If (2*(a/b)) > 3.02 And (2*(a/b)) < 3.51
K=0.394
EndIf
If (2*(a/b)) > 3.52 And (2*(a/b)) < 4.01
K=0.365
EndIf
If (2*(a/b)) > 4.02 And (2*(a/b)) < 5.01
K=0.32
EndIf
If (2*(a/b)) > 5.02 And (2*(a/b)) < 6.01
K=0.283
EndIf
If (2*(a/b)) > 6.02 And (2*(a/b)) < 7.01
K=0.258
EndIf
If (2*(a/b)) > 7.02 And (2*(a/b)) < 8.01
K=0.237
EndIf
If (2*(a/b)) > 8.02 And (2*(a/b)) < 9.01
K=0.219
EndIf
If (2*(a/b)) > 9.02 And (2*(a/b)) < 10.01
K=0.203
EndIf
If (2*(a/b)) > 10.02 And (2*(a/b)) < 25.01
K=0.105
EndIf
If (2*(a/b)) > 25.02 And (2*(a/b)) < 50.01
K=0.061
EndIf
If (2*(a/b)) > 50.02 And (2*(a/b)) < 75.01
K=0.043
EndIf
If (2*(a/b)) > 75.02 And (2*(a/b)) < 100.01
K=0.035
EndIf
If (2*(a/b)) > 100.02 And (2*(a/b)) < 200.01
K=0.019
EndIf
If (2*(a/b)) > 200.02 And (2*(a/b)) < 400.01
K=0.011
EndIf
;===================================formule de Nagaoka ==================
L = (0.0395*(a*a)*(n*n)*K) / b
If L <> AncienResultat
SetGadgetText(5, StrD(L) )
EndIf
AncienResultat = L
Until WaitWindowEvent() = 16
merci par avance.