Kicad-to-HAL: Parameters and Constants

Kicad PARAMETER symbols (center, left of the upper TOGGLE) provide the value for HAL setp commands:

Kicad-to-HAL Demo Schematic
Kicad-to-HAL Demo Schematic

Which becomes this line in the HAL file:

setp toggle.0.debounce 5	# parameter.0

Parameter pins use the Inverted graphic style decorating them with a small circle to distinguish parameters from ordinary data pins, but the data value is not inverted. Parameter components can also connect to ordinary HAL input pins without the Inverted style.

PARAMETER symbols have an invisible reference value (parameter.0 in the example) that you don’t care about:

Kicad symbol - PARAMETER
Kicad symbol – PARAMETER

Edit the value inside the symbol to whatever you need.

Kicad CONSTANT symbols (lower center, left of the TIMEDELAY symbol) generate HAL CONSTANT modules, set their values, and connect them to a thread. The resulting HAL commands look like this:

addf constant.0		servo-thread
addf constant.1		servo-thread

… snippage …

setp constant.0.value [BLINKY]ON
setp constant.1.value [BLINKY]OFF

… snippage …

net N_001 <= constant.1.out => timedelay.0.off-delay
net N_002 <= constant.0.out => timedelay.0.on-delay

The thread connections works the same way as for other HAL components with the automagic net connection to “_”:

Kicad symbol - CONSTANT
Kicad symbol – CONSTANT

The (invisible) + in the middle tells Kicad-to-HAL to put the total number of CONSTANT components into the addf command.

As with Parameters, edit the CONSTANT inside the symbol as needed.

Both Parameters and Constants can use text values defined in the INI file:

[BLINKY]
ON = 0.2
OFF = 2.0

Both Parameters and Constants can connect to nets going to multiple input pins, but it’s probably not worth cluttering a schematic with off-page connectors just to reuse a single instance. When you copy-n-paste an otherwise identical symbol somewhere else, it will get a different reference number and generate additional HAL commands, which may offend your sense of neatness.

One thought on “Kicad-to-HAL: Parameters and Constants

Spam comments get trashed, so don't bother. Comment moderation may cause a delay.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s