Input/Output

This post explains how to send and receive input/output signals to/from the robot and other sensors/actuators.

Hardware

Below is a diagram showing the connector and pin mapping on the forearm of the robot. All pins send or expect to receive 12V.

Software

The digital inputs/outputs can be accessed in RAPID as follows:
Digital Inputs: di1, di2, di3, di4, di5
Digital Outputs: do1, do2, do3, do4, do5, do6

Here is a sample RAPID program that flashes an LED attached to digital output pin 1, when digital input pin 1 is turned on (goes HIGH).

MODULE Module1
 
PROC Main()
 
  TPWrite "Starting up I/O Test";
  WaitTime 3;
  flashLED(4);
 
  WHILE TRUE DO
 
    TPWrite "Waiting for digital input 1....";
    WaitDI di1, 1;
    TPWrite "Continuing....";
    flashLED(1);
    flashLED(1);
 
  ENDWHILE
 
ENDPROC
 
! Flash an led for a given amount of time
PROC flashLED(num time)
    TPWrite "Turning on digital out 1";
    SetDO do1, 1;
    WaitTime time;
    TPWrite "Turning off digital out 1";
    SetDO do1, 0;
    WaitTime time;
ENDPROC
 
ENDMODULE

The value of an input signal can be read directly in the program, e.g. :

MODULE Module1
 
	PERS tooldata MyTool:=[TRUE,[[0.0000000000,0.0000000000,127.0000000000],[1.0000000000,0.0000000000,0.0000000000,0.0000000000]],[1,[0,0,1],[1,0,0,0],0,0,0]];
	CONST robtarget Target_10:=[[616.276853239657,1.29490244455989E-12,615.999957933775],[0.499999890452526,0,0.866025467031693,0],[0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
	CONST robtarget Target_20:=[[435.125898570835,-436.420224361678,615.999957933775],[0.461797457861153,0.332007619638777,0.799856893481112,-0.191684632575266],[-1,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
	CONST robtarget Target_30:=[[228.073190880006,572.520549361144,615.999957933775],[0.413835981610481,-0.486023816641573,0.716785155541478,0.280605899398119],[0,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
 
 
PROC MoveRight()
	MoveJ Target_10,v1000,z100,MyTool\WObj:=wobj0;
	MoveJ Target_20,v1000,z100,MyTool\WObj:=wobj0;
	MoveJ Target_10,v1000,z100,MyTool\WObj:=wobj0;
ENDPROC
 
 
PROC MoveLeft()
	MoveJ Target_10,v1000,z100,MyTool\WObj:=wobj0;
	MoveJ Target_30,v1000,z100,MyTool\WObj:=wobj0;
	MoveJ Target_10,v1000,z100,MyTool\WObj:=wobj0;
ENDPROC
 
 
PROC main()
 
	MoveJ Target_10,v1000,z100,MyTool\WObj:=wobj0;
 
	! Endless loop
	WHILE TRUE DO
		! Check the state of digital input 1
		IF di1 = 1 THEN
			MoveRight;
 
		! Else check digital input 2
		ELSEIF di2 = 1 THEN
			MoveLeft;
 
		ENDIF
	ENDWHILE
 
ENDPROC

Categories