RadioBanter

RadioBanter (https://www.radiobanter.com/)
-   Antenna (https://www.radiobanter.com/antenna/)
-   -   Antenna programming tool/language/compiler/preprocessor? (https://www.radiobanter.com/antenna/120608-antenna-programming-tool-language-compiler-preprocessor.html)

[email protected] June 17th 07 01:06 PM

Antenna programming tool/language/compiler/preprocessor?
 
Again,

my intention is, not to re-invent the programming language "C". My
intention is, to describe in a prooven language an antenne. I decided
the programming language C, because it is most used language on the
world.

I have not given any name for my language to the pre-processor. Lets
call this as SNEC - just for "Symbolic NEC". The commands for the pre-
processor has similar syntax to the programming language C. But not
exactly the same. It has many limitations.

As an example, I show you one of the source code of a horn antenna for
WLAN. It has three modules. As you can see, the language is as
superset of NEC2 and 4NEC2. It can be adapted easily to any other
antenne defining formats. If the pre-processor detects an unknowing
command, it will do nothing. Just taking the line of code and writing
to output file. A special set of commands will be interpreted by the
pre-processor. It will translate it into the 4NEC2/NEC2 commands.
That is all. It is a very simple language, but you can design very
complex antenna model with few lines of "code".
The output file has a lot of kilobytes of code! It will split surface
patches into many segments or wires. The main module is Horn1.txt.

Aziz

--------------- File: Horn1.txt -------------------------
CM Horn Antenna Model at 2.437 GHz (C) 2007 by Aziz Oeguet
CE

#include "Common.txt"
#include "PP4NEC2Defs.txt"

#ifndef H_wrmode
H_wrmode = 0 // Drahtmodus (0=Surface-Path, 1=Wire-Modus)
#endif

#if (H_wrmode)
// Parameter für Wire-Modus
#pragma mode = _MODE_WR, wrnumseg = 1, wrtagstart=5000, wrtaginc =
1, wrradius = 0.00075
#pragma symode = _SYMODE_REUSE
#else
#pragma mode= _MODE_SP
#pragma symode = _SYMODE_REUSE
#endif

//--- Biquad-Parameter definieren ---
BQ_nsegw = 8 // Number of segments for width
BQ_nsegh = 8 // Number of segments for height
BQ_RW = 0.10 // Reflector width (y-axis)
BQ_RH = 0.10 // Reflector height (z-axis)

// Erreger-Antenne einfügen
#include "FeedBiQ.txt"

refdist = 0.014617 // Reflector distance to antenna


// Box parameters
B_Px = -refdist // Position of box (x-Axis)
B_Py = 0 // Position of box (y-Axis)
B_Pz = 0 // Position of box (z-Axis)

#if (H_wrmode)
B_lseg = 25 // Number of segments for length (x-axis)
B_wseg = 21 // Number of segments for width 2 (y-axis)
B_hseg = 18 // Number of segments for height 2 (z-axis)
#else
B_lseg = 30 // Number of segments for length (x-axis)
B_wseg = 24 // Number of segments for width 2 (y-axis)
B_hseg = 20 // Number of segments for height 2 (z-axis)
#endif

B_W1 = BQ_RW // Box width 1 (y-axis)
B_H1 = BQ_RH // Box height 1 (z-axis)

// Opt. simuliert
B_L = 0.385216 // 0.398 // Box length (x-axis)
B_W2 = 0.40 // Box width 2 (y-axis)
B_H2 = 0.291 // Box height 2 (z-axis)


#if (H_wrmode)
B_nBox = 1 // Number of box divisions for a better
segmentation
#else
B_nBox = 10 // Number of box divisions for a better
segmentation
#endif

#if B_nBox == 1
B_wseg1 = B_wseg // Number of segments for width 1 (y-axis)
B_hseg1 = B_hseg // Number of segments for height 1 (z-axis)
#else
B_wseg1 = 2+B_W1/(B_W2/B_wseg) // Number of segments for width 1 (y-
axis)
B_hseg1 = 2+B_H1/(B_H2/B_hseg) // Number of segments for height 1 (z-
axis)
#endif

// Deltas for box divisions
B_DH = (B_H2-B_H1)/B_nBox
B_DW = (B_W2-B_W1)/B_nBox
B_DL = B_L/B_nBox

//--- Horn Reflektor ---

B_dws = (B_wseg - B_wseg1)/B_nBox
B_dhs = (B_hseg - B_hseg1)/B_nBox

for (i=0; i B_nBox; i=i+1)
{
#if i==0
#Box %%(B_wseg1+i*B_dws) %%(B_hseg1+i*B_dhs) %%(B_lseg/B_nBox)
(B_Px+%%i*B_DL) B_Py B_Pz (B_W1+%%i*B_DW) (B_W1+%%(i+1)*B_DW) (B_H1+%
%i*B_DH) (B_H1+%%(i+1)*B_DH) B_DL BLRUD _8ALL
#else
#Box %%(B_wseg1+i*B_dws) %%(B_hseg1+i*B_dhs) %%(B_lseg/B_nBox)
(B_Px+%%i*B_DL) B_Py B_Pz (B_W1+%%i*B_DW) (B_W1+%%(i+1)*B_DW) (B_H1+%
%i*B_DH) (B_H1+%%(i+1)*B_DH) B_DL LRUD _8ALL-_4ALL
#endif

} // for i

ofsx = -B_L-B_Px // Offset structure


// Achsen-Transformation (verschieben, um aus dem Nahfeld
rauszukommen)
GM 0 0 0 0 0 ofsx 0 0 0


// End-Of-Geometry
GE 0

//--- Wire-Load (HF-Speisung) ---
EX 0 Ant_Feed_Tagnr Ant_Feed_Segnr 0 1.0 0.0
LD 5 0 0 0 62900000

// Extended-Wire-Kernel einschalten
EK 1

//--- Frequency Parameter and Execute ---
FR 0 1 0 0 freq 1
EN
-------------------File: Common.txt ----------------------
CM
CM File: Common.txt
CM
CM Antenna Model at 2.437 GHz (C) 2007 by Aziz Oeguet
CM
CM --- General parameters ---
CE

freq = 2437.0 // Operating frequency in MHz
pi = 3.14159265358979 // famous pi
c0 = 299792.458 // Light speed km/s
lambda = c0/freq/1000 // One wave length in m
lambda2= lambda/2 // Half wave length in m
lambda4= lambda/4 // Fourth wave length in m

CM End of File Common.txt
CE
-----------------File: PP4NECDefs.txt ----------------------
CM
CM File: PP4NEC2Defs.txt
CM
CM PP4NEC2 Constant Definitions (C) 2007 by Aziz Oeguet
CM

//--- Modus-Arten definition (Bit-Flag, Number-Codes) ---
_MODE_SP = 0 // #pragma mode=_MODE_SP - Surface Patch Modus
(Metallflächen)
_MODE_WR = 1 // #pragma mode=_MODE_WR - Wire Modus
(Drahtmodell)

_SYMODE_UNIQUE = 1 // #pragma symode = _SYMODE_UNIQUE - interne
Symbole einzigartig (keine Mehrfachverwendung)
_SYMODE_REUSE = 0 // #pragma symode = _SYMODE_REUSE - interne
Symbole mehrfach verwenden (durch Neuzuweisung)

_HS_OUTSIDE = 0 // Struktur nur ausserhalb zulassen (innerhalb des
Hotspots keine Objekte)
_HS_INSIDE = 1 // Struktur nur innerhalb zulassen (ausserhalb des
Hotspots keine Objekte)


//--- Edge definitions (Bit-Flags) (#Sp3 only) ---
_P1P2 = 1 // Kante P1-P2 mit Draht verbinden (nur bei Wire Modus)
_P2P3 = 2 // Kante P2-P3 mit Draht verbinden (nur bei Wire Modus)
_P3P1 = 4 // Kante P3-P1 mit Draht verbinden (nur bei Wire Modus)
_3ALL = 7 // alle Kanten des Dreiecks mit Draht verbinden (nur bei
Wire Modus)

//--- Edge definitions (Bit-Flags) (#Sp4 plus #Sp3) ---
_P3P4 = 4 // Kante P3-P4 mit Draht verbinden (nur bei Wire Modus)
_P4P1 = 8 // Kante P4-P1 mit Draht verbinden (nur bei Wire Modus)
_4ALL = 15 // alle Kanten des Vierecks mit Draht verbinden (nur bei
Wire Modus)

//--- Edge definitions (Bit-Flags) (#Box, #Horn plus #Sp4) ---
_P5P6 = 16 // Kante P5-P6 mit Draht verbinden (nur bei Wire Modus)
_P6P7 = 32 // Kante P6-P7 mit Draht verbinden (nur bei Wire Modus)
_P7P8 = 64 // Kante P7-P8 mit Draht verbinden (nur bei Wire Modus)
_P8P5 = 128 // Kante P8-P5 mit Draht verbinden (nur bei Wire Modus)
_P1P5 = 256 // Kante P1-P5 mit Draht verbinden (nur bei Wire Modus)
_P2P6 = 512 // Kante P2-P6 mit Draht verbinden (nur bei Wire Modus)
_P3P7 = 1024 // Kante P3-P7 mit Draht verbinden (nur bei Wire Modus)
_P4P8 = 2048 // Kante P4-P8 mit Draht verbinden (nur bei Wire Modus)
_8ALL = 4095 // alle Kanten des Objekts mit Draht verbinden (nur bei
Wire Modus)

//--- Edge definitions (Bit-Flags) (#SpArc and #Tube only) ---
_A1 = 1 // Kante Alpha1 (Startwinkel)
_A2 = 2 // Kante Alpha2 (Endwinkel)
_R1 = 4 // Kante Radius 1 (Startradius)
_R2 = 8 // Kante Radius 2 (Endradius)
_RALL = 15 // alle Kanten des Objekts mit Draht verbinden (nur bei
Wire Modus)

//--- Konvex definition (Bit-Flag) (für Metallflächen (Surface
Patches)) ---
_CONVEX = 65536 // Objekt ist Konvex, alle Normalenvektoren zeigen
nach aussen

CM End of File PP4NEC2Defs.txt
CE
----------------File: FeedBiQ.txt------------
CM
CM File: FeedBiQ.txt
CM
CM BiQuad-Feeder Antenna Model at 2.437 GHz (C) 2007 by Aziz Oeguet
CM
CE

//--- Antenne parameters ---

#ifndef BQ_sgap
BQ_sgap = 0.003 // Soldering gap distance
#endif

#ifndef BQ_wr
BQ_wr = 0.00075 // Wire radius
#endif

#ifndef BQ_wrseg
BQ_wrseg = 5 // Number of segments on partial
antenne wire part
#endif

#ifndef BQ_tagwr
BQ_tagwr = 1000 // Antenna Tag-Start
#endif

BQ_elemlen = lambda/4 // Antenna element length
BQ_ea = BQ_elemlen/sqr(2) // Projected axis length of antenna
element


//--- Antenne (BiQuad) ---

GW BQ_tagwr 1 0 0 BQ_sgap/2 0 0 -
BQ_sgap/2 BQ_sgap/6
GW BQ_tagwr+1 BQ_wrseg 0 0 BQ_sgap/2 0 BQ_ea
BQ_ea BQ_wr
GW BQ_tagwr+2 BQ_wrseg 0 BQ_ea BQ_ea 0 2*BQ_ea
0 BQ_wr
GW BQ_tagwr+3 BQ_wrseg 0 2*BQ_ea 0 0 BQ_ea -
BQ_ea BQ_wr
GW BQ_tagwr+4 BQ_wrseg 0 BQ_ea -BQ_ea 0 0 -
BQ_sgap/2 BQ_wr
GW BQ_tagwr+5 BQ_wrseg 0 0 -BQ_sgap/2 0 -BQ_ea -
BQ_ea BQ_wr
GW BQ_tagwr+6 BQ_wrseg 0 -BQ_ea -BQ_ea 0 -2*BQ_ea
0 BQ_wr
GW BQ_tagwr+7 BQ_wrseg 0 -2*BQ_ea 0 0 -BQ_ea
BQ_ea BQ_wr
GW BQ_tagwr+8 BQ_wrseg 0 -BQ_ea BQ_ea 0 0
BQ_sgap/2 BQ_wr


//--- Wire-Load Punkt definieren (HF-Speisepunkt) ---

Ant_Feed_Tagnr = BQ_tagwr
Ant_Feed_Segnr = 1

CM End of File FeedBiQ.txt
CE

-------------------END----------------


Richard Clark June 17th 07 04:29 PM

Antenna programming tool/language/compiler/preprocessor?
 
On Sun, 17 Jun 2007 05:06:25 -0700, wrote:

Again,

my intention is, not to re-invent the programming language "C".


Hi Aziz,

Unfortunately that is exactly what you have done, re-invent C. The
source you provide makes sense mostly to the C programming community,
not antenna designers.

MY intention is, to describe in a prooven language an antenne. I decided
the programming language C, because it is most used language on the
world.


Antenna designers are not C programmers, usually. As this post proves
through your contribution, English is far more universal - hence
designing an antenna pre-processing language with a natural language
interface makes far more sense.

You don't know BNF or YACC, do you?

I have not given any name for my language to the pre-processor. Lets
call this as SNEC - just for "Symbolic NEC". The commands for the pre-
processor has similar syntax to the programming language C. But not
exactly the same. It has many limitations.


The first limitation is the source you provide is not a symbolic
language, it is a procedural language. Just giving it the name
symbolic does not make it one.

Please reference SNOBOL for symbolic languages, or Pascal records, or
if you insist C, then C's structs (I notice you don't use structs).

Mainstream symbolic languages still in use are AWK and Perl. Either
of these languages could be implemented in C, but neither look like C.

Do you know AWK? Perl?

Professional software C programmers have skills with the UNIX toolkit
since C was designed in BNF created by YACC and its product used to
build AWK.

As an example, I show you one of the source code of a horn antenna for
WLAN. It has three modules. As you can see, the language is as
superset of NEC2 and 4NEC2. It can be adapted easily to any other
antenne defining formats. If the pre-processor detects an unknowing
command, it will do nothing.


This is called a "silent failure" and YACC can easily provide a not so
silent warning. "Silent failures" are very poor design.

Just taking the line of code and writing
to output file. A special set of commands will be interpreted by the
pre-processor. It will translate it into the 4NEC2/NEC2 commands.
That is all. It is a very simple language, but you can design very
complex antenna model with few lines of "code".
The output file has a lot of kilobytes of code! It will split surface
patches into many segments or wires. The main module is Horn1.txt.


You should also consult (by googling the term) XLZIZL.zip.

You have done a lot of work. You obviously know what you want from
your code. You clearly know what the product is going to be. To be
useful, you need to wrap it in a truly symbolic language of your own
design.

Using the appropriate tools, LEX and YACC, you can preserve your
investment with the code you have written, and build a natural
language (or symbolic) interface to it.

Research the term BNF (Backus Naur Form). BNF is the ultimate
symbolic code and has stood the test of time in some version for 50
years.

73's
Richard Clark, KB7QHC

[email protected] June 18th 07 10:27 AM

Antenna programming tool/language/compiler/preprocessor?
 
Sorry Richard,

no source code will be available for anybody. Only binaries and
antenna models.
But the expression-syntax is shown below:
(you must convert the text below to courier font, to see the diagram
right).

// Level1 : ---+---(Level2)---+---
// | |
// +-----[||]-----+

// Level2 : ---+---(Level3)---+---
// | |
// +-----[&&]-----+

// Level3 : ---(Level4)---+------------------------+---
// | +--[!=]--+ |
// +--+ +--(Level4)--+
// +--[==]--+

// Level4 : ---(Level5)---+------------------------+---
// | +--[ ]--+ |
// | | | |
// | +--[=]--+ |
// +--+ +--(Level5)--+
// +--[ ]--+
// | |
// +--[=]--+

// Level5 : ---+---(Level6)---+---
// | |
// | +--[+]--+ |
// +--+ +---+
// +--[-]--+

// Level6 : ---+---(Level7)---+---
// | |
// | +--[^]---+ |
// | +--[|]---+ |
// | +--[&]---+ |
// | +--[*]---+ |
// +--+--[/]---+--+
// +--[%]---+

// Level7 : ---+-------------+---(Level8)---
// | +--[+]--+ |
// +--+--[-]--+--+
// +--[!]--+
// +--[~]--+

// Level8 : ---(Level9)---+-----------------+---
// disabled (// +--[^]--(Level8)--+)

// Level9 : +---[(]---(Level1)---[)]----------------+
// | |
// +---(Zahl)------------------------------+
// ---+ +---
// +---(Funktion)---[(]---(Level1)---[)]---+
// | |
// +---(Funktion2)--[(](Level1),(Level1)[)]
+ // , or ; allowed
// | |
// +---(Variable)--------------------------+

// Zahl: +[.]+(Ziffer)+------------+
// | +--------+ |
// ---+ +-+--------------------+---
// | | |+[e]++[+]+ |
// ++(Ziffer)++-------------++ ++ ++---++(Ziffer)++
// +--------++[.]+(Ziffer)++ +[E]++[-]++--------+
// +--------+

// Variable: +------[_]------+
// ---+ +---+-----------------------+---
// +--(Buchstabe)--+ | +------[_]------+ |
// +-+-+--(Buchstabe)--+-+-+
// | +----(Ziffer)---+ |
// +-------------------+

// Ziffer: [0] .. [9]

// Buchstabe: [a] .. [z], [A] .. [Z]

// Funktion: [sin], [cos], [tan], [asin], [acos], [atan], [sqrt],
// [ln], [exp], [sinh], [cosh], [tanh], [abs], [ceil],
[floor] and more


John Smith I June 18th 07 01:51 PM

Antenna programming tool/language/compiler/preprocessor?
 
wrote:
Sorry Richard,

no source code will be available for anybody. Only binaries and
antenna models.
...


Keep it, I'll write my own ... :-)

Regards,
JS

Richard Clark June 18th 07 03:47 PM

Antenna programming tool/language/compiler/preprocessor?
 
On Mon, 18 Jun 2007 02:27:28 -0700, wrote:

Sorry Richard,

no source code will be available for anybody. Only binaries and
antenna models.
But the expression-syntax is shown below:
(you must convert the text below to courier font, to see the diagram
right).


Hi Aziz,

OK, all pretty conventional stuff 30 years ago. So what is the
problem with abstracting a symbolic wrapper to level 1 to make it
generally useful?

As I said, there's no reason why your work can't survive, my question
was why do you simply re-invent C, a language as dead to antenna
designers as Sanskrit?

73's
Richard Clark, KB7QHC

Richard Clark June 18th 07 04:29 PM

Antenna programming tool/language/compiler/preprocessor?
 
On Mon, 18 Jun 2007 07:47:37 -0700, Richard Clark
wrote:

As I said, there's no reason why your work can't survive, my question
was why do you simply re-invent C, a language as dead to antenna
designers as Sanskrit?


For instance. Even C programmers (some) enjoy the benefit of structs
as a layer of abstraction. This is a pretty thin difference, but
certainly within furthering the scheme of antenna design. Why I say
that is that the NEC card deck is already a struct. To ignore the
card deck is a step backwards from antenna design to simply conform to
a programmer's model.

Further, taking the deck, you stand a better model with Pascal and
records. This gives the antenna designer a way to more fluently
describe and access segments, wires, or elements. It is a natural
progression. However, Pascal is hardly a symbolic language, except by
some of its own elements (the record). Abstracting further, LISP (a
decidedly intense symbolic language) is a chained and recursive
language (you say you've licked recursion) that mimics not only the
linear connections of wires, but the regress of arrays. However, I
wouldn't wish LISP on anyone as an antenna design language, but it is
certainly far more suitable than C.

All-in-all, each of these variants can still contain exactly what
you've offered in BNF.

In short, your expression syntax is not a language at all (not even
C). It is incomplete being only the phrase particles of many
languages. Phrases need to aggregate into clauses and then sentences.
You exhibit none of that.

73's
Richard Clark, KB7QHC

Jim Lux June 18th 07 06:47 PM

Antenna programming tool/language/compiler/preprocessor?
 
wrote:
Hello Dave,

thanks for your hint. I know the problem with perl scripts. What I am
searching is, that no text or symbol replacement or calculating
symbols is done on your source nec file. I am searching for a compiler/
pre-processor, that makes from source file (antenna model) a
compatible nec file (still left in symbolic 4nec2-format).
I am sick off, to code many symbolic lines of nec code. It is boring
and difficult, when your model gets complex and has much more
segments.
Therefore I started with my pre-processor few month ago, that makes
the code for me automatically. It supports primitive object and
complex structures. It also let you "to program" your antenna model.
But the most advantage of letting the nec file symbolic, you can
optimize the antenna parameters.
I tried and constructed many antenna models and wont miss the
optimizer tool from 4nec2.

I am wondering, that nobody made such a tool till now.

Aziz


What you are looking for is essentially a way to specify a mechanical
design, which would then be processed into an appropriate description
for a modeling code to use.

For trivial antennas, it would be pretty easy to have a text language to
describe things. You could have macros and such. However, at a basic
level, all you're doing is exchanging the somewhat cryptic NEC cards for
something more readable.

As soon as it gets more complex, you're looking at defining your own
shape/geometry definition language, and that's quite a chore.. and has
been done to boot.

A better approach is to use an off the shelf drawing package of some
sort, and build a parser that takes the mechanical drawing and turns it
into a EM model. In the commercial world, there's a lot of activity for
this sort of gridding process.

Typically you'd start with something like an IGES or DXF file.




[email protected] June 19th 07 01:02 AM

Antenna programming tool/language/compiler/preprocessor?
 
Keep it, I'll write my own ... :-)

Regards,
JS

Ok, I will wait for your ones and save time and effort.
;-)
Aziz


[email protected] June 19th 07 01:41 AM

Antenna programming tool/language/compiler/preprocessor?
 
Hi Richard,

I am really not happy with old stuff like NEC-Cards. And I do not want
do a lot of work. But a minimum of command set must be interpreted.
For the translation of primitive objects (#SP3, #SP4, #Horn, #Box,
#Tube, #Pipe, #SPArc), I am only using simple CM, CE, GW, SP, SC and
GM cards.
For symbols (variables) I am using only the extension SY of 4nec2.
Any other cards, that can not be detected from the parser, they are
simply passed through without changing. Of course, some comment line
transformation must also be done. Thats all.
Complex data type structures would explode the amount of work. I want
to keep the pre-processor as simple as possible. The pre-processor is
a NEC-processor and not a compiler.

However, there are some good ideas built in:
- fully symbolic (SY abc=..) NEC-code generation or hard wired
(calculated) NEC-code
- SP3 (triangle), SP4 (quadrilateral) can be divided into more small
peaces (segmentation)
- easy to use primitive objects
- complex (hierarchical) object transformation (move, rotation,
scaling does not work due to NEC limitation)
- surface-patch or wire-mode support, without changing the model
- hotspots, where parts of structures or locations can be masked out
(-----!)
- generator modules (parabolic reflector, helix, etc.)
- program control commands
- programable antenna models

Again, I am not re-inventing C. I am only using the syntax whenever
possible. That is the difference.

Now, many old neglected deposits from the pre-processor must be
redesigned and improved. I am doing this step by step. Of course, a
good BNF notation and implementation would simplfy many things. I will
do this for the future version may be.

Regards,
Aziz


John Smith I June 19th 07 04:07 AM

Antenna programming tool/language/compiler/preprocessor?
 
wrote:
Keep it, I'll write my own ... :-)

Regards,
JS

Ok, I will wait for your ones and save time and effort.
;-)
Aziz


LOL!

You flatter me, however, if I don't have to provide user support ... OK!

Regards,
JS


All times are GMT +1. The time now is 08:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
RadioBanter.com