CWRI
CWRITE writes data to an opened serial interface or to a loaded external module of type LD_EXT_OBJ. In a loaded external module of type LD_EXT_FCT, CWRITE calls a function.
CWRITE Writes a command to the command channel.
CWRITE triggers a premature run stop.
CWRITE (Handle or $CMD, State, Mode, Format, Var1 <, ..., Var10>)
Handle/$CMD
Type: INT
Handle: A variable transferred from COPEN to WRITE that identifies a channel.
$CMD: A predefined variable used to write to the command channel
State: Type: STATE_T
Automatically returns to WRITE state
Mode : Type: INT
Type: MODUS_T
To write mode, the mode must be initialized.
Format: Type: CHAR[]
Converts Var variables before writing them to a string. A format must be specified for each Var variable.
Var:
The variable whose data is written to the string. Each statement can have up to 10 variables.
Write Mode
The writing mode is determined by a variable of type MODUS_T. MODUS_T is a predefined enumeration type:
ENUM MODUS_T SYNC, ASYNC, ABS, COND, SEQ For CWRITE, only SYNC and ASYNC are relevant:
SYNC
The statement is considered executed once the partner controller has fetched the transmitted data from the receive buffer.
ASYNC
When writing external modules of type LD_EXT_FCT, ASYNC mode is not allowed!
The following applies to all other channels: The statement is considered executed as soon as the data arrives in the receive buffer of the partner controller.
-
Better than SYNC: program execution speed is faster.
-
Disadvantages compared to SYNC: Possible data loss.
Other Values
If mode has a value other than SYNC or ASYNC, the write is performed in SYNC mode by default.
For example:
CWRITE($CMD,STAT,MODE,"RUN /R1/CELL()") program executes CELL program
$CMD
Through the command channel $CMD
CWRITE can transfer statements to the program interpreter via the command channel. Example: starting a program with RUN and stopping it with STOP.
Communicate with command channel $CMD
Command channel: start, stop and deselect programs
Program A6.SRC will start, stop and deselect via the command channel. This is done with the following program lines in the SUB file.
DECL STATE_T STAT
DECL MODUS_T MODE
MODE=#SYNC
...
;select prog A6()
;to start the program the START-button or
;an external start-signal is needed
IF $FLAG[1]==TRUE THEN
CWRITE($CMD,STAT,MODE,"RUN/R1/A6()") Run the program
$FLAG[1]=FALSE
ENDIF
;stop program A6()
IF $FLAG[2]==TRUE THEN
CWRITE($CMD,STAT,MODE,"STOP 1") program stops
$FLAG[2]=FALSE
ENDIF
;cel program A6()
IF $FLAG[3]==TRUE THEN
CWRITE($CMD,STAT,MODE,"CANCEL 1") exits the program
$FLAG[3]=FALSE
ENDIF
Conversion example:
Example 1
The value of the integer variable VI is transmitted in decimal and hexadecimal ASCII representation. The first CWRITE statement transmits the characters 123. The second CWRITE statement transmits the characters 7B.
INT VI
VI=123
CWRITE(HANDLE,SW_T,MW_T,"%d",VI)
CWRITE(HANDLE,SW_T,MW_T,"%x",VI)
Example 2
The value of an integer variable VI is transmitted in binary representation:
INT VI
VI=123
CWRITE(HANDLE,SW_T,MW_T,"%r",VI)
Example 3
Transfer all array elements of an array:
REAL [10]
CWRITE(HANDLE,SW_T,MW_T,"%r",VR[])
When using the "%r" format, the system does not check whether the variable or array element has been initialized. Random values are transferred for array elements that have not been initialized.
Example 4
The first five array elements of the array are transmitted in binary representation:
REAL VR[10]
CWRITE(HANDLE,SW_T,MW_T,"%.5r",VR[])
The 20 bytes are transmitted in binary representation.
Example 5
Transfer all array elements up to the first uninitialized element:
CHAR VS[100]
CWRITE(HANDLE,SW_T,MW_T,"%s",VS[])
Example 6
Transfer the first 50 array elements:
CHAR VS[100]
CWRITE(HANDLE,SW_T,MW_T,"%s",VS[])
Example 7
The internal value of ENUM constants is transmitted in ASCII notation. The corresponding number is:
DECL ENUM_TYPE E
CWRITE(HANDLE,SW_T,MW_T,"%d",E)
Example 8
Two REAL values are transferred together with additional text:
REAL V1,V2
V1=3.97
V2=-27.3
CWRITE(...,...,...,"value1=%+#07.3f value2=+#06.2f",V1,V2)
The following data is transmitted:
value1=+03.970
value2=-27.30
CWRITE and the Command Interface
CELL.SRC can be selected from the SPS.SUB program by means of the CWRITE statement and RUN. The call is effective only on a cold start.
CWRITE can transfer statements to the interpreter via the command channel $CMD. In addition to interpreter and system submissions, extended submissions can also be used for this purpose in multi-submission mode.
The meaning of the following commands has changed compared to single commit mode:
-
RUN[interpreter ID]
-
STOP[interpreter ID]
-
Reset [interpreter ID]
-
Cancel [Interpreter ID]
Interpreter ID:
0: all commit interpreters
1: Robot translation
2: System submission interpreter
3: Extended Submission Interpreter 1
4: Extended Submission Interpreter 2
…
9: Extended Submission Interpreter 7
Additionally, RUN is extended with the optional element [> interpreter ID]. CWRITE ($CMD, STAT, MODE, "RUN/R1/CELL()") Behavior in single submission mode: Starts the program CELL(). Since CELL() is an SRC program, it is started in the robot interpreter. Behavior in multiple submission mode: Same as in single submission mode. This program line can be used for system submissions or extended submissions. CWRITE ($CMD, STAT, MODE, "RUN/R1/SPS()") Behavior in single submission mode: Starts the program SPS(). Since SPS() is a SUB program, it is started in the system submission interpreter (= submission interpreter only in single submission mode). Behavior in multiple submission mode: Starts the program SPS(). Since SPS() is a SUB program, it is started in the system submission interpreter.
CWRITE ($CMD, STAT, MODE, "STOP 0")
This program line is only meaningful in robot programs. Behavior in single-submission mode: Stops the system submission interpreter. Behavior in multi-submission mode: Stops all running submission interpreters.
CWRITE ($CMD, STAT, MODE, "CANCEL 0")
Behavior in single-submission mode: Deselects the system submission interpreter. Behavior in multiple-submission mode: Deselects all submitted interpreters. CWRITE ($CMD, STAT, MODE, "RUN/R1/MySubProg() > 5")This statement is not allowed in single commit mode.
Behavior in multi-submission mode: If MySubProg() is a SUB program, it will start with extended submit 3. This program line can be used for other submissions to interpreters or robots.
Reviewing Editor: Li Qian
Previous article:WorkVisual assigns the robot controller to the robot controller of the actual application
Next article:Teacher Zhu has published a new book! ! "ROS Robot Programming Zero Basics"
- Popular Resources
- Popular amplifiers
- Using IMU to enhance robot positioning: a fundamental technology for accurate navigation
- Researchers develop self-learning robot that can clean washbasins like humans
- Universal Robots launches UR AI Accelerator to inject new AI power into collaborative robots
- The first batch of national standards for embodied intelligence of humanoid robots were released: divided into 4 levels according to limb movement, upper limb operation, etc.
- New chapter in payload: Universal Robots’ new generation UR20 and UR30 have upgraded performance
- Humanoid robots drive the demand for frameless torque motors, and manufacturers are actively deploying
- MiR Launches New Fleet Management Software MiR Fleet Enterprise, Setting New Standards in Scalability and Cybersecurity for Autonomous Mobile Robots
- Nidec Drive Technology produces harmonic reducers for the first time in China, growing together with the Chinese robotics industry
- DC motor driver chip, low voltage, high current, single full-bridge driver - Ruimeng MS31211
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- EEWORLD University Hall----Live Replay: Smaller, faster, more reliable connectors drive new developments in IoT applications
- Instructions for submitting entries to the 2020 ST MEMS Sensor Creative Design Competition
- Recruiting QT software engineers (PC side), QT software engineers (Linux side), hardware design engineers, R&D test engineers,...
- How to achieve aperture tuning
- Black Gold's FPGA is really bad
- Today at 10:00: AMS audio experts analyze active noise reduction headphone design, technology trends, and potential applications
- The BLE mobile app required for RSL10 BLE development is not easy to install through Google Play, APK file downloads are collected
- MSP430F5529 serial port clock and SPI clock configuration issues
- [Evaluation of SGP40] + UART communication + use of at32f407 development board
- Solid-state devices versus vacuum tubes: Will the two coexist for a long time?