Motor Evaluation Kit NEVC-MCTRL-100-t01-1.0.0
Firmware for NEVB-MCTRL-100-01 for trapezoidal control of BLDC motors using Hall-effect sensors
|
SCPI implementation source file. More...
#include "scpi.h"
Go to the source code of this file.
Functions | |
static scpi_result_t | MeasureMotorSpeed (scpi_t *context) |
Measures the motor speed. | |
static scpi_result_t | MeasureMotorCurrent (scpi_t *context) |
Measures and returns the motor's current. | |
static scpi_result_t | MeasureMotorDirection (scpi_t *context) |
Measures and reports the current direction of the motor. | |
static scpi_result_t | MeasureGateVoltage (scpi_t *context) |
Measures and returns the gate voltage of the motor. | |
static scpi_result_t | ConfigureMotorDutyCycleSource (scpi_t *context) |
Configures the motor's speed input source. | |
static scpi_result_t | ConfigureMotorDutyCycle (scpi_t *context) |
Configures the motor's speed input by changing the duty cycle. | |
static scpi_result_t | MeasureGateDutyCycle (scpi_t *context) |
Measures and returns the gate PWM duty cycle. | |
static scpi_result_t | ConfigureMotorEnable (scpi_t *context) |
Configures the motor's enable state. | |
static scpi_result_t | GetConfigureMotorEnable (scpi_t *context) |
Retrieves the current motor enable state. | |
static scpi_result_t | ConfigureMotorDirection (scpi_t *context) |
Sets the motor's direction based on the input parameter. | |
static scpi_result_t | GetConfigureMotorDirection (scpi_t *context) |
Retrieves the configured direction of the motor. | |
static scpi_result_t | ConfigureMotorFrequency (scpi_t *context) |
Configures the motor's operating frequency. | |
static scpi_result_t | GetConfigureMotorFrequency (scpi_t *context) |
Retrieves the configured motor frequency. | |
static scpi_result_t | ConfigureMotorDeadTime (scpi_t *context) |
Configures the motor's dead time. | |
static scpi_result_t | GetConfigureMotorDeadTime (scpi_t *context) |
Retrieves the configured motor dead time. | |
size_t | SCPI_Write (scpi_t *context, const char *data, size_t len) |
Writes data to the SCPI interface. | |
scpi_result_t | SCPI_Flush (scpi_t *context) |
Flushes the Serial interface buffer. | |
int | SCPI_Error (scpi_t *context, int_fast16_t err) |
Handles SCPI errors and outputs them to the Serial interface. | |
scpi_result_t | SCPI_Control (scpi_t *context, scpi_ctrl_name_t ctrl, scpi_reg_val_t val) |
Handles control messages for the SCPI interface (dummy) | |
scpi_result_t | SCPI_Reset (scpi_t *context) |
Resets the SCPI context. | |
Variables | |
const scpi_choice_def_t | motorDirections [] |
Array or enumeration of possible motor directions. | |
const scpi_command_t | scpi_commands [] |
Array of SCPI commands. | |
scpi_interface_t | scpi_interface |
SCPI interface structure. | |
char | scpi_input_buffer [64] |
SCPI input buffer. | |
scpi_error_t | scpi_error_queue_data [4] |
SCPI error queue data array. | |
scpi_t | scpi_context |
SCPI context structure. | |
SCPI implementation source file.
This file contains all function callbacks and type definitions necessary for SCPI implementation.
This file depends on the base SCPI parser library v2 (commit #4e87990) by Jan Breuer which was then ported by Scott Feister to the Arduino IDE, SCPI Parser Arduino Library.
Further modifications were made to the base library to allow for memory optimisation and support for the avr-gcc compiler.
Definition in file scpi.cpp.
|
static |
Configures the motor's dead time.
This function sets the motor's dead time based on the input parameter. It validates the dead time range, updates the motor configuration, and reinitializes timers after ensuring the motor is stopped.
context | The SCPI context |
Definition at line 444 of file scpi.cpp.
|
static |
Sets the motor's direction based on the input parameter.
This function reads a direction parameter ('FORWard' or 'REVErse') and sets the motor's direction accordingly by manipulating the DIRECTION_COMMAND_PIN on PORTD.
In remote mode, the DIRECTION_COMMAND_PIN is configured as an output as opposed to an input. Setting or clearing the pin triggers the relevant software interrupt as it would in normal operation.
context | The SCPI context |
Definition at line 324 of file scpi.cpp.
|
static |
Configures the motor's speed input by changing the duty cycle.
context | The SCPI context |
Definition at line 175 of file scpi.cpp.
|
static |
Configures the motor's speed input source.
This function reads a boolean parameter from the SCPI command and sets the motor's source corresponding to SPEED_INPUT_SOURCE_LOCAL and SPEED_INPUT_SOURCE_REMOTE.
context | The SCPI context |
Definition at line 140 of file scpi.cpp.
|
static |
Configures the motor's enable state.
This function reads a boolean parameter from the SCPI command and sets the motor's enable state accordingly.
In remote mode, the ENABLE_PIN is configured as an output as opposed to an input. The motor is then enabled or disabled by setting or clearing the ENABLE_PIN on the PORTD register, which triggers the relevant software interrupt as it would in normal operation.
context | The SCPI context |
Definition at line 268 of file scpi.cpp.
|
static |
Configures the motor's operating frequency.
This function sets the motor's operating frequency based on the input parameter. It validates the frequency range, updates the motor configuration, and reinitializes timers after ensuring the motor is stopped.
context | The SCPI context |
Definition at line 381 of file scpi.cpp.
|
static |
Retrieves the configured motor dead time.
This function queries the current dead time configuration of the motor and returns it as a double value.
context | The SCPI context |
Definition at line 489 of file scpi.cpp.
|
static |
Retrieves the configured direction of the motor.
This function queries the desired direction of the motor and returns a textual representation ('FORWard' or 'REVErse') based on the motor's desired direction setting.
context | The SCPI context |
Definition at line 360 of file scpi.cpp.
|
static |
Retrieves the current motor enable state.
This function queries the current enable state of the motor and returns it as a boolean value.
context | The SCPI context |
Definition at line 303 of file scpi.cpp.
|
static |
Retrieves the configured motor frequency.
This function queries the current frequency configuration of the motor and returns it as a double value.
context | The SCPI context |
Definition at line 427 of file scpi.cpp.
|
static |
Measures and returns the gate PWM duty cycle.
context | The SCPI context |
Definition at line 234 of file scpi.cpp.
|
static |
Measures and returns the gate voltage of the motor.
This function calculates the gate voltage of the motor using the gate voltage reference value and returns it in Volts.
context | The SCPI context |
Definition at line 122 of file scpi.cpp.
|
static |
Measures and returns the motor's current.
This function calculates the current being used by the motor and returns it in Amperes.
context | The SCPI context |
Definition at line 78 of file scpi.cpp.
|
static |
Measures and reports the current direction of the motor.
This function checks the current direction of the motor and returns a textual representation ('FORWard', 'REVErse', or 'UNKNown') based on the motor's actual direction.
context | The SCPI context |
Definition at line 95 of file scpi.cpp.
|
static |
Measures the motor speed.
This function calculates and returns the motor speed in revolutions per minute (RPM).
context | The SCPI context |
Definition at line 55 of file scpi.cpp.
scpi_result_t SCPI_Control | ( | scpi_t * | context, |
scpi_ctrl_name_t | ctrl, | ||
scpi_reg_val_t | val ) |
Handles control messages for the SCPI interface (dummy)
This function processes control messages such as SRQ (Service Request) or other control signals. It outputs relevant information to the Serial interface. Used as a callback in the SCPI interface structure.
context | The SCPI context |
ctrl | The control name/type |
val | The control value |
Definition at line 605 of file scpi.cpp.
int SCPI_Error | ( | scpi_t * | context, |
int_fast16_t | err ) |
Handles SCPI errors and outputs them to the Serial interface.
This function processes and displays SCPI error messages. It is used as a callback in the SCPI interface structure for error handling.
context | The SCPI context |
err | The error code |
Definition at line 581 of file scpi.cpp.
scpi_result_t SCPI_Flush | ( | scpi_t * | context | ) |
Flushes the Serial interface buffer.
This function ensures that all pending Serial data is transmitted. It acts as a callback for the SCPI interface structure.
context | The SCPI context |
Definition at line 565 of file scpi.cpp.
scpi_result_t SCPI_Reset | ( | scpi_t * | context | ) |
Resets the SCPI context.
This function is called to reset the SCPI environment. It outputs a reset message to the Serial interface and is used as a callback in the SCPI interface structure.
context | The SCPI context |
Definition at line 622 of file scpi.cpp.
size_t SCPI_Write | ( | scpi_t * | context, |
const char * | data, | ||
size_t | len ) |
Writes data to the SCPI interface.
This function is responsible for writing data to the Serial interface. It is used as a callback in the SCPI interface structure.
context | The SCPI context |
data | Pointer to the data to be written |
len | Length of the data to be written |
Definition at line 549 of file scpi.cpp.
const scpi_choice_def_t motorDirections[] |
Array or enumeration of possible motor directions.
This defines the possible directions in which the motor can move, i.e. forward, reverse. It is used in SCPI commands to set or query the motor's current direction. Each direction is typically associated with a specific command or numeric value.
Definition at line 40 of file scpi.cpp.
const scpi_command_t scpi_commands[] |
Array of SCPI commands.
This array contains the definitions of all SCPI commands that the system recognizes. Each command is defined with its pattern, callback function, and associated context. The array is stored in program memory (PROGMEM) to optimize memory usage.
Definition at line 504 of file scpi.cpp.
scpi_t scpi_context |
scpi_error_t scpi_error_queue_data[4] |
SCPI error queue data array.
Array for storing SCPI errors. Its size is defined by SCPI_ERROR_QUEUE_SIZE.
char scpi_input_buffer[64] |
SCPI input buffer.
Array for storing incoming SCPI commands. Its size is defined by SCPI_INPUT_BUFFER_LENGTH.
scpi_interface_t scpi_interface |
SCPI interface structure.
This structure defines the callbacks for various SCPI interface operations like error handling, writing to an output, control functions, flushing the output, and resetting the interface.
Definition at line 651 of file scpi.cpp.