HI
1.
I want to know that the karel Program ( as below) ,will it also act as polling program to the device connected on RS 232 port.(not PLC)
I mean to say that this program will send the data to the device connected to the port without any request from the other slave device.
2.
Also the format of data is from robot is mostly ASCII
Karel Program is as below:
PROGRAM COMM_WRT
%ALPHABETIZE
%NOLOCKGROUP
%NOBUSYLAMP
%NOPAUSE = ERROR + TPENABLE + COMMAND
%NOABORT = ERROR
%COMMENT = 'KEYENCE comm'
------------------------------------------------------------------------------
---- Constant and Variable Declaration
------------------------------------------------------------------------------
VAR
STATUS : INTEGER -- Holds error status from the builtin calls
port: FILE -- Filehandle fuer den geoeffneten seriellen Port
data_type, int_value: INTEGER
real_val,real_value: REAL -- Benoetigt fuer GET_TPE_PRM, wird nicht benutzt
str_value: STRING[32] -- Benoetigt fuer GET_TPE_PRM, wird nicht benutzt
text IN DRAM: STRING[128] -- Text von der Kamera
sub_string: STRING[32] -- String wird in substrings zerlegt
trenner: STRING[2] -- Trennzeichen im von der Kamera gesendeten String
int_val,i, j: INTEGER -- Zaehler / Hilfvariablen
loc1, loc2 : XYZWPREXT -- Positionsdaten der Kamera
conf : CONFIG -- Achskonfiguration fuer das Positionsregister
bool_flag:BOOLEAN
------------------------------------------------------------------------------
---- CHK_STAT
---- Tests whether the status was successful or not.
---- If the status was not successful the status is posted
------------------------------------------------------------------------------
ROUTINE chk_stat (rec_stat: INTEGER)
BEGIN
IF (rec_stat <> 0) THEN -- if rec_stat is not SUCCESS
-- then post the error
POST_ERR (rec_stat, '', 0, 0) -- Post the error to the system.
ENDIF
END chk_stat
-----------------------------------------------------------------------------
---- Main Program
-----------------------------------------------------------------------------
BEGIN -- COMM
-- Initialize config data
conf.CFG_TURN_NO1=0
conf.CFG_TURN_NO2=0
conf.CFG_TURN_NO3 =0
conf.CFG_FLIP = FALSE
conf.CFG_LEFT = TRUE
conf.CFG_UP = TRUE
conf.CFG_FRONT = TRUE
loc1 = POS(0, 0, 0, 0, 0, 0, conf)
loc2 = POS(0, 0, 0, 0, 0, 0, conf)
text='1'
-- WRITE (CHR(128),CHR(137)) -- By default this will clear TPDISPLAY
WRITE TPERROR (CR,' ',CR)
-- WRITE TPSTATUS(CR,' ',CR)
-- WRITE TPPROMPT(CR,' ',CR)
-- WRITE TPFUNC (CR,' ',CR)
FORCE_SPMENU(TP_PANEL,SPI_TPUSER,1) -- Force the USER menu screen to be visible last.
-- OPEN FILE port ('RO', 'input.txt')
OPEN FILE port ('RW', 'P3:')
GET_REG(13,bool_flag,int_val,real_val,STATUS)
-- This below lines are not required to write and thus remarked on 6.12.16
-- Wenn ein Parameter uebergeben wird und dieser 1 ist, dann RS232 Puffer leeren
--GET_TPE_PRM(1, data_type, int_value, real_value, str_value, STATUS)
-- IF ((data_type = 1) AND (int_value = 1)) THEN
-- SET_FILE_ATR(port, ATR_TIMEOUT,100) -- Timeout 100 ms
-- --REPEAT
-- WRITE port (int_val)
--ELSE
--SET_FILE_ATR (port, ATR_TIMEOUT, 2000) -- Timeout 2000 ms
WRITE port (int_val)
WRITE(int_val)
WRITE TPERROR('it is written')
--ENDIF -- (data_type = 1 AND int_value = 1)
CLOSE FILE port
SET_INT_REG(15,int_val,STATUS)
END COMM_WRT
Rupy