![]() |
||
| Home | SwiftForth Archive | SwiftX Archive | |

This is probably not worthy of FAQ posting, but ....
Here is a quickie program for calculating inductance (L), capacitance =
(C) and frequency (FREQ) values for an oscillator or LC resonant =
network. It solves for the missing value, given any two parameters. =20
This is my first use of the SF floating point package. Comments and =
criticisms are welcome.
\ ***** Calculate LC Values for an Oscillator *****
\
include c:\forthinc\swiftforth\lib\options\fpmath.f
8 ENG \ display 8 places
FVARIABLE FREQ
FVARIABLE L
FVARIABLE C
PI F2* FCONSTANT 2PI
: W2 2PI FREQ F@ F* FDUP F* ; \ omega squared
: LORC ( F: a -- n) F@ W2 F* 1/N ; \ calc L or C, given C or L
\ ***** ENTER STARTING VALUES HERE *********
0.290e6 FREQ F! \ 290 kHz
2403e-12 C F! \ 2403 pf
\ 125e-6 L F! \ 125 uh
C LORC L F! \ start with calculated L
\ ******************************************
: L? ( -- ) C LORC N. ;
: C? ( -- ) L LORC N. ;
: FREQ? ( -- ) C F@ L F@ F* FSQRT 2PI F* 1/N N. ;
: LC? ( -- ) CR CR \ display current values
." L is: " L? ." Henries"
CR ." C is: " C? ." Farads"
CR ." FREQ is: " FREQ? ." Hertz" CR ;
CR CR CR
.( Enter values for any two: L, C, and FREQ)
CR=20
.( Display the results with L?, C?, FREQ? or LC?)
CR CR
.( Example for FREQ from L and C: 2403e-12 C F! 125e-6 L F! LC?)
CR CR
.( Current values:)
LC?
CR CR
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Thu May 08 2003 - 06:53:35 PDT
This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 03:04:32 PST