Help - Search - Members - Calendar
Full Version: Query PLC for Current Program / Routine Name
Forums.MrPLC.com > PLCs and Supporting Devices > Allen Bradley
HandledException
Hello everyone.

I am working on an internal logging setup for a plc and was wondering if there is a way to access the current program and/or routine name information in a CompactLogic processor?

Thanks in advance for any help. smile.gif
paulengr
QUOTE (HandledException @ Jul 15 2009, 05:33 PM) *
Hello everyone.

I am working on an internal logging setup for a plc and was wondering if there is a way to access the current program and/or routine name information in a CompactLogic processor?

Thanks in advance for any help. smile.gif


Yes. There are commands to do so. However, the configuration and such is important. Best to have the PLC itself supply the information.

There are GETSSV commands which can retrieve that information quite easily.
BobLfoot
QUOTE (paulengr @ Jul 16 2009, 07:36 AM) *
Yes. There are commands to do so. However, the configuration and such is important. Best to have the PLC itself supply the information.

There are GETSSV commands which can retrieve that information quite easily.


Paul doulbe check. I found GSV for Program and Routine but these require the program or routine name. What exception wants is the currently executing routine name. I didn't find a reverse directory GSV so to speak, but maybe I missed it, there are so many after all.
HandledException
Bob pretty much summed up what I was going to say. Looking through the GSV objects I couldn't see any easy way of getting the program / routine name. The closest thing I could find was the instance number, which isn't very human-readable, and that requires the program name like Bob mentioned.

Thanks for the help Bob & Paul, I appreciate it.
Ken Roach
You could use a CIP Generic message to get the Program name as Class 0x68, Instance 1, Attribute 28 (I think...haven't tested).

I just can't figure out why you'd write code to get the Program name when you're writing a routine that you're going to place into that Program. I can see you maybe shooting for some elegant mechanism where you just deploy the one routine into zillions of Programs, but do you really have that many ?
HandledException
Ken, I'm trying to develop a logger add on which I can use in various programs. Right now I have to pass in the program and routine name along with the message I want logged. I just wanted to see if I could get them programmatically to try and save some headaches managing the name strings. (I currently have 10 programs in the controller)

One of the larger projects that I am working on is a compact logix plc completely dedicated to crunching numbers and data collection for a number of older (ie maxed out) production lines. It doesn't have any kind of HMI whatsoever, and runs autonomously. I quickly found out that I had few ways to determine what happened after problems, so I started trying to develop an internal logger of sorts to keep track of it's status / problems.

For example:
CODE
<snip>

//----------------------------------
// Transaction Error, Abort.
//----------------------------------
ELSIF logTransResult > 1 AND logTransRetries > MAX_TRANS_RETRIES THEN

//Log the error to the controller-scope log
JSR(loggerTransError, 1, logTransResult);

//Remove the problematic log from the queue
JSR(logDequeue, 0, lastProdXferLog);
</snip>

//|------------------------------------------------------------------
//| loggerTransError()
//|------------------------------------------------------------------
SBR(someTransResult);

//Start the message
COP(STRING_ERROR, tempMessage, 1);
CONCAT(tempMessage, ASCII_SPACE, tempMessage);
CONCAT(tempMessage, STRING_CODE, tempMessage);
CONCAT(tempMessage, ASCII_SPACE, tempMessage);

//Get the error code and add it to the message
rssqlErrorDecode(errorDecoder, someTransResult, errorCode);
DTOS(errorCode, tempString);
CONCAT(tempMessage, tempString, tempMessage);

//Pass the completed message on to be added to the log
logger(logger_controller, STRING_PROD_XFER, STRING_TRANSHANDLER, tempMessage, logs_controller);

RET();


I'm not sure if it's the best way to do what I'm looking for, but it seems to work ok, barring being a tad memory intensive...

I don't have much experience with CIP generic messages. Could you explain that a bit further?

Thanks for the help.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.