Motor Driver Evaluation Kit NEVB-MTR1-t01-1.1.0
Firmware for NEVB-MTR1-KIT1 for trapezoidal control of BLDC motors using Hall-effect sensors
Loading...
Searching...
No Matches
scpi.h File Reference

SCPI implementation header file. More...

#include "scpi_helper.h"
#include "config.h"
Include dependency graph for scpi.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MOTOR_DIRECTION_OPTIONS   2
 Motor direction options array.
 
#define INPUT_SOURCE_OPTIONS   2
 Motor direction options array.
 

Functions

void ScpiInit (void)
 Initializes the SCPI command parser and registers all supported commands.
 
void ScpiInput (Stream &interface)
 Processes incoming data from a serial interface for SCPI commands.
 

Variables

const SCPI_choice_def_t motorDirections [2]
 Number of motor direction options.
 
const SCPI_choice_def_t inputSources [2]
 Number of speed input source options.
 
SCPI_Parser scpiParser
 Speed input source options array.
 

Detailed Description

SCPI implementation header file.

This file contains the command definitions for the SCPI parser to recognize and execute.

Most of this code was originally written by Diego González Chávez as part of the Vrekrer SCPI Parser project.

It has been merged into the main codebase for customization and linking limitations of the Arduino IDE.

Author
Nexperia: http://www.nexperia.com
Support Page
For additional support, visit: https://www.nexperia.com/support
Author
Aanas Sayed
Date
2025/04/21


Definition in file scpi.h.

Macro Definition Documentation

◆ INPUT_SOURCE_OPTIONS

#define INPUT_SOURCE_OPTIONS   2

Motor direction options array.

Definition at line 39 of file scpi.h.

◆ MOTOR_DIRECTION_OPTIONS

#define MOTOR_DIRECTION_OPTIONS   2

Motor direction options array.

Definition at line 35 of file scpi.h.

Function Documentation

◆ ScpiInit()

void ScpiInit ( void )

Initializes the SCPI command parser and registers all supported commands.

This function sets up the SCPI parser instance and registers the core IEEE mandated commands, required SCPI commands, and the custom motor control and measurement commands.

Definition at line 71 of file scpi.cpp.

72{
73 /* IEEE Mandated Commands (SCPI std V1999.0 4.1.1) */
74 // "*CLS" and "*RST" are not supported
75 scpiParser.RegisterCommand(F("*IDN?"), &ScpiCoreIdnQ);
76
77 /* Required SCPI commands (SCPI std V1999.0 4.2.1) */
78 // "SYSTem:VERSion?" and "SYSTem:ERRor:NEXT?" are not supported
79 scpiParser.SetCommandTreeBase(F("SYSTem"));
80 scpiParser.RegisterCommand(F(":ERRor?"), &ScpiSystemErrorNextQ);
81 scpiParser.RegisterCommand(F(":ERRor:COUNt?"), &ScpiSystemErrorCountQ);
82
83 /* Motor Configuration Commands */
84 scpiParser.SetCommandTreeBase(F("CONFigure"));
85 scpiParser.RegisterCommand(F(":ENABle"), &ConfigureMotorEnable);
86 scpiParser.RegisterCommand(F(":ENABle?"), &GetMotorEnable);
87#if (SPEED_CONTROL_METHOD == SPEED_CONTROL_OPEN_LOOP)
88 scpiParser.RegisterCommand(F(":DUTYcycle:SOURce"), &ConfigureMotorDutyCycleSource);
89 scpiParser.RegisterCommand(F(":DUTYcycle:SOURce?"), &GetConfigureMotorDutyCycleSource);
90 scpiParser.RegisterCommand(F(":DUTYcycle"), &ConfigureMotorDutyCycle);
91#else
92 scpiParser.RegisterCommand(F(":SPEED:SOURce"), &ConfigureMotorSpeedSource);
93 scpiParser.RegisterCommand(F(":SPEED:SOURce?"), &GetMotorSpeedSource);
94 scpiParser.RegisterCommand(F(":SPEED"), &ConfigureMotorSpeed);
95#endif
96 scpiParser.RegisterCommand(F(":FREQuency"), &ConfigureMotorFrequency);
97 scpiParser.RegisterCommand(F(":FREQuency?"), &GetConfigureMotorFrequency);
98 scpiParser.RegisterCommand(F(":DIREction"), &ConfigureMotorDirection);
99 scpiParser.RegisterCommand(F(":DIREction?"), &GetConfigureMotorDirection);
100
101 /* Motor Measurement Commands */
102 scpiParser.SetCommandTreeBase(F("MEASure"));
103 scpiParser.RegisterCommand(F(":SPEEd?"), &MeasureMotorSpeed);
104 scpiParser.RegisterCommand(F(":CURRent:IBUS?"), &MeasureMotorCurrentVBus);
105 scpiParser.RegisterCommand(F(":CURRent:IPHU?"), &MeasureMotorCurrentPhaseU);
106 scpiParser.RegisterCommand(F(":CURRent:IPHV?"), &MeasureMotorCurrentPhaseV);
107 scpiParser.RegisterCommand(F(":CURRent:IPHW?"), &MeasureMotorCurrentPhaseW);
108 scpiParser.RegisterCommand(F(":VOLTage?"), &MeasureMotorVoltage);
109 scpiParser.RegisterCommand(F(":DIREction?"), &MeasureMotorDirection);
110 scpiParser.RegisterCommand(F(":DUTYcycle?"), &MeasureGateDutyCycle);
111}
static void GetConfigureMotorDirection(SCPI_C commands, SCPI_P parameters, Stream &interface)
Retrieves the configured direction of the motor.
Definition scpi.cpp:480
static void GetConfigureMotorDutyCycleSource(SCPI_C commands, SCPI_P parameters, Stream &interface)
Retrieves the configured motor's duty cycle source.
Definition scpi.cpp:307
static void MeasureMotorCurrentPhaseV(SCPI_C commands, SCPI_P parameters, Stream &interface)
Measures and returns the motor's phase V current.
Definition scpi.cpp:553
static void ScpiSystemErrorNextQ(SCPI_C commands, SCPI_P parameters, Stream &interface)
Implements the SYSTem:ERRor? (System Error Next Query) command.
Definition scpi.cpp:179
static void MeasureMotorSpeed(SCPI_C commands, SCPI_P parameters, Stream &interface)
Measures the motor speed.
Definition scpi.cpp:498
static void MeasureMotorDirection(SCPI_C commands, SCPI_P parameters, Stream &interface)
Measures and reports the current direction of the motor.
Definition scpi.cpp:585
static void ScpiSystemErrorCountQ(SCPI_C commands, SCPI_P parameters, Stream &interface)
Implements the SYSTem:ERRor:COUNt? (System Error Count Query) command.
Definition scpi.cpp:163
static void MeasureMotorCurrentPhaseU(SCPI_C commands, SCPI_P parameters, Stream &interface)
Measures and returns the motor's phase U current.
Definition scpi.cpp:537
static void MeasureMotorCurrentVBus(SCPI_C commands, SCPI_P parameters, Stream &interface)
Measures and returns the motor's VBUS current.
Definition scpi.cpp:521
static void ConfigureMotorEnable(SCPI_C commands, SCPI_P parameters, Stream &interface)
Configures the motor's enable state.
Definition scpi.cpp:234
static void ScpiCoreIdnQ(SCPI_C commands, SCPI_P parameters, Stream &interface)
Implements the *IDN? (Identification Query) command.
Definition scpi.cpp:138
static void GetConfigureMotorFrequency(SCPI_C commands, SCPI_P parameters, Stream &interface)
Retrieves the configured motor frequency.
Definition scpi.cpp:425
static void ConfigureMotorDutyCycleSource(SCPI_C commands, SCPI_P parameters, Stream &interface)
Configures the motor's speed input source.
Definition scpi.cpp:268
static void GetMotorEnable(SCPI_C commands, SCPI_P parameters, Stream &interface)
Retrieves the current motor enable state.
Definition scpi.cpp:214
static void ConfigureMotorDutyCycle(SCPI_C commands, SCPI_P parameters, Stream &interface)
Configures the motor's speed input by setting the duty cycle.
Definition scpi.cpp:338
static void MeasureMotorCurrentPhaseW(SCPI_C commands, SCPI_P parameters, Stream &interface)
Measures and returns the motor's phase W current.
Definition scpi.cpp:569
static void ConfigureMotorDirection(SCPI_C commands, SCPI_P parameters, Stream &interface)
Sets the motor's direction based on the input parameter.
Definition scpi.cpp:445
static void MeasureMotorVoltage(SCPI_C commands, SCPI_P parameters, Stream &interface)
Measures and returns the VBUS voltage of the motor.
Definition scpi.cpp:609
SCPI_Parser scpiParser
Speed input source options array.
Definition scpi.cpp:62
static void MeasureGateDutyCycle(SCPI_C commands, SCPI_P parameters, Stream &interface)
Measures and returns the gate PWM duty cycle as a percentage.
Definition scpi.cpp:626
static void ConfigureMotorFrequency(SCPI_C commands, SCPI_P parameters, Stream &interface)
Configures the motor's operating frequency.
Definition scpi.cpp:386
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ScpiInput()

void ScpiInput ( Stream & interface)

Processes incoming data from a serial interface for SCPI commands.

This function takes a Stream object (like Serial) and processes any received data, looking for complete SCPI commands terminated by a newline character. It then passes the command to the SCPI parser for execution.

Parameters
interfaceThe serial stream interface to read commands from.

Definition at line 122 of file scpi.cpp.

123{
124 scpiParser.ProcessInput(interface, SCPI_CMD_TERM);
125}
#define SCPI_CMD_TERM
Command termination character used to identify the end of a SCPI command.
Here is the caller graph for this function:

Variable Documentation

◆ inputSources

const SCPI_choice_def_t inputSources[2]
extern

Number of speed input source options.

Number of speed input source options.

This array is used by the SCPI parser to interpret and represent the source of the motor's speed or duty cycle control ('LOCA' for local, 'REMO' for remote). Each entry associates a textual representation with a numerical value (e.g., SPEED_INPUT_SOURCE_LOCAL, SPEED_INPUT_SOURCE_REMOTE).

Definition at line 665 of file scpi.cpp.

665 {
666 {"LOCA", "l", SPEED_INPUT_SOURCE_LOCAL},
667 {"REMO", "te", SPEED_INPUT_SOURCE_REMOTE},
668};
#define SPEED_INPUT_SOURCE_LOCAL
Speed input source - Local or speed input pin.
Definition config.h:763
#define SPEED_INPUT_SOURCE_REMOTE
Speed input source - Remote input.
Definition config.h:765

◆ motorDirections

const SCPI_choice_def_t motorDirections[2]
extern

Number of motor direction options.

Number of motor direction options.

This array is used by the SCPI parser to interpret and represent the motor's direction ('FORW' for forward, 'REVE' for reverse). Each entry in the array associates a textual representation with a numerical value defined elsewhere (e.g., DIRECTION_FORWARD, DIRECTION_REVERSE).

Definition at line 652 of file scpi.cpp.

652 {
653 {"FORW", "ard", DIRECTION_FORWARD},
654 {"REVE", "rse", DIRECTION_REVERSE},
655};
#define DIRECTION_FORWARD
Forward direction flag value.
Definition config.h:699
#define DIRECTION_REVERSE
Reverse direction flag value.
Definition config.h:701

◆ scpiParser

SCPI_Parser scpiParser
extern

Speed input source options array.

Definition at line 62 of file scpi.cpp.