Bit ¿¬»êÀÚ »ç¿ëÇϱâ

 

 Bit ¿¬»êÀÚ              ¡® | ¡®(OR ¿¬»êÀÚ) , ¡® & ¡® (AND¿¬»êÀÚ), ¡® ^ ¡® ( XOR¿¬»êÀÚ) ÀÇ ¼¼°¡Áö°¡ ÀÖ´Ù.

 

Bit ¿¬»êÀÚ´Â WORD¿¡ ÀúÀåµÈ µ¥ÀÌÅ͵éÀ» 2Áø¼ö·Î º¯È¯ÇÏ¿© Bit ´ÜÀ§·Î °è»êÇÒ ¼ö ÀÖµµ·Ï ÇØÁØ´Ù.

 

¿¹¸¦ µç´Ù¸é ÄÁÆ®·Ñ·¯³ª PLC¿¡¼­ DIGITAL ÀԷ½ÅÈ£¸¦ Àâ¾Æ¼­ 16°³ÀÇ Æ÷ÀÎÆ®¸¦ ÇÑ °³ÀÇ WORD¿¡ ÀúÀåÇÑ´Ù°í °¡Á¤Çغ¸ÀÚ.

°³¹ßÀÚ´Â ÀÌ ½ÅÈ£¸¦ °¢°¢ÀÇ PLC_SCANµðÁöÅÐ ÀÔ·Âű׸¦ 16°³¸¦ µî·ÏÇÏ¿© °¨½Ã È­¸é»ó¿¡¼­ º¼ ¼ö ÀÖÀ» °ÍÀÌ´Ù.

Bit ¿¬»êÀÚ¿Í °ü·Ã Áö¾î »ý°¢ÇÏ¸é ´Ù¸¥ ¹æ¹ýÀ¸·Îµµ °¡´ÉÇÏ´Ù. Áï, µðÁöÅÐ ½ÅÈ£ 16°³°¡ ÀúÀåµÇ¾î ÀÖ´Â ÀÌ ÇÑ °³ÀÇ WORD¸¦ PLC_SCAN¾Æ³¯·Î±× ÀÔ·Âű׷Π¼³Á¤ÇÏ¿© °ªÀ» ºÒ·¯¿Í¼­ Bit ¿¬»êó¸® ÇÏ¸é °¡´ÉÇÏ´Ù.

 

Áï,  ¾Æ·¡¿Í °°ÀÌ Ã³¸®ÇØ ÁÖ¸é µÈ´Ù.

1) ¿¹¸¦ µé¾î PLC¿µ¿ª M0000 WORD(¾ÕÀ¸·Î M0·Î ¾´´Ù.)¿¡ 16°³ÀÇ Á¢Á¡À» ¼ø¼­´ë·Î ÀúÀåÇϴµ¥ ¸¸¾à, 16°³ÀÇ Á¢Á¡ÀÌ ¸ðµÎ ON µÇ¾îÀÖ´Ù¸é M0ÀÇ °ªÀº ¾Æ·¡¿Í °°´Ù.

 

ÀÌÁø¼ö : 1111111111111111

½ÊÁø¼ö : 65535

16Áø¼ö : FFFFh

 

À§ÀÇ °ªÀÌ µÉ °ÍÀÌ°í,

 

2) 0¹øBit , 4¹ø Bit, 5¹ø Bit, 10¹ø Bit, 15¹ø Bit °¡ ONµÇ¾î ÀÖ´Ù¸é M0ÀÇ °ªÀº ¾Æ·¡¿Í °°À» °ÍÀÌ´Ù.

 

ÀÌÁø¼ö : 1000010000110001

½ÊÁø¼ö : 33841

16Áø¼ö : 8431h

 

À§ÀÇ °ªÀÌ µÉ°ÍÀÌ´Ù.

 

2)¹ø¿¡¼­ ÀÌ °ªÀ» ¾Æ³¯·Î±× ÀÔ·Âű׷Π¼³Á¤ÇÏ¿© °¢°¢ÀÇ µðÁöÅРä³Î °ªÀÇ ON/OFF »óŸ¦ ³ªÅ¸³»±â À§Çؼ­´Â ¾Æ·¡¿Í °°ÀÌ Bit¿¬»êÀÚ¸¦ »ç¿ëÇÏ¸é µÈ´Ù.

 

M0ÀÇ WORD°ªÀ» PLC_SCN ¾Æ³¯·Î±× ÀÔ·ÂÅÂ±× AI_0000·Î ¼³Á¤Çß´Ù°í °¡Á¤ÇÏ°í, °¢°¢ÀÇ µðÁöÅРä³Î¿¡ ´ëÇÏ¿© ¸Þ¸ð¸® µðÁöÅÐ ÀÔ·Âű׸¦ 16°³(DI_0000 ~DI_0016) ¼³Á¤ÇÑ´Ù.

 

STATUS[0]=$AI_0000 & 1; //0¹ø° ä³ÎÀÇ ON/OFF»óÅ °Ë»ç

If ( STATUS[0] == 1) $DI_0000 = 1;

else $DI_0000 = 0;

 

STATUS[1]=$AI_0000 & 2; //1¹ø° ä³ÎÀÇ ON/OFF»óÅ °Ë»ç

If ( STATUS[1] == 2) $DI_0001 = 1;

else $DI_0001 = 0;

 

STATUS[2]=$AI_0000 & 4; //2¹ø° ä³ÎÀÇ ON/OFF»óÅ °Ë»ç

If ( STATUS[2] == 4) $DI_0002 = 1;

else $DI_0002 = 0;

 

STATUS[3]=$AI_0000 & 8; //3¹ø° ä³ÎÀÇ ON/OFF»óÅ °Ë»ç

If ( STATUS[3] == 8) $DI_0003 = 1;

else $DI_0003 = 0;

 

STATUS[4]=$AI_0000 & 16; //4¹ø° ä³ÎÀÇ ON/OFF»óÅ °Ë»ç

If ( STATUS[4] == 16) $DI_0004 = 1;

else $DI_0004 = 0;

 

STATUS[5]=$AI_0000 & 32; //5¹ø° ä³ÎÀÇ ON/OFF»óÅ °Ë»ç

If ( STATUS[5] == 32) $DI_0005 = 1;

else $DI_0005 = 0;

 

STATUS[6]=$AI_0000 & 64; //6¹ø° ä³ÎÀÇ ON/OFF»óÅ °Ë»ç

If ( STATUS[6] == 64) $DI_0006 = 1;

else $DI_0006 = 0;

 

STATUS[7]=$AI_0000 & 128; //7¹ø° ä³ÎÀÇ ON/OFF»óÅ °Ë»ç

If ( STATUS[7] == 128) $DI_0007 = 1;

else $DI_0007 = 0;

 

STATUS[8]=$AI_0000 & 256; //8¹ø° ä³ÎÀÇ ON/OFF»óÅ °Ë»ç

If ( STATUS[8] == 256) $DI_0008 = 1;

else $DI_0008 = 0;

 

STATUS[9]=$AI_0000 & 512; //9¹ø° ä³ÎÀÇ ON/OFF»óÅ °Ë»ç

If ( STATUS[9] == 512) $DI_0009 = 1;

else $DI_0009 = 0;

 

STATUS[10]=$AI_0000 & 1024; //10¹ø° ä³ÎÀÇ ON/OFF»óÅ °Ë»ç

If ( STATUS[10] == 1024) $DI_0010 = 1;

else $DI_0010 = 0;

 

STATUS[11]=$AI_0000 & 2048; //11¹ø° ä³ÎÀÇ ON/OFF»óÅ °Ë»ç

If ( STATUS[11] == 2048) $DI_0011 = 1;

else $DI_0011 = 0;

 

STATUS[12]=$AI_0000 & 4096; //12¹ø° ä³ÎÀÇ ON/OFF»óÅ °Ë»ç

If ( STATUS[12] == 4096) $DI_0012 = 1;

else $DI_0012 = 0;

 

STATUS[13]=$AI_0000 & 8192; //13¹ø° ä³ÎÀÇ ON/OFF»óÅ °Ë»ç

If ( STATUS[13] == 8192) $DI_0013 = 1;

else $DI_0013 = 0;

 

STATUS[14]=$AI_0000 & 16384; //14¹ø° ä³ÎÀÇ ON/OFF»óÅ °Ë»ç

If ( STATUS[14] == 16384) $DI_0014 = 1;

else $DI_0014 = 0;

 

STATUS[15]=$AI_0000 & 32768; //15¹ø° ä³ÎÀÇ ON/OFF»óÅ °Ë»ç

If ( STATUS[15] == 32768) $DI_0015 = 1;

else $DI_0015 = 0;

 

 

À§¿Í °°ÀÌ »ç¿ëÇϸé ÇÑ °³ÀÇ PLC_SCAN ¾Æ³¯·Î±× ÀÔ·Âű׸¦ »ç¿ëÇÏ¿© 16°³ÀÇ µðÁöÅÐ Á¢Á¡À» º¼ ¼ö ÀÖ°Ô µÈ´Ù.

 

Ãâ·ÂÀ» ÇϳªÀÇ ¿öµå·Î ³»º¸³»±â À§Çؼ­´Â ´ÙÀ½°ú °°ÀÌ ÀÛ¼ºÇÑ´Ù.

¿ì¼±, ¸Þ¸ð¸® ű׷ΠµÈ µðÁöÅÐ ÀÔ·Â ÅÂ±× 16°³(OUTPUT00~OUTPUT15)¸¦ ÀÛ¼ºÇÑ´Ù. (ÀÌ µðÁöÅÐ ÀԷ ű׵éÀº ¸Þ¸ð¸® ű׷ΠÀÛ¼ºÇÏ¿´±â ¶§¹®¿¡ ÀÌ ÀԷ ű׵éÀ» ON/OFFÇÏ¿©µµ ½ºÅ©¸³Æ®¸¦ ÀÛ¼ºÇÏÁö ¾ÊÀ¸¸é Ãâ·ÂÀÌ ON/OFFµÇÁö ¾Ê´Â´Ù.)

´ÙÀ½¿¡ ÀÌ°ªµéÀ» ¸ð¾Æ¼­ ÇϳªÀÇ ¿öµå·Î Ãâ·ÂÇϱâ À§ÇÏ¿© ¾Æ³¯·Î±× Ãâ·Âű׸¦ ÀÛ¼ºÇÑ´Ù. (AIOUTPUT ¾Æ³¯·Î±× Ãâ·Âű×)

À§¿Í °°ÀÌ ¸¸µç ÈÄ¿¡ ÇÁ·Î±×·¥ ¹öÆ°À» »ç¿ëÇÏ¿© ´ÙÀ½°ú °°ÀÌ ÇÁ·Î±×·¥À» ÀÛ¼ºÇÑ´Ù.

 

OUTPUT = 0;                                                                         // OUTPUT À̶ó´Â WORDÇüÀÇ º¯¼ö¸¦ ÇÒ´çÇÑ´Ù. ÃʱⰪÀ» 0À¸·Î ¼¼ÆÃÇØÁØ´Ù.

 

If ($OUTPUT00 == ON ) OUTPUT = OUTPUT+1;                       // 1¹ø° ä³ÎÀ» ON½ÃÅ°±â À§ÇÏ¿© OUTPUTÀ̶ó´Â WORDÀÇ 0¹ø° ºñÆ®¸¦ 1·Î ¸¸µç´Ù.

If ($OUTPUT01 == ON ) OUTPUT = OUTPUT+2;                       // 2¹ø° ä³ÎÀ» ON½ÃÅ°±â À§ÇÏ¿© OUTPUTÀ̶ó´Â WORDÀÇ 1¹ø° ºñÆ®¸¦ 1·Î ¸¸µç´Ù.

If ($OUTPUT02 == ON ) OUTPUT = OUTPUT+4;                       // 3¹ø° ä³ÎÀ» ON½ÃÅ°±â À§ÇÏ¿© OUTPUTÀ̶ó´Â WORDÀÇ 2¹ø° ºñÆ®¸¦ 1·Î ¸¸µç´Ù.

If ($OUTPUT03 == ON ) OUTPUT = OUTPUT+8;                       // 4¹ø° ä³ÎÀ» ON½ÃÅ°±â À§ÇÏ¿© OUTPUTÀ̶ó´Â WORDÀÇ 3¹ø° ºñÆ®¸¦ 1·Î ¸¸µç´Ù.

If ($OUTPUT04 == ON ) OUTPUT = OUTPUT+16;                     // 5¹ø° ä³ÎÀ» ON½ÃÅ°±â À§ÇÏ¿© OUTPUTÀ̶ó´Â WORDÀÇ 4¹ø° ºñÆ®¸¦ 1·Î ¸¸µç´Ù.

If ($OUTPUT05 == ON ) OUTPUT = OUTPUT+32;                     // 6¹ø° ä³ÎÀ» ON½ÃÅ°±â À§ÇÏ¿© OUTPUTÀ̶ó´Â WORDÀÇ 5¹ø° ºñÆ®¸¦ 1·Î ¸¸µç´Ù.

If ($OUTPUT06 == ON ) OUTPUT = OUTPUT+64;                     // 7¹ø° ä³ÎÀ» ON½ÃÅ°±â À§ÇÏ¿© OUTPUTÀ̶ó´Â WORDÀÇ 6¹ø° ºñÆ®¸¦ 1·Î ¸¸µç´Ù.

If ($OUTPUT07 == ON ) OUTPUT = OUTPUT+128;                   // 8¹ø° ä³ÎÀ» ON½ÃÅ°±â À§ÇÏ¿© OUTPUTÀ̶ó´Â WORDÀÇ 7¹ø° ºñÆ®¸¦ 1·Î ¸¸µç´Ù.

If ($OUTPUT08 == ON ) OUTPUT = OUTPUT+256;                   // 9¹ø° ä³ÎÀ» ON½ÃÅ°±â À§ÇÏ¿© OUTPUTÀ̶ó´Â WORDÀÇ 8¹ø° ºñÆ®¸¦ 1·Î ¸¸µç´Ù.

If ($OUTPUT09 == ON ) OUTPUT = OUTPUT+512;                   // 10¹ø° ä³ÎÀ» ON½ÃÅ°±â À§ÇÏ¿© OUTPUTÀ̶ó´Â WORDÀÇ 9¹ø° ºñÆ®¸¦ 1·Î ¸¸µç´Ù.

If ($OUTPUT10 == ON ) OUTPUT = OUTPUT+1024;                 // 11¹ø° ä³ÎÀ» ON½ÃÅ°±â À§ÇÏ¿© OUTPUTÀ̶ó´Â WORDÀÇ 10¹ø° ºñÆ®¸¦ 1·Î ¸¸µç´Ù.

If ($OUTPUT11 == ON ) OUTPUT = OUTPUT+2048;                 // 12¹ø° ä³ÎÀ» ON½ÃÅ°±â À§ÇÏ¿© OUTPUTÀ̶ó´Â WORDÀÇ 11¹ø° ºñÆ®¸¦ 1·Î ¸¸µç´Ù.

If ($OUTPUT12 == ON ) OUTPUT = OUTPUT+4096;                 // 13¹ø° ä³ÎÀ» ON½ÃÅ°±â À§ÇÏ¿© OUTPUTÀ̶ó´Â WORDÀÇ 12¹ø° ºñÆ®¸¦ 1·Î ¸¸µç´Ù.

If ($OUTPUT13 == ON ) OUTPUT = OUTPUT+8192;                 // 14¹ø° ä³ÎÀ» ON½ÃÅ°±â À§ÇÏ¿© OUTPUTÀ̶ó´Â WORDÀÇ 13¹ø° ºñÆ®¸¦ 1·Î ¸¸µç´Ù.

If ($OUTPUT14 == ON ) OUTPUT = OUTPUT+16384;                // 15¹ø° ä³ÎÀ» ON½ÃÅ°±â À§ÇÏ¿© OUTPUTÀ̶ó´Â WORDÀÇ 14¹ø° ºñÆ®¸¦ 1·Î ¸¸µç´Ù.

If ($OUTPUT15 == ON ) OUTPUT = OUTPUT+32768;                // 16¹ø° ä³ÎÀ» ON½ÃÅ°±â À§ÇÏ¿© OUTPUTÀ̶ó´Â WORDÀÇ 15¹ø° ºñÆ®¸¦ 1·Î ¸¸µç´Ù.

 

$AIOUTPUT = OUTPUT;                                                        // OUTPUT °á°ú¸¦ ¾Æ³¯·Î±× Ãâ·Â ÅÂ±× AIOUTPUT À¸·Î ³Ñ°Ü¼­ Ãâ·ÂÀ» ÇÑ´Ù.

 

 

À§¿Í °°ÀÌ ÀÛ¼ºÀ» ÇÏ¿© ÇϳªÀÇ ¿öµå·Î µðÁöÅÐ 16°³ÀÇ Ã¤³ÎÀ» Á¦¾îÇÒ ¼ö ÀÖ´Ù.