采用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)
|