⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plc_public.c

📁 以前做的一个仿PLC程序
💻 C
字号:
/*******************************PLC_PUBLIC.C****************************************
*LUHEDING
*2009-09-08
*V1.0
*
******************************************************************************/
/******************************************************************************/
typedef unsigned char  uint8;   /* 无符号8位整型变量    */
typedef signed   char  int8;    /* 有符号8位整型变量	*/
typedef unsigned short uint16;  /* 无符号16位整型变量   */
typedef signed   short int16;   /* 有符号16位整型变量   */
typedef unsigned int   uint32;  /* 无符号32位整型变量   */
typedef signed   int   int32;   /* 有符号32位整型变量   */ 
typedef unsigned long  u32;
typedef unsigned short u16;
typedef unsigned char  u8;
#ifndef __at
#define __at(_addr) __attribute__ ((at(_addr)))
#endif
/******************************************************************************/
char  	PLC_UART_BUFFER[0x8F]; 	//接收缓存	 BUFFER
char  	PLC_UART_T_BUFFER[0x8F]; 	//接收缓存
uint8 	PLC_UART_RECEIVE_CNT;	//接收计数
uint8 	PLC_UART_T_CNT;		//发送计数
//uint8   temp_led1,temp_led2,temp_led3;
/******************************************************************************/
u32 	PLC_PC;		 //PLC程序指针
uint16 	PLC_TEMP1,PLC_TEMP2,PLC_CMD;//程序执行专用
uint8  	PLC_ACC_BIT,PLC_MPS_BIT;//程序执行专用(运算栈及分线栈)
uint16 	PLC_RUN_TIME; // 扫描时间
uint16  PLC_ERR_PC;	 //PLC出错步
uint8   RUN_BIT;

/******************************************************************************/
const uint8 hex[256]={
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0,
0,10,11,12,13,14,15,0,0,0,0,0,0,};
const uint8 asc[16]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x41,0x42,0x43,0x44,0x45,0x46};
/******************************************************************************/
const uint8 PLC_BIT_OR[]={0X01,0X02,0X04,0X08,0X10,0X20,0X40,0X80};
const uint8 PLC_BIT_AND[]={0XFE,0XFD,0XFB,0XF7,0XEF,0XDF,0XBF,0X7F};
/******************************************************************************/
const uint8 PROG_CODE[]__at (0x0003FFA4)={						
//最前的0X02表示PLC为2K的程序步,其它还未明
0x08,0x00,0xB9,0x69,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0xF4,0x09,0xFF,0x0B,0xF4,0x01,0xE7,0x03,0x64,0x0E,0xC7,0x0E,0xDC,0x0E,0xFF,0x0E,0x90,0x01,0xFE,0x03,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x83,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
//程序开始
0x01,0x24,0x01,0xC5, //LD X1 OUT Y1
0X0F,0X00,//结束指令
0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,};
/*********************************************************************************************************
**                            End Of File
********************************************************************************************************/  




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -