View Full Version : Variable IO Numbers


squarewave
10-12-2004, 05:29 PM
I have a situation where I would like to use the contents of a variable to specify an IO number, such as #(\53)=1. Is there any way of doing this?

I have a 12 tool changer where each tool has its own status switches (tool 2 is up; tool 2 is down) and would like to pass the tool number as a variable to a subroutine. I have numbered the switches such that I can define them in a subroutine with a constant offset, like tool 2 up and down would be #22 and #23, and tool 3 up and down would be #24 and #25, etc. So my expression would be "tool X is up" is #(2X+18) and "tool X is down" is #(2X+19).

I was hoping I might be able to do this with some string function, but haven't been able to come up with anything that works yet. Has anyone tackled this problem yet?

Thanks for any thoughts!

camsoft
10-12-2004, 06:49 PM
squarewave,

We're not quite sure we understand, but we do have an idea that should satisfy any random I/O needs. The current version does offer an ARRAY command to store mass amounts of numbers, data, strings and so on, but not knowing what version you have we do have a generic idea.

Create two Macros. One to turn off an output relay and another to turn them on.
Call these macro from any routine, anytime. They are public and global through out the whole logic system.

In each of them create a simple list. For example:

[IO LIST ON]
IF \53=1 THEN #22=1
IF \53=2 THEN #23=1
IF \53=3 THEN #24=1
IF \53=4 THEN #25=1
ect...

-Or for OFF-

[IO LIST OFF]
IF \53=1 THEN #22=0
ect...

Whereas variable \53 represents your tool number and # is a fixed I/O relay number.

Hope this helped.

Tech Support
CamSoft Corp.
(951) 674-8100
support@camsoftcorp.com
www.cnccontrols.com

squarewave
10-15-2004, 02:42 PM
Thanks very much for your fast reply Camsoft!

My desire to have a variable specify an I/O number was strictly from a programming efficiency standpoint. Using If/Thens will require me to duplicate the toolchanging routine 12 times (the number of tools in the changer). There is absolutely no problem with me doing this as I don't believe I will run out of Macro room.

This just looked like an excellent place for a subroutine where all I had to pass into the routine was the tool number.

Thanks again ...