采用stm32 仿三菱PLC,含原理圖,源碼,帶說明,保證源碼編譯通過,還有些小問題需要改進,特此貼出給大家參考。
FX1N三菱PLC說明文檔
1 技術規格:
輸入電源 24V +- 10%(20V觸發掉電保護)
輸入: 8路 隔離
輸出: 8路 隔離 達林頓管輸出
232編程接口
485通訊接口,可連接觸摸屏、文本顯示器等等
兩個電位器輸出
輸入輸出 均帶有指示燈
電路原理圖如下:
單片機源程序如下:
- /* Includes ------------------------------------------------------------------*/
- #include "iostm32f10xxB.h"
- #include "stm32f10x_lib.h"
- #include "main.h"
- //rac
- /* Includes ------------------------------------------------------------------*/
- #include "iic.c"
- #include "uart.c"
- #include "plc.c"
- #include "stm32f10x_it.c"
- /* Private functions ---------------------------------------------------------*/
- /*******************************************************************************
- * Function Name : main
- * Description : Main program.
- * Input : None
- * Output : None
- * Return : None
- *******************************************************************************/
- int main(void)
- {
- #ifdef DEBUG
- debug();
- #endif
- //配置系統時鐘
- sys_config();
- //配置 NVIC 和 Vector Table
- NVIC_Configuration();
- //配置使用的GPIO口
- GPIO_Configuration();
- //改變指定管腳的映射 GPIO_Remap_SWJ_JTAGDisable JTAG-DP 失能 + SW-DP使能
- GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable , ENABLE);
-
-
- xxdelay();
- SysTick_Config();
- I2C_EE_Init();
- Analog_Configration();
- DMA_Configration();
- program = (unsigned char *)(0x0800C000);
- UART0_setup();
- // uart0_txptr = 0;
- // uart0_txall = 2;
- // COM0_OUT;
- // USART1->DR = 0x55;
- UART1_setup();
- LED0_OFF;
- LED1_OFF;
-
- //主循環
- plc_main();
- }
- #ifdef DEBUG
- /*******************************************************************************
- * Function Name : assert_failed
- * Description : Reports the name of the source file and the source line number
- * where the assert_param error has occurred.
- * Input : - file: pointer to the source file name
- * - line: assert_param error line source number
- * Output : None
- * Return : None
- *******************************************************************************/
- void assert_failed(u8* file, u32 line)
- {
- /* User can add his own implementation to report the file name and line number,
- ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
- /* Infinite loop */
- while (1)
- {
- }
- }
- #endif
- /******************* (C) COPYRIGHT 2008 STMFANS *********************************
- *****END OF FILE****/
復制代碼
所有資料51hei提供下載:
STM001-STM32F103RBT6PLC源碼說明書原圖.7z
(883.39 KB, 下載次數: 962)
2019-3-9 01:29 上傳
點擊文件名下載附件
|