testDI function
sort
✭
Hello all I would like to know what is the real difference between these two lines
IF DI_mySignal THEN
and the same using IF TesetDI(DI_mySignal) THEN
Both are working but what is the real differenece?
Thank you
Tagged:
0
Comments
-
Hello,You can write it like this too:IF DI_mysignal=1 THENorIF DI_mysignal=high THENBut if you define badly DI_mysignal nothing happens in syntax check.TestDI have a signaldi parameter, so it have to be defined as this.And TestDI handles errors:
Error handling The following recoverable errors are generated and can be handled in an error handler. The system variable ERRNO will be set to:
Name
Cause of error
ERR_NO_ALIASIO_DEF
The signal variable is a variable declared in RAPID. It has not been connected to an I/O signal defined in the I/O configuration with instruction AliasIO.
ERR_NORUNUNIT
There is no contact with the I/O device.
ERR_SIG_NOT_VALID
The I/O signal cannot be accessed. The reasons can be that the I/O device is not running or an error in the configuration (only valid for ICI field bus).
☑️2024 - RobotStudio® User Group0 -
Hello,the difference is that function "TESTDI" returns a boolean value (True or False) instead of "high" and "low".I think there is no additional error check inside this function.The function will probably look like this:
FUNC bool TESTDI(VAR signaldi Signal)<br> RETURN Signal = high;<br>ERROR<br> RAISE;<br>ENDFUNC<br>
I think if you use an "IF" statement in your code, it will be faster than calling the TESTDI function.BRMicky
0 -
I found this code in an older mediapool for S4 generation controllers:! Test Digital InputFUNC bool TestDI(VAR signaldi Signal)IF Signal = 1 THENRETURN TRUE;ELSERETURN FALSE;ENDIFENDFUNCLee Justice0
-
I take the text from documentation.
☑️2024 - RobotStudio® User Group0 -
I see, Denis. Makes me curious if the error is generated in the routine that calls the function or if the function has its error handler which RAISES the error.Lee Justice0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 799 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings