Re: Waveform Mini-Language



Richard Pennington wrote:
Guy Macon wrote:

I am doing some preliminary design work on a AC waveform generator.
The primary use will be generating signals that, when amplified,
will generate three-phase AC power with various line disturbances
(dropouts, spikes, etc.). This will all be dome with DACs.

I am pondering making a mini-language to make it easier for the
users (who range from EEs to electricians) to program waveforms.
something along the lines of this (pseudocode, not the actual
syntax):

Output A Waveform = Sine

Output A Voltage = 10 VAC

Output A Frequency = 400 Hz.

Output A Phase = 120 degrees

Output A Duration = 1 Second


You could use an off the shelf command language, but you may find that it's a lot more capable than you need to do the job and has a large memory footprint

If you have the time, it's more fun and you learn more by writing your own. You can design and build a simple table driven parser and command dispatch unit to fit in a few K of memory. Typical data flow would be:

Get and tokenise input line

Syntax check against defined command set.

Lexical analysis

Command dispatch,

A typical command language structure that i've used in the past is of the form <command> <variable> <value> or <command> <variable> <value> <qualifier>, which results in commands like set frequency 1000, set volts 250 etc. If you keep the command set structure consistent throughout, writing the parser becomes a fairly trivial exercise. What you get at the output is a collection of function stubs, which you write to do the actual work.

A book on compiler design would be usefull - you don't need all the hairy stuff for simple command line parser, but it would provide a good background to the various techniques used.

IMO, one of the more interesting areas of software design...

Chris






Electronic and Embedded System Design
Oxford, England
(44) 1865 750 681
.