190 lines
6.0 KiB
C
190 lines
6.0 KiB
C
|
/****************************************************************************
|
|||
|
PLC<EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
ר<EFBFBD>ø<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
M8126 ȫ<EFBFBD>ֱ<EFBFBD>־
|
|||
|
M8127 ͨѶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
|||
|
M8128 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
|||
|
M8129 ͨѶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD>
|
|||
|
|
|||
|
ר<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼĴ<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
D8000 = 200; ɨ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|||
|
D8001 = 0X5EF6; <EFBFBD>ͺŰ汾 FX2N(C)
|
|||
|
D8101 = 0X5EF6; <EFBFBD>ͺŰ汾 FX2N(C)
|
|||
|
D8002 = 8; <EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
D8102 = 8; <EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
D8003 = 0x0010; <EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>͡<EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
D8006 CPU<EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ѹ
|
|||
|
D8010 = 10; ɨ<EFBFBD>赱ǰֵ
|
|||
|
D8011 = 20; ɨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Сʱ<EFBFBD><EFBFBD>(0.1MS)
|
|||
|
D8012 = 140; ɨ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>(0.1MS)
|
|||
|
|
|||
|
D8120 = 0X4096 ͨѶ<EFBFBD><EFBFBD>ʽ
|
|||
|
D8121 <EFBFBD><EFBFBD>վ<EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>16<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
D8127 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
D8128 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
D8129 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨѶ<EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD>ֵ
|
|||
|
D8000 <EFBFBD><EFBFBD><EFBFBD>Ź<EFBFBD>
|
|||
|
|
|||
|
ͨѶ<EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD>⣨D8120<EFBFBD><EFBFBD>
|
|||
|
----------------------------------------------------------------------
|
|||
|
λ<EFBFBD><EFBFBD> | <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> | <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
-----------+-------------+--------------------------------------------
|
|||
|
b0 | <EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD> | 0<EFBFBD><EFBFBD> 7λ 1<EFBFBD><EFBFBD> 8λ
|
|||
|
-----------+-------------+--------------------------------------------
|
|||
|
b2b1 | У<EFBFBD>鷽ʽ | 00<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 01<EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD> 11<EFBFBD><EFBFBD>żУ<EFBFBD><EFBFBD>
|
|||
|
-----------+-------------+--------------------------------------------
|
|||
|
b3 | ֹͣλ | 0<EFBFBD><EFBFBD> 1λ 1<EFBFBD><EFBFBD> 2λ
|
|||
|
-----------+-------------+--------------------------------------------
|
|||
|
| | 0001<EFBFBD><EFBFBD>300 0111<EFBFBD><EFBFBD>4800
|
|||
|
b7b6b5b4 | <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | 0100<EFBFBD><EFBFBD>600 1000<EFBFBD><EFBFBD>9600
|
|||
|
| | 0101<EFBFBD><EFBFBD>1200 1001<EFBFBD><EFBFBD>19200
|
|||
|
| | 0110<EFBFBD><EFBFBD>2400
|
|||
|
-----------+-------------+--------------------------------------------
|
|||
|
b8 | | 0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><EFBFBD>ͨѶר<EFBFBD><EFBFBD>
|
|||
|
-----------+-------------+--------------------------------------------
|
|||
|
b9 | | 0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ͬ<EFBFBD><EFBFBD>
|
|||
|
-----------+-------------+--------------------------------------------
|
|||
|
b12b11b10 | ͨѶ<EFBFBD>ӿ<EFBFBD> | 000<EFBFBD><EFBFBD>RS485<EFBFBD><EFBFBD>RS422<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>
|
|||
|
| | 010<EFBFBD><EFBFBD> RS232C<EFBFBD>ӿ<EFBFBD>
|
|||
|
-----------+-------------+--------------------------------------------
|
|||
|
b13 | <EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD> | 0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1<EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
-----------+-------------+-------------------------------------------
|
|||
|
b14 | Э<EFBFBD><EFBFBD> | 0<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><EFBFBD>ͨѶ 1<EFBFBD><EFBFBD>ר<EFBFBD><EFBFBD>ͨѶЭ<EFBFBD><EFBFBD>
|
|||
|
-----------+-------------+--------------------------------------------
|
|||
|
b15 | Э<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ | 0<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ1 1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ4
|
|||
|
----------------------------------------------------------------------
|
|||
|
|
|||
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>D8120 = 0X4096 ͨѶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>19200
|
|||
|
|
|||
|
*********************************************************************************/
|
|||
|
#ifndef _PLC_IO_H
|
|||
|
#define _PLC_IO_H
|
|||
|
|
|||
|
#include "stm32f10x.h" //0X4221018C
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
extern "C" {
|
|||
|
#endif
|
|||
|
#ifdef __cplusplus
|
|||
|
}
|
|||
|
#endif
|
|||
|
|
|||
|
#define BIT_ADDR(addr, bitnum) *((volatile unsigned long *)((0x42000000)+(addr<<5)+(bitnum<<2))) //
|
|||
|
//IO<49>ڵ<EFBFBD>ַӳ<D6B7><D3B3>
|
|||
|
#define GPIOA_ODR_Addr 0x01080C
|
|||
|
#define GPIOB_ODR_Addr 0x010C0C
|
|||
|
#define GPIOC_ODR_Addr 0x01100C
|
|||
|
#define GPIOD_ODR_Addr 0x01140C
|
|||
|
//IOģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
|||
|
#define GPIOA_IDR_Addr 0x010808
|
|||
|
#define GPIOB_IDR_Addr 0x010C08
|
|||
|
#define GPIOC_IDR_Addr 0x011008
|
|||
|
#define GPIOD_IDR_Addr 0x011408
|
|||
|
//IO<49>ڲ<EFBFBD><DAB2><EFBFBD>,ֻ<>Ե<EFBFBD>һ<EFBFBD><D2BB>IO<49><4F>!
|
|||
|
|
|||
|
//ȷ<><C8B7>n<EFBFBD><6E>ֵС<D6B5><D0A1>16!
|
|||
|
#define PAout(n) BIT_ADDR(GPIOA_ODR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
#define PAin(n) BIT_ADDR(GPIOA_IDR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
#define PBout(n) BIT_ADDR(GPIOB_ODR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
#define PBin(n) BIT_ADDR(GPIOB_IDR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
#define PCout(n) BIT_ADDR(GPIOC_ODR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
#define PCin(n) BIT_ADDR(GPIOC_IDR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
#define PDout(n) BIT_ADDR(GPIOD_ODR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
#define PDin(n) BIT_ADDR(GPIOD_IDR_Addr,n) //<2F><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
#define PLC_RUN PCin(13)
|
|||
|
#define PVD PAin(0)
|
|||
|
|
|||
|
#define run_Lamp PBout(8)=0
|
|||
|
#define Stop_Lamp PBout(8)=1
|
|||
|
|
|||
|
#define Err_Lamp_ON PBout(9)=0
|
|||
|
#define Err_Lamp_OFF PBout(9)=1
|
|||
|
|
|||
|
// #define send_485 PDout(10)=1 //485 mode open send
|
|||
|
// #define read_485 PDout(10)=0 //485 mode open read
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD>
|
|||
|
#define X00 PAin(1)
|
|||
|
#define X01 PAin(2)
|
|||
|
#define X02 PAin(3)
|
|||
|
#define X03 PAin(6)
|
|||
|
#define X04 PAin(7)
|
|||
|
#define X05 PCin(4)
|
|||
|
#define X06 PCin(5)
|
|||
|
#define X07 PBin(0)
|
|||
|
#define X10 PBin(1)
|
|||
|
#define X11 PBin(12)
|
|||
|
#define X12 PBin(13)
|
|||
|
#define X13 PBin(14)
|
|||
|
#define X14 PBin(15)
|
|||
|
|
|||
|
#define X15 PBin(7)
|
|||
|
#define X16 PBin(8)
|
|||
|
#define X17 PBin(9)
|
|||
|
|
|||
|
// <20>û<EFBFBD><C3BB>ɸ<EFBFBD><C9B8><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ
|
|||
|
//#define X20 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define X21 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define X22 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define X23 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define X24 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define X25 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define X26 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define X27 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define X30 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define X31 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define X32 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define X33 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define X34 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define X35 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define X36 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define X37 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD>Y<EFBFBD><59><EFBFBD><EFBFBD>
|
|||
|
#define Y00 PCout(9)
|
|||
|
#define Y01 PAout(8)
|
|||
|
#define Y02 PAout(11)
|
|||
|
#define Y03 PAout(12)
|
|||
|
#define Y04 PAout(15)
|
|||
|
#define Y05 PCout(10)
|
|||
|
#define Y06 PCout(11)
|
|||
|
#define Y07 PCout(12)
|
|||
|
|
|||
|
#define Y10 PDout(2 )
|
|||
|
#define Y11 PBout(3 )
|
|||
|
#define Y12 PBout(4 )
|
|||
|
#define Y13 PBout(5 )
|
|||
|
#define Y14 PBout(6 )
|
|||
|
#define Y15 PBout(7 )
|
|||
|
|
|||
|
//#define Y16 PAout(1 )
|
|||
|
//#define Y17 PAout(0 )
|
|||
|
|
|||
|
// <20>û<EFBFBD><C3BB>ɸ<EFBFBD><C9B8><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ
|
|||
|
//#define Y20 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define Y21 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define Y22 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define Y23 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define Y24 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define Y25 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define Y26 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define Y27 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define Y30 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define Y31 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define Y32 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define Y33 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define Y34 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define Y35 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define Y36 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
//#define Y37 <20>ܽŴ<DCBD><C5B4><EFBFBD>
|
|||
|
|
|||
|
|
|||
|
#endif
|
|||
|
|