15.07.2013 Views

Automatic control function programming manual ladder language

Automatic control function programming manual ladder language

Automatic control function programming manual ladder language

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example 1<br />

Consider the following variables<br />

%V100.L = «Tool number:%5d Type:%2c%2c Time of use:<br />

%M50.W = 255<br />

%2d hours %2d minutes»<br />

%M52.B = 0x55<br />

%M54.B = 2<br />

%M55.B = 57<br />

(0x55 ASCII code for t, 0x57 ASCII code for v)<br />

The instruction printf(%V100.L, %M50.W, %M52.B,0x57, %M54.B, %M55.B) displays:<br />

Tool number: 255 Type: tv Time of use: 2 hours 57 minutes<br />

Example 2<br />

Displaying a Simple String<br />

%V200.L = «Do you want to know the time? (Y/N)»<br />

printf(%V200.L) displays: Do you want to know the time? (Y/N)<br />

Transparent Mode<br />

Displaying a String with a Display Format for the Arguments<br />

If %M10.B = 3;<br />

If %M11.B = 15;<br />

%V200.L = «It is %2d:%2d»<br />

printf(%V200.L, %M10.B, %M11.B) displays: It is 3:15<br />

The two characters \n cause a jump to the next line when displaying the string (the compiler replaces the characters<br />

\n by bytes 0xd 0xa).<br />

Example 3<br />

%V200.L = «1 - Read \n 2 - Write»<br />

printf(%V200.L) displays<br />

1 - Read<br />

2 - Write<br />

Return code<br />

If OK<br />

Number of characters transmitted for display.<br />

Error<br />

-1: Not in transparent mode, the calling task is not a %TF task.<br />

-2: Max. formatting buffer size (255 bytes) exceeded.<br />

-3: Format error in the format string.<br />

en-938846/6 8 - 11<br />

8

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!