Hi Roberto,
I do not have that relay board, but may be the following code will be of help. Try it and see what it does.
/* write/read to/from relay device */
rc=RxFuncAdd('SysSleep','RexxUtil','SysSleep')
/* set com port*/
ddName = 'COM8'
/* protect the file system from inadvertent access */
if stream(ddName,'command','query exists') \= '\DEV\' || ddName
then do
say 'ERROR: The device driver' ddName 'does not exist!'
/* wait */
'@pause'
exit
end
/* setup communication mode */
'MODE '||ddName||':9600,N,8,1,BUFFER=OFF,TO=ON'
/* acquire the device driver */
rc=stream(ddName,'command','open')
if rc \= 'READY:'
then do
say rc 'Device driver' ddName 'currently in use. Please try later.'
/* wait */
'@pause'
exit
end
/* send 0x50 command */
say 'sending 0x50 command'
rc = charout(ddName,x2c(50))
call SysSleep(0.030)
/* obtain response */
say 'obtaining response'
response = charin(ddName,,1)
say 'response: 'c2x(response)
call SysSleep(0.030)
/* send 0x51 command */
say 'sending 0x51 command'
rc = charout(ddName,x2c(51))
call SysSleep(0.030)
/* switch relays off */
say 'sending 0xFF control'
rc = charout(ddName,x2c(FF))
call SysSleep(0.030)
/* switch relay 1 on */
say 'sending 0xFE control'
rc = charout(ddName,x2c(FE))
call SysSleep(0.030)
/* wait 5 seconds */
say 'waiting 5 seconds'
call SysSleep(5)
/* switch relays off */
say 'sending 0xFF control'
rc = charout(ddName,x2c(FF))
call SysSleep(0.030)
/* release the device driver */
rc=stream(ddName,'command','close')
Regards