6.6.9. Custom board definition format¶
Custom board definition files follow a prescribed format in motorBench® Development Suite. They are human-readable and hand-editable, but they are based on a defined data structure, organized as a data model.
The data model must conform to the board definition schema
The data model is serialized as a text format (YAML in motorBench 2.50)
The following sections describe these constraints.
6.6.9.1. Working with Serialized Data Models¶
6.6.9.1.1. Introduction¶
The term data model refers to any hierarchical tree structure used to model a system. In motorBench® Development Suite we use several data models, for processes such as code generation, parameter customization and custom board support.
Some data models can be serialized into text formats such as JSON, YAML, and TOML, which facilitates use of version control and hand-editing where appropriate. The custom board feature in motorBench® Development Suite 2.50 supports importing files in YAML format.
The data model for board definitions in motorBench is
serializable to JSON and deserializable from JSON, including support for the following types of values
numbers
strings
booleans (
true
andfalse
)null
lists of values (= arrays / ordered sequences)
maps of values (= dictionaries / unordered sets of key-value pairs)
generally described in YAML format (easier to read/write than JSON)
referenced by a path separated by dots, for example
characteristics.current.phase.fullscale
6.6.9.1.2. Example in YAML¶
Here is an excerpt containing a partial board definition in YAML. Its hierarchical structure is expressed through levels of indentation.
Note
When editing, we suggest using an editor that supports YAML, such as VSCode or Notepad++, with syntax highlighting and ability to expand/collapse sections of the hierarchy.
Warning
To avoid misalignment and incompatibility, use spaces for indentation, not tabs.
identification:
id: custom_board
displayName: "Custom Board"
description: "Custom Board"
characteristics:
device: dsPIC33CK256MP508
# This is a comment
current:
phase:
fullscale: 21.8
maximum:
# WOO HOO HOO
continuous: 14.1
timeConstant: 184.0e-9
dcLink:
fullscale: 21.8
timeConstant: 184.0e-9
peripherals:
adc:
current:
a:
channel: AN0
inverted: true
signed: true
b:
channel: AN1
inverted: true
signed: true
opamp:
enabled:
- 1
- 2
- 3
Comments are expressed as a
#
followed by arbitrary text that will be ignored until the end of the lineNumbers are expressed as integers, floating-point values, or scientific notation
Floating-point values may be expressed as decimals (examples:
0.38
,8702.1
) or as scientific notation (examples:-3.02e-5
,4.73e3
).Note
When using scientific notation, make sure to use a decimal before the exponent, for example
3.0e-5
rather than3e-5
. This avoids issues in some software libraries.
Booleans are expressed as the fixed text
true
andfalse
(note: content is case-sensitive)Null values are expressed as the fixed text
null
Strings are expressed as text that is not a number or a boolean or null.
To be safe in YAML, use quotes to delimit the string; YAML includes other confusing and quirky representations like
on
andoff
(for booleans) or12:00
which is a time.There are several other ways to express multiline strings in YAML; you won’t need them for board definition files and should not use them.
Lists are ordered sequences of indented values, each of which is preceded by a hyphen character (the 1,2,3 at the end under
opamp.enabled
)Lists may also be represented by an alternate compact syntax
[value1, value2, value3]
as in Javascript and Python, but we generally don’t use this in our examples.
Maps are unordered sequences of indented key/value pairs, where the key is a string, followed by a colon, followed by a value that is separated from the colon by a space or newline.
The example document above is a map with three keys,
identification
,characteristics
, andperipherals
.The value associated with the
identification
key is itself a map containing three keys:id
,displayName
, anddescription
. These keys each refer to a string value that immediately follows the key, after a space.Maps may also be represented by an alternate compact syntax as in Javascript, but we generally don’t use this in our examples:
{key1: value1, key2: value2, key3: value3}
The ordering of elements in a map is not important, and may be permuted without changing the value, even though the resulting serialized YAML file is different.
Values within a data model may be referenced by a path, which is a string that uses a period/dot
.
to denote indexing a map by key, and brackets[]
to denote indexing a list by an integer value. In the example data model above:the path
identification.id
refers to the stringcustom_board
the path
peripherals.opamp.enabled[1]
refers to the number2
the path
peripherals.adc.current.a
refers to the following map:channel: AN0 inverted: true signed: true
For a more detailed introduction on YAML, there are various public sources; these appear to be among the more readable tutorials:
6.6.9.2. Custom board schema¶
The data models in custom board definitions are hierarchical tree structures that conform to the schema listed in the table below, organized under three top-level sections:
identification
— covers data associated with the name and description of a boardcharacteristics
— covers parameters associated with a board, such as maximum PWM frequency, full-scale DC link voltage, maximum continuous phase current, etc.peripherals
— covers peripheral configuration choices, such as UART pin assignment, ADC channel mapping, PWM fault source and polarity, etc.
Each row of the table describes an entry in the tree, which has several properties:
a type, which is either one of the standard data model types or one of the following:
a named type, such as [digitalPolarity], that has a constrained structure. These types are listed at the end of the table.
an
enum
, which is a choice from among several fixed options (these are listed in the description)a constrained numeric range, shown here as an inequality in either \(n\) or \(x\):
\(n\): integer range, for example \(1 \le n \le 3\)
\(x\): floating-point range, for example \(0.0 \le x \le 1.0\) or \(x \ge 0.0\)
units, if applicable — for example V (volts) or A (amperes) or s (seconds)
whether the entry is required (Req’d, denoted by a green checkmark
) or optional
Note
Entries are required or optional in the context of their parent entries. For example,
peripherals.qei
is optional, but if it is present, thenperipherals.qei.pins
is required.further descriptive notes under “Description”
Path |
Type |
Units |
Req’d |
Description |
||
---|---|---|---|---|---|---|
identification |
map |
Board identification object. |
||||
.id |
string |
Unique ID for a given instance of a board. This parameter is restricted to printable ASCII characters (codes 32-126, including space but excluding DELETE (127)). regex:descriptor = |
||||
.displayName |
string |
Board name that will appear in motorBench when the board configuration file is loaded. This parameter is restricted to printable ASCII characters (codes 32-126, including space but excluding DELETE (127)). regex:descriptor = |
||||
.description |
string |
Description of the board configuration. |
||||
characteristics |
map |
Board characteristics object. |
||||
.device |
string |
Microcontroller part number. Restricted to dsPIC33CKxxxM(P/C)xxx discrete devices and dsPIC33CDV, dsPIC33CDVC, and dsPIC33CDVL SiP devices. Use the device name as in MPLAB X, without any part suffixes to indicate
packaging or temperature range. For example, regex:deviceName = |
||||
.gateDriver |
map |
PWM gate driver object for boards with MCP802(1/2/7) gate drivers or SiP-based boards. |
||||
.device |
string |
Gate driver device name. Restricted to regex:identifier = |
||||
.configuration |
map |
Gate driver configuration object. See device datasheet for more information on each parameter. |
||||
.sleepMode |
enum |
Device mode when disabled (SLEEP). Options: 'sleep' 'standby' |
||||
.shortCircuitDetect |
boolean |
Enable external MOSFET short circuit detection (EXTSC). |
||||
.underVoltageLockout |
boolean |
Enable external MOSFET under-voltage lockout (EXTUVLO). |
||||
.opampEnabledDuringDeviceStandby |
boolean |
Enable op amps during device standby mode (OPAMP). Only required if using MCP8022. |
||||
.linPullUpsEnabled |
boolean |
Enable LIN pull-up resistors (PU30K). Only required if using MCP8027. |
||||
.dacReference |
float |
V |
Sets the DAC current reference value (DACREF). Only required if using MCP8027. |
|||
.pins |
map |
Pin assignment for the MCP802x gate driver RX, TX, fault, and device enable pins. If using a SiP device, refer to the internal connections block diagram of the device datasheet. |
||||
.RX |
string |
GPIO pin name. See device datasheet for which pins are available on the selected device. regex:pin = |
||||
.TX |
string |
GPIO pin name. See device datasheet for which pins are available on the selected device. regex:pin = |
||||
.fault |
string |
GPIO pin name. See device datasheet for which pins are available on the selected device. regex:pin = |
||||
.outputEnable |
string |
GPIO pin name. See device datasheet for which pins are available on the selected device. regex:pin = |
||||
.voltage |
map |
Contains board voltage measurement characteristics. |
||||
.phase |
map |
Specifies phase voltage measurement characteristics. |
||||
.timeConstant |
float |
s |
Time constant of phase voltage measurement circuit. |
|||
.fullscale |
float |
V |
Full scale value of phase voltage measurement. |
|||
.dcLink |
map |
Specifies DC link voltage measurement characteristics. |
||||
.timeConstant |
float |
s |
Time constant of DC link voltage measurement circuit. |
|||
.fullscale |
float |
V |
Full scale value of DC link voltage measurement. 0V-to-3.3V range at ADC corresponds to 0V-to-fullscale range. |
|||
.minimum |
float |
V |
Minimum allowable value of DC link voltage. |
|||
.maximum |
float |
V |
Maximum allowable value of DC link voltage. |
|||
.default |
float |
V |
Default value of DC link voltage. Used to initialize the system parameter for “Nominal DC link voltage” when motorBench starts a new project. |
|||
.current |
map |
Contains board current measurement characteristics. |
||||
.dcLink |
map |
Specifies DC link current measurement characteristics. |
||||
.fullscale |
float |
A |
Full scale value of DC link current measurement. |
|||
.timeConstant |
float |
s |
Time constant of DC link current measurement circuit. |
|||
.phase |
map |
Specifies phase current measurement characteristics. |
||||
.fullscale |
float |
A |
Full scale value of phase current measurement. |
|||
.timeConstant |
float |
s |
Time constant of phase current measurement circuit. |
|||
.maximum |
map |
Specifies maximum phase current characteristics. |
||||
.continuous |
float |
A |
Maximum continuous phase current. This value must be well below the full scale phase current measurement range to account for current ripple and hardware tolerances while leaving enough margin for current controller overshoot. |
|||
.peak |
float |
A |
Maximum peak phase current. This value must be well below the full scale phase current measurement range to account for current ripple and hardware tolerances while leaving enough margin for current controller overshoot. |
|||
.gainCorrectionFactors |
map |
Phase current measurement gain correction factors. These five parameters form a 3x3 matrix (Kac, Kbc, Kca, and Kcb are set to zero) used for current measurement compensation. Optional; if not present, the 3x3 identity matrix is used. |
||||
.Kaa |
\(0.5 \le x \le 1.5\) | |||||
.Kab |
\(-0.5 \le x \le 0.5\) | |||||
.Kba |
\(-0.5 \le x \le 0.5\) | |||||
.Kbb |
\(0.5 \le x \le 1.5\) | |||||
.Kcc |
\(0.5 \le x \le 1.5\) | Optional; supports boards that measure phase C current and need gain correction. |
||||
.pwm |
map |
Contains 3-phase PWM characteristics. |
||||
.frequency |
Switching frequency of 3-phase PWM signals. |
|||||
.minimum |
\(x \ge 0.0\) | Hz |
Minimum allowable value. |
|||
.maximum |
\(x \ge 0.0\) | Hz |
Maximum allowable value. |
|||
.default |
\(x \ge 0.0\) | Hz |
Default value. |
|||
.deadTime |
Dead time of 3-phase PWM signals. Brief period of time when the high and low PWM signals in a phase are off, preventing conduction and short circuits between the DC link voltage and ground. |
|||||
.minimum |
\(x \ge 0.0\) | s |
Minimum allowable value. |
|||
.maximum |
\(x \ge 0.0\) | s |
Maximum allowable value. |
|||
.default |
\(x \ge 0.0\) | s |
Default value. |
|||
.dutyCycle |
map |
PWM duty cycle characteristics. |
||||
.minimum |
float |
Minimum duty cycle supported by the board, taking into consideration the minimum pulse width limitations of the inverter stage. |
||||
.maximum |
float |
Maximum duty cycle supported by the board, taking into consideration the minimum pulse width limitations of the inverter stage, bootstrap limitations of the gate driver (if present) and current measurement limitations of low-side shunt-based current amplifier circuits (if present). |
||||
peripherals |
map |
|||||
.debugger |
map |
Programming/Debugging configuration. |
||||
.channel |
\(1 \le n \le 3\) | PGDx/PGCx channel used for Programming/Debugging. Refer to device datasheet for which Programming/Debugging channels are available. |
||||
.oscillator |
map |
Oscillator configuration. |
||||
.clockSource |
string |
Clock source selection. Possible options are
regex:clockSource = |
||||
.inputClockFrequency |
integer |
Hz |
Frequency of input clock used to generate system clock frequency. |
|||
.adc |
map |
Configuration of ADC peripheral and ADC channels. See device datasheet for which ADC channels are available on the selected device. |
||||
.samplingTime |
Sampling time of ADC channels. |
|||||
.minimum |
\(x \ge 0.0\) | s |
Minimum allowable value. |
|||
.maximum |
\(x \ge 0.0\) | s |
Maximum allowable value. |
|||
.default |
\(x \ge 0.0\) | s |
Default value. |
|||
.current |
map |
Configures ADC channels for current measurement. This determines which current measurement methods are available. |
||||
.dcLink |
Current measurement ADC channel configuration. |
|||||
.channel |
string |
Desired ADC channel to sample. regex:adcChannel = |
||||
.inverted |
boolean |
Determines if the ADC channel measurement is inverted. |
||||
.signed |
boolean |
Determines if the ADC measurement is treated as a signed value relative to mid-scale (AVdd/2) or an unsigned value relative to AVss. |
||||
.a |
Current measurement ADC channel configuration. |
|||||
.channel |
string |
Desired ADC channel to sample. regex:adcChannel = |
||||
.inverted |
boolean |
Determines if the ADC channel measurement is inverted. |
||||
.signed |
boolean |
Determines if the ADC measurement is treated as a signed value relative to mid-scale (AVdd/2) or an unsigned value relative to AVss. |
||||
.b |
Current measurement ADC channel configuration. |
|||||
.channel |
string |
Desired ADC channel to sample. regex:adcChannel = |
||||
.inverted |
boolean |
Determines if the ADC channel measurement is inverted. |
||||
.signed |
boolean |
Determines if the ADC measurement is treated as a signed value relative to mid-scale (AVdd/2) or an unsigned value relative to AVss. |
||||
.c |
Current measurement ADC channel configuration. |
|||||
.channel |
string |
Desired ADC channel to sample. regex:adcChannel = |
||||
.inverted |
boolean |
Determines if the ADC channel measurement is inverted. |
||||
.signed |
boolean |
Determines if the ADC measurement is treated as a signed value relative to mid-scale (AVdd/2) or an unsigned value relative to AVss. |
||||
.voltage |
map |
Configuration of ADC channels for voltage measurement. DC link voltage measurement is required, all other voltage measurements are optional. |
||||
.dcLink |
DC link voltage measurement channel configuration. |
|||||
.channel |
string |
Desired ADC channel to sample. regex:adcChannel = |
||||
.signed |
boolean |
Determines if the ADC measurement is treated as a signed value relative to mid-scale (AVdd/2) or an unsigned value relative to AVss. |
||||
.a |
Phase A voltage measurement channel configuration. |
|||||
.channel |
string |
Desired ADC channel to sample. regex:adcChannel = |
||||
.signed |
boolean |
Determines if the ADC measurement is treated as a signed value relative to mid-scale (AVdd/2) or an unsigned value relative to AVss. |
||||
.b |
Phase B voltage measurement channel configuration. |
|||||
.channel |
string |
Desired ADC channel to sample. regex:adcChannel = |
||||
.signed |
boolean |
Determines if the ADC measurement is treated as a signed value relative to mid-scale (AVdd/2) or an unsigned value relative to AVss. |
||||
.c |
Phase C voltage measurement channel configuration. |
|||||
.channel |
string |
Desired ADC channel to sample. regex:adcChannel = |
||||
.signed |
boolean |
Determines if the ADC measurement is treated as a signed value relative to mid-scale (AVdd/2) or an unsigned value relative to AVss. |
||||
.absoluteReference |
map |
Absolute voltage reference channel configuration. |
||||
.nominal |
float |
V |
Nominal analog voltage (AVdd). |
|||
.channel |
string |
Desired ADC channel to sample. regex:adcChannel = |
||||
.signed |
boolean |
Determines if the ADC measurement is treated as a signed value relative to mid-scale (AVdd/2) or an unsigned value relative to AVss. |
||||
.other |
map |
ADC measurements supported by MCAF that don’t fit into the current or voltage categories. The ADC measurements in this category are optional. |
||||
.bridgeTemperature |
map |
Bridge temperature measurement channel configuration. |
||||
.offset |
float |
V |
Offset of bridge temperature measurement. |
|||
.gain |
float |
Gain of bridge temperature measurement. |
||||
.channel |
string |
Desired ADC channel to sample. regex:adcChannel = |
||||
.signed |
boolean |
Determines if the ADC measurement is treated as a signed value relative to mid-scale (AVdd/2) or an unsigned value relative to AVss. |
||||
.potentiometer |
map |
Potentiometer measurement channel configuration. |
||||
.inverted |
boolean |
Polarity of measurement. |
||||
.minimum |
\(0.0 \le x \le 1.0\) | Minimum measured voltage as a fraction of AVdd. Defaults to 0.0. |
||||
.maximum |
\(0.0 \le x \le 1.0\) | Maximum measured voltage as a fraction of AVdd. Defaults to 1.0. |
||||
.channel |
string |
Desired ADC channel to sample. regex:adcChannel = |
||||
.signed |
boolean |
Determines if the ADC measurement is treated as a signed value relative to mid-scale (AVdd/2) or an unsigned value relative to AVss. |
||||
.custom |
Custom ADC channel configuration. These ADC channels are not used by MCAF, and may be managed by the application. They are sampled at the same frequency (PWM frequency) as other MCAF ADC channels. The custom name of the channel must be a valid C identifier. |
|||||
.* |
key = regex:cStandardName = |
|||||
.pwm |
map |
3-phase PWM configuration. |
||||
.polarity |
map |
Polarity of the upper (PWMxH) and lower (PWMxL) PWM signals. |
||||
.upper |
Digital polarity. |
|||||
.lower |
Digital polarity. |
|||||
.generators |
map |
PWM generator to motor phase mapping. See device datasheet for which PWM generators are available on the selected device. |
||||
.a |
integer |
PWM generator number. See device datasheet for which PWM generators are available on the selected device. |
||||
.b |
integer |
PWM generator number. See device datasheet for which PWM generators are available on the selected device. |
||||
.c |
integer |
PWM generator number. See device datasheet for which PWM generators are available on the selected device. |
||||
.outputSwap |
map |
Swap the outputs of the upper (PWMxH) and lower (PWMxL) signals for each generator. |
||||
.a |
boolean |
Determines if the PWMxH and PWMxL signals are swapped. |
||||
.b |
boolean |
Determines if the PWMxH and PWMxL signals are swapped. |
||||
.c |
boolean |
Determines if the PWMxH and PWMxL signals are swapped. |
||||
.fault |
map |
PWM fault configuration. This signal will cause the PWM generators to shut down when the digital signal transitions (low or high, depending on the polarity configuration). |
||||
.polarity |
Digital polarity. |
|||||
.source |
string |
Fault source selection.
regex:faultSource = |
||||
.opamp |
map |
Internal op amp configuration. |
||||
.enabled |
list |
A list of which op amps are enabled. |
||||
.* |
\(1 \le n \le 3\) | |||||
.comparator |
map |
Internal comparator/DAC configuration. The comparator/DAC can be configured for the PWM fault source. |
||||
.source |
string |
Source that triggers the comparator output. regex:cmpTrigSource = |
||||
.inverted |
boolean |
Polarity of the comparator output. |
||||
.threshold |
\(0.0 \le x \le 1.0\) | Fraction of AVDD |
Trigger threshold as a fraction of AVdd. |
|||
.gpio |
GPIO configuration. |
|||||
.* |
key = regex:cStandardName = |
|||||
.qei |
map |
QEI configuration. Must be configured to use the QEI estimator. See device datasheet for which pins are available on the selected device. |
||||
.pins |
map |
QEI pin configuration. |
||||
.A |
string |
GPIO pin name. See device datasheet for which pins are available on the selected device. regex:pin = |
||||
.B |
string |
GPIO pin name. See device datasheet for which pins are available on the selected device. regex:pin = |
||||
.Z |
string |
GPIO pin name. See device datasheet for which pins are available on the selected device. regex:pin = |
||||
.uart |
map |
UART configuration. Must be configured if real-time debugging is desired. See device datasheet for which pins are available on the selected device. |
||||
.pins |
map |
UART pin configuration. |
||||
.RX |
string |
GPIO pin name. See device datasheet for which pins are available on the selected device. regex:pin = |
||||
.TX |
string |
GPIO pin name. See device datasheet for which pins are available on the selected device. regex:pin = |
||||
Referenced types | ||||||
[generator] |
integer |
PWM generator number. See device datasheet for which PWM generators are available on the selected device. |
||||
[pin] |
string |
GPIO pin name. See device datasheet for which pins are available on the selected device. regex:pin = |
||||
[adcChannelCustom] |
map |
|||||
.channel |
string |
Desired ADC channel to sample. regex:adcChannel = |
||||
.signed |
boolean |
Determines if the ADC measurement is treated as a signed value relative to mid-scale (AVdd/2) or an unsigned value relative to AVss. |
||||
[adcChannelVoltage] |
map |
|||||
.channel |
string |
Desired ADC channel to sample. regex:adcChannel = |
||||
.signed |
boolean |
Determines if the ADC measurement is treated as a signed value relative to mid-scale (AVdd/2) or an unsigned value relative to AVss. |
||||
[digitalPolarity] |
enum |
Digital polarity. Options: 'active-high' 'active-low' |
||||
[gpio] |
map |
|||||
.pin |
string |
GPIO pin name. See device datasheet for which pins are available on the selected device. regex:pin = |
||||
.direction |
enum |
Direction of GPIO. Options: 'input' 'output' |
||||
.polarity |
Digital polarity. |
|||||
.openDrain |
boolean |
Open drain pin configuration. |
||||
.weakPullUp |
boolean |
Enable internal weak pull-up resistor. |
||||
.weakPullDown |
boolean |
Enable internal weak pull-down resistor. |
||||
.startHigh |
boolean |
Start condition of pin (LATx). |
||||
[generatorOutputsSwap] |
boolean |
Determines if the PWMxH and PWMxL signals are swapped. |
||||
[rangeWithDefault] |
map |
|||||
.minimum |
\(x \ge 0.0\) | Minimum allowable value. |
||||
.maximum |
\(x \ge 0.0\) | Maximum allowable value. |
||||
.default |
\(x \ge 0.0\) | Default value. |
||||
[adcChannelCurrent] |
map |
Current measurement ADC channel configuration. |
||||
.channel |
string |
Desired ADC channel to sample. regex:adcChannel = |
||||
.inverted |
boolean |
Determines if the ADC channel measurement is inverted. |
||||
.signed |
boolean |
Determines if the ADC measurement is treated as a signed value relative to mid-scale (AVdd/2) or an unsigned value relative to AVss. |