EasyManuals Logo

IDEC MICROSmart FC6A-C24R1CE Ladder Programming Manual

IDEC MICROSmart FC6A-C24R1CE
604 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #524 background imageLoading...
Page #524 background image
26: S
CRIPT
26-22 FC6A S
ERIES
MICROS
MART
L
ADDER
P
ROGRAMMING
M
ANUAL
FC9Y-B1726
Example 1.10 Decimal to octal conversion using a while statement
Script
Operation Description
This example converts a decimal value to octal using a while statement.
By repeating the process to divide the original decimal data by 8 and converting each digit to octal in a while statement, the
conversion is implemented up to four digits.
The original decimal value is stored in D0100. After the script is executed, the converted octal value is stored in D0200.
Example 1.11 Conditional branch with switch
Script
Operation Description
If the value of D0100 is 10, then 0x1234 is stored in D0200.
If the value of D0100 is 999, then 0x5678 is stored in D0200 and D0000.01 is set to 1.
If the value of D0100 is not 10 nor 999, then nothing is executed.
// Convert a decimal value to octal
// - For example, convert 10 (dec) to 12 (oct), 16 (dec) to 20 (oct)
// - Convert a value to octal up to 4 digits max
@1 = 0; // while counter
@2 = [D0100]; // gets original data
@3 = 1; // decimal base
@4 = 0; // calculation results
// repeat four times
while (@1 < 4)
{
//
Extract 1st octal digit from original data. Store working result in @10
.
@10 = @2 % 8;
//Convert the extracted results to decimal and add to the results
@4 = @4 + (@10 * @3);
//Increase the decimal base by one digit
@3 = @3 * 10;
// Decrease the original data by one digit
@2 = @2 / 8;
// If @2 is 0, exit the white statement
if (0 == @2)
{
break;
}
// Increment while counter by 1
@1 = @1 + 1;
}
// Store the calculation result in D0200
[D0200] = @4;
switch ([D0100])
{
case 10:
[D0200] = 0x1234;
break;
case 999:
[D0200] = 0x5678;
SET([D0000.01]);
break;
}

Table of Contents

Other manuals for IDEC MICROSmart FC6A-C24R1CE

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the IDEC MICROSmart FC6A-C24R1CE and is the answer not in the manual?

IDEC MICROSmart FC6A-C24R1CE Specifications

General IconGeneral
BrandIDEC
ModelMICROSmart FC6A-C24R1CE
CategoryComputer Hardware
LanguageEnglish

Related product manuals