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
Loading...
Searching...
No Matches
scpi.cpp File Reference

SCPI implementation source file. More...

#include "scpi.h"
Include dependency graph for scpi.cpp:

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.
 

Detailed Description

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.

Author
Nexperia: http://www.nexperia.com
Support Page
For additional support, visit: https://www.nexperia.com/support
Author
Aanas Sayed
Date
2024/03/08


Definition in file scpi.cpp.

Function Documentation

◆ ConfigureMotorDeadTime()

static scpi_result_t ConfigureMotorDeadTime ( scpi_t * context)
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.

Parameters
contextThe SCPI context
Returns
SCPI result code indicating success (SCPI_RES_OK) or error (SCPI_RES_ERR)

Definition at line 444 of file scpi.cpp.

445{
446 // Clear the enable pin
447 PORTD &= ~(1 << ENABLE_PIN);
448
449 uint32_t param;
450
451 // Read first parameter if present
452 if (!SCPI_ParamUInt32(context, &param, TRUE))
453 {
454 return SCPI_RES_ERR;
455 }
456 else
457 {
458 // Check if within range
459 if ((param < 350) | (param > 1875))
460 {
461 return SCPI_RES_ERR;
462 }
463
464 // Reload the config
466
467 // Wait until motor is stopped
468 while (faultFlags.motorStopped == FALSE)
469 {
470 ;
471 }
472
473 // Re-init timers
474 TimersInit();
475 }
476
477 return SCPI_RES_OK;
478}
#define ENABLE_PIN
Enable input pin.
Definition main.h:623
#define TRUE
TRUE constant value, defined to be compatible with comparisons.
Definition main.h:537
#define FALSE
FALSE constant value.
Definition main.h:535
volatile motorconfigs_t motorConfigs
Motor Configs.
Definition main.ino:90
volatile faultflags_t faultFlags
Fault flags placed in I/O space for fast access.
Definition main.ino:84
void TimersInit(void)
Initializes and synchronizes Timers.
Definition main.ino:405
uint8_t motorStopped
Is motor stopped?
Definition main.h:1005
uint16_t tim4DeadTime
Corresponding dead time for TIM4 output.
Definition main.h:1030
Here is the call graph for this function:

◆ ConfigureMotorDirection()

static scpi_result_t ConfigureMotorDirection ( scpi_t * context)
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.

Parameters
contextThe SCPI context
Returns
SCPI result code indicating success (SCPI_RES_OK) or error (SCPI_RES_ERR)

Definition at line 324 of file scpi.cpp.

325{
326 int32_t param;
327
328 /* read first parameter if present */
329 if (!SCPI_ParamChoice(context, motorDirections, &param, TRUE))
330 {
331 return SCPI_RES_ERR;
332 }
333 else
334 {
335 if (param)
336 {
337 // Set the direction pin if param is 1
338 PORTD |= (1 << DIRECTION_COMMAND_PIN);
339 }
340 else
341 {
342 // Clear the direction pin if param is 0
343 PORTD &= ~(1 << DIRECTION_COMMAND_PIN);
344 }
345 }
346
347 return SCPI_RES_OK;
348}
#define DIRECTION_COMMAND_PIN
Pin where direction command input is located.
Definition main.h:621
const scpi_choice_def_t motorDirections[]
Array or enumeration of possible motor directions.
Definition scpi.cpp:40

◆ ConfigureMotorDutyCycle()

static scpi_result_t ConfigureMotorDutyCycle ( scpi_t * context)
static

Configures the motor's speed input by changing the duty cycle.

Parameters
contextThe SCPI context
Returns
SCPI result code indicating success (SCPI_RES_OK) or error (SCPI_RES_ERR)

Definition at line 175 of file scpi.cpp.

176{
177 double param;
178
179 // Read first parameter if present
180 if (!SCPI_ParamDouble(context, &param, TRUE))
181 {
182 return SCPI_RES_ERR;
183 }
184 else
185 {
186 // Check if within range
187 if ((param < 0.0) | (param > 100.0))
188 {
189 return SCPI_RES_ERR;
190 }
191
192 speedInput = (param * SPEED_CONTROLLER_MAX_INPUT) / 100;
193 }
194
195 return SCPI_RES_OK;
196}
#define SPEED_CONTROLLER_MAX_INPUT
Maximum Speed Reference Input.
Definition main.h:674
volatile uint8_t speedInput
The most recent "speed" input measurement.
Definition main.ino:125

◆ ConfigureMotorDutyCycleSource()

static scpi_result_t ConfigureMotorDutyCycleSource ( scpi_t * context)
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.

Parameters
contextThe SCPI context
Returns
SCPI result code indicating success (SCPI_RES_OK) or error (SCPI_RES_ERR)

Definition at line 140 of file scpi.cpp.

144{
145 scpi_bool_t param;
146
147 /* read first parameter if present */
148 if (!SCPI_ParamBool(context, &param, TRUE))
149 {
150 return SCPI_RES_ERR;
151 }
152 else
153 {
154 if (param == SPEED_INPUT_SOURCE_LOCAL)
155 {
157 }
158 else
159 {
161 speedInput = 0;
162 }
163 }
164
165 return SCPI_RES_OK;
166}
#define SPEED_INPUT_SOURCE_LOCAL
Speed input source - Local or speed input pin.
Definition main.h:629
#define SPEED_INPUT_SOURCE_REMOTE
Speed input source - Remote input.
Definition main.h:631
uint8_t speedInputSource
SpeedInput source select (only for remote mode).
Definition main.h:1032

◆ ConfigureMotorEnable()

static scpi_result_t ConfigureMotorEnable ( scpi_t * context)
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.

Parameters
contextThe SCPI context
Returns
SCPI result code indicating success (SCPI_RES_OK) or error (SCPI_RES_ERR)

Definition at line 268 of file scpi.cpp.

269{
270 scpi_bool_t param;
271
272 /* read first parameter if present */
273 if (!SCPI_ParamBool(context, &param, TRUE))
274 {
275 return SCPI_RES_ERR;
276 }
277 else
278 {
279 if (param)
280 {
281 // Set the enable pin
282 PORTD |= (1 << ENABLE_PIN);
283 }
284 else
285 {
286 // Clear the enable pin
287 PORTD &= ~(1 << ENABLE_PIN);
288 }
289 }
290
291 return SCPI_RES_OK;
292}

◆ ConfigureMotorFrequency()

static scpi_result_t ConfigureMotorFrequency ( scpi_t * context)
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.

Parameters
contextThe SCPI context
Returns
SCPI result code indicating success (SCPI_RES_OK) or error (SCPI_RES_ERR)

Definition at line 381 of file scpi.cpp.

382{
383 // Clear the enable pin
384 PORTD &= ~(1 << ENABLE_PIN);
385
386 uint32_t param;
387
388 // Read first parameter if present
389 if (!SCPI_ParamUInt32(context, &param, TRUE))
390 {
391 return SCPI_RES_ERR;
392 }
393 else
394 {
395 // Check if within range
396 if ((param < 7183) | (param > 100000))
397 {
398 return SCPI_RES_ERR;
399 }
400
401 // Reload the configs
402 motorConfigs.tim4Freq = param;
404
405 // Wait until motor is stopped
406 while (faultFlags.motorStopped == FALSE)
407 {
408 ;
409 }
410
411 // Re-init timers
412 TimersInit();
413 }
414
415 return SCPI_RES_OK;
416}
#define TIM4_TOP(tim4Freq)
Definition main.h:1059
uint16_t tim4Top
Corresponding TIM4 top value for TIM4 frequency.
Definition main.h:1028
uint32_t tim4Freq
TIM4 or gate switching frequency.
Definition main.h:1026
Here is the call graph for this function:

◆ GetConfigureMotorDeadTime()

static scpi_result_t GetConfigureMotorDeadTime ( scpi_t * context)
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.

Parameters
contextThe SCPI context
Returns
SCPI result code indicating success or failure

Definition at line 489 of file scpi.cpp.

490{
491 SCPI_ResultDouble(context, (double)motorConfigs.tim4DeadTime);
492
493 return SCPI_RES_OK;
494}

◆ GetConfigureMotorDirection()

static scpi_result_t GetConfigureMotorDirection ( scpi_t * context)
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.

Parameters
contextThe SCPI context
Returns
SCPI result code indicating success or failure

Definition at line 360 of file scpi.cpp.

361{
362 const char *name;
363
364 SCPI_ChoiceToName(motorDirections, motorFlags.desiredDirection, &name);
365
366 SCPI_ResultText(context, name);
367
368 return SCPI_RES_OK;
369}
volatile motorflags_t motorFlags
Motor control flags placed in I/O space for fast access.
Definition main.ino:76
uint8_t desiredDirection
The desired direction of rotation.
Definition main.h:989

◆ GetConfigureMotorEnable()

static scpi_result_t GetConfigureMotorEnable ( scpi_t * context)
static

Retrieves the current motor enable state.

This function queries the current enable state of the motor and returns it as a boolean value.

Parameters
contextThe SCPI context
Returns
SCPI result code indicating success or failure

Definition at line 303 of file scpi.cpp.

304{
305 SCPI_ResultBool(context, (scpi_bool_t)motorFlags.enable);
306
307 return SCPI_RES_OK;
308}
uint8_t enable
Is the motor enabled?
Definition main.h:985

◆ GetConfigureMotorFrequency()

static scpi_result_t GetConfigureMotorFrequency ( scpi_t * context)
static

Retrieves the configured motor frequency.

This function queries the current frequency configuration of the motor and returns it as a double value.

Parameters
contextThe SCPI context
Returns
SCPI result code indicating success or failure

Definition at line 427 of file scpi.cpp.

428{
429 SCPI_ResultDouble(context, (double)motorConfigs.tim4Freq);
430
431 return SCPI_RES_OK;
432}

◆ MeasureGateDutyCycle()

static scpi_result_t MeasureGateDutyCycle ( scpi_t * context)
static

Measures and returns the gate PWM duty cycle.

Parameters
contextThe SCPI context
Returns
SCPI result code indicating success or failure

Definition at line 234 of file scpi.cpp.

235{
236 if (motorFlags.enable == TRUE)
237 {
238 // Reading 16 bit register so disabling interrupts for atomic operation
239 cli();
240 uint16_t duty = 0xff & OCR4A;
241 duty |= (0x03 & TC4H) << 8;
242 sei();
243
244 SCPI_ResultDouble(context, ((double)duty / (double)motorConfigs.tim4Top * 100));
245 }
246 else
247 {
248 SCPI_ResultDouble(context, 0);
249 }
250
251 return SCPI_RES_OK;
252}

◆ MeasureGateVoltage()

static scpi_result_t MeasureGateVoltage ( scpi_t * context)
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.

Parameters
contextThe SCPI context
Returns
SCPI result code indicating success or failure

Definition at line 122 of file scpi.cpp.

123{
124 SCPI_ResultDouble(context, ((double)gateVref * 5 * (GATE_RTOP + GATE_RBOTTOM)) / ((double)1024 * GATE_RBOTTOM));
125
126 return SCPI_RES_OK;
127}
#define GATE_RBOTTOM
Bottom resistor value in the gate voltage potential divider.
Definition main.h:512
#define GATE_RTOP
Top resistor value in the gate voltage potential divider.
Definition main.h:492
volatile uint16_t gateVref
Gate voltage measurement (Register Value)
Definition main.ino:190

◆ MeasureMotorCurrent()

static scpi_result_t MeasureMotorCurrent ( scpi_t * context)
static

Measures and returns the motor's current.

This function calculates the current being used by the motor and returns it in Amperes.

Parameters
contextThe SCPI context
Returns
SCPI result code indicating success or failure

Definition at line 78 of file scpi.cpp.

79{
80 SCPI_ResultDouble(context, ((double)current * 5 * 1000000) / ((double)1024 * CURRENT_GAIN * CURRENT_SENSE_RESISTOR));
81
82 return SCPI_RES_OK;
83}
#define CURRENT_GAIN
Current Gain for Current Measurement.
Definition main.h:220
#define CURRENT_SENSE_RESISTOR
Current Sense Resistor Value.
Definition main.h:238
volatile uint16_t current
Current measurement (Register Value).
Definition main.ino:161

◆ MeasureMotorDirection()

static scpi_result_t MeasureMotorDirection ( scpi_t * context)
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.

Parameters
contextThe SCPI context
Returns
SCPI result code indicating success or failure

Definition at line 95 of file scpi.cpp.

96{
98 {
99 SCPI_ResultText(context, "UNKNown");
100 }
101 else
102 {
103 const char *name;
104
105 SCPI_ChoiceToName(motorDirections, motorFlags.actualDirection, &name);
106
107 SCPI_ResultText(context, name);
108 }
109
110 return SCPI_RES_OK;
111}
#define DIRECTION_UNKNOWN
Unknown direction flag value.
Definition main.h:579
uint8_t actualDirection
The actual direction of rotation.
Definition main.h:987

◆ MeasureMotorSpeed()

static scpi_result_t MeasureMotorSpeed ( scpi_t * context)
static

Measures the motor speed.

This function calculates and returns the motor speed in revolutions per minute (RPM).

Parameters
contextThe SCPI context
Returns
SCPI result code indicating successful operation

Definition at line 55 of file scpi.cpp.

56{
57 if (lastCommutationTicks == 0xffff)
58 {
59 SCPI_ResultDouble(context, 0);
60 }
61 else
62 {
63 SCPI_ResultDouble(context, ((motorConfigs.tim4Freq * 20) / (lastCommutationTicks * MOTOR_POLES)));
64 }
65
66 return SCPI_RES_OK;
67}
#define MOTOR_POLES
Number of poles in the motor.
Definition main.h:60
volatile uint16_t lastCommutationTicks
The number of 'ticks' between two hall sensor changes (store).
Definition main.ino:118

◆ SCPI_Control()

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.

Note
Dummy function implemented here.
Parameters
contextThe SCPI context
ctrlThe control name/type
valThe control value
Returns
SCPI result code indicating successful operation

Definition at line 605 of file scpi.cpp.

606{
607 (void)context;
608
609 return SCPI_RES_OK;
610}

◆ SCPI_Error()

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.

Parameters
contextThe SCPI context
errThe error code
Returns
Always returns 0

Definition at line 581 of file scpi.cpp.

582{
583 (void)context;
584#if (REMOTE_DEBUG_MODE == TRUE)
585 Serial.print(err);
586 Serial.print(", \"");
587 Serial.print(SCPI_ErrorTranslate(err));
588 Serial.println("\"");
589#endif
590 return 0;
591}

◆ SCPI_Flush()

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.

Parameters
contextThe SCPI context
Returns
SCPI result code indicating successful operation

Definition at line 565 of file scpi.cpp.

566{
567 (void)context;
568 Serial.flush();
569 return SCPI_RES_OK;
570}

◆ SCPI_Reset()

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.

Parameters
contextThe SCPI context
Returns
SCPI result code indicating successful operation

Definition at line 622 of file scpi.cpp.

623{
624 (void)context;
625
626 // Clear the enable pin
627 PORTD &= ~(1 << ENABLE_PIN);
628
629 // Wait until motor is stopped
630 while (faultFlags.motorStopped == FALSE)
631 {
632 ;
633 }
634
635 // Reset configurations
636 ConfigsInit();
637
638 // Re-init timers
639 TimersInit();
640
641 return SCPI_RES_OK;
642}
static void ConfigsInit(void)
Initializes motorConfigs.
Definition main.ino:320
Here is the call graph for this function:

◆ SCPI_Write()

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.

Parameters
contextThe SCPI context
dataPointer to the data to be written
lenLength of the data to be written
Returns
The number of bytes written

Definition at line 549 of file scpi.cpp.

550{
551 (void)context;
552 Serial.write(data, len);
553 return len;
554}

Variable Documentation

◆ motorDirections

const scpi_choice_def_t motorDirections[]
Initial value:
= {
{"FORWard", 0 },
{"REVErse", 1 },
{NULL, -1}
}

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.

40 {
41 {"FORWard", DIRECTION_FORWARD},
42 {"REVErse", DIRECTION_REVERSE},
43 SCPI_CHOICE_LIST_END /* termination of option list */
44};
#define DIRECTION_FORWARD
Forward direction flag value.
Definition main.h:575
#define DIRECTION_REVERSE
Reverse direction flag value.
Definition main.h:577

◆ scpi_commands

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.

504 {
505 /* IEEE Mandated Commands (SCPI std V1999.0 4.1.1) */
506 {"*CLS", SCPI_CoreCls, 0},
507 {"*IDN?", SCPI_CoreIdnQ, 0},
508 {"*RST", SCPI_CoreRst, 0},
509
510 /* Required SCPI commands (SCPI std V1999.0 4.2.1) */
511 {"SYSTem:ERRor[:NEXT]?", SCPI_SystemErrorNextQ, 0},
512 {"SYSTem:ERRor:COUNt?", SCPI_SystemErrorCountQ, 0},
513 {"SYSTem:VERSion?", SCPI_SystemVersionQ, 0},
514
515 /* Motor */
516 {"CONFigure:MOTOr:ENABle", ConfigureMotorEnable, 0},
517 {"CONFigure:MOTOr:ENABle?", GetConfigureMotorEnable, 0},
518#if (SPEED_CONTROL_METHOD == SPEED_CONTROL_OPEN_LOOP)
519 {"CONFigure:MOTOr:GATE:DUTYcycle:SOURce", ConfigureMotorDutyCycleSource, 0},
520 {"CONFigure:MOTOr:GATE:DUTYcycle", ConfigureMotorDutyCycle, 0},
521#else
522 {"CONFigure:MOTOr:SPEED:SOURce", ConfigureMotorSpeedSource, 0},
523 {"CONFigure:MOTOr:SPEED", ConfigureMotorSpeed, 0},
524#endif
525 {"CONFigure:MOTOr:GATE:FREQuency", ConfigureMotorFrequency, 0},
526 {"CONFigure:MOTOr:GATE:FREQuency?", GetConfigureMotorFrequency, 0},
527 {"CONFigure:MOTOr:GATE:DEADtime", ConfigureMotorDeadTime, 0},
528 {"CONFigure:MOTOr:GATE:DEADtime?", GetConfigureMotorDeadTime, 0},
529 {"CONFigure:MOTOr:DIREction", ConfigureMotorDirection, 0},
530 {"CONFigure:MOTOr:DIREction?", GetConfigureMotorDirection, 0},
531 {"MEASure:MOTOr:SPEEd?", MeasureMotorSpeed, 0},
532 {"MEASure:MOTOr:CURRent?", MeasureMotorCurrent, 0},
533 {"MEASure:MOTOr:DIREction?", MeasureMotorDirection, 0},
534 {"MEASure:MOTOr:GATE:VOLTage?", MeasureGateVoltage, 0},
535 {"MEASure:MOTOr:GATE:DUTYcycle?", MeasureGateDutyCycle, 0},
536
537 SCPI_CMD_LIST_END};
static scpi_result_t MeasureGateVoltage(scpi_t *context)
Measures and returns the gate voltage of the motor.
Definition scpi.cpp:122
static scpi_result_t MeasureMotorSpeed(scpi_t *context)
Measures the motor speed.
Definition scpi.cpp:55
static scpi_result_t GetConfigureMotorDeadTime(scpi_t *context)
Retrieves the configured motor dead time.
Definition scpi.cpp:489
static scpi_result_t GetConfigureMotorFrequency(scpi_t *context)
Retrieves the configured motor frequency.
Definition scpi.cpp:427
static scpi_result_t GetConfigureMotorDirection(scpi_t *context)
Retrieves the configured direction of the motor.
Definition scpi.cpp:360
static scpi_result_t MeasureMotorCurrent(scpi_t *context)
Measures and returns the motor's current.
Definition scpi.cpp:78
static scpi_result_t ConfigureMotorDeadTime(scpi_t *context)
Configures the motor's dead time.
Definition scpi.cpp:444
static scpi_result_t ConfigureMotorDirection(scpi_t *context)
Sets the motor's direction based on the input parameter.
Definition scpi.cpp:324
static scpi_result_t ConfigureMotorEnable(scpi_t *context)
Configures the motor's enable state.
Definition scpi.cpp:268
static scpi_result_t GetConfigureMotorEnable(scpi_t *context)
Retrieves the current motor enable state.
Definition scpi.cpp:303
static scpi_result_t ConfigureMotorDutyCycleSource(scpi_t *context)
Configures the motor's speed input source.
Definition scpi.cpp:140
static scpi_result_t ConfigureMotorFrequency(scpi_t *context)
Configures the motor's operating frequency.
Definition scpi.cpp:381
static scpi_result_t MeasureGateDutyCycle(scpi_t *context)
Measures and returns the gate PWM duty cycle.
Definition scpi.cpp:234
static scpi_result_t ConfigureMotorDutyCycle(scpi_t *context)
Configures the motor's speed input by changing the duty cycle.
Definition scpi.cpp:175
static scpi_result_t MeasureMotorDirection(scpi_t *context)
Measures and reports the current direction of the motor.
Definition scpi.cpp:95

◆ scpi_context

scpi_t scpi_context

SCPI context structure.

This structure holds the context for SCPI operations, encapsulating state and configuration information.

Definition at line 681 of file scpi.cpp.

◆ scpi_error_queue_data

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.

Definition at line 673 of file scpi.cpp.

◆ scpi_input_buffer

char scpi_input_buffer[64]

SCPI input buffer.

Array for storing incoming SCPI commands. Its size is defined by SCPI_INPUT_BUFFER_LENGTH.

Definition at line 665 of file scpi.cpp.

◆ scpi_interface

scpi_interface_t scpi_interface
Initial value:
= {
}
scpi_result_t SCPI_Reset(scpi_t *context)
Resets the SCPI context.
Definition scpi.cpp:622
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)
Definition scpi.cpp:605
size_t SCPI_Write(scpi_t *context, const char *data, size_t len)
Writes data to the SCPI interface.
Definition scpi.cpp:549
int SCPI_Error(scpi_t *context, int_fast16_t err)
Handles SCPI errors and outputs them to the Serial interface.
Definition scpi.cpp:581
scpi_result_t SCPI_Flush(scpi_t *context)
Flushes the Serial interface buffer.
Definition scpi.cpp:565

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.

651 {
652 /*.error = */ SCPI_Error,
653 /*.write = */ SCPI_Write,
654 /*.control = */ SCPI_Control,
655 /*.flush = */ SCPI_Flush,
656 /*.reset = */ SCPI_Reset,
657};