18 changed files with 659 additions and 514 deletions
-
10.cproject
-
2.project
-
4.settings/language.settings.xml
-
4Intelligent_winding_robot_main_board.ioc
-
10Intelligent_winding_robot_main_board.launch
-
11README.md
-
2sdk
-
2usrc/cmdline_version.cpp
-
152usrc/device.cpp
-
94usrc/device.hpp
-
9usrc/global.cpp
-
10usrc/global.hpp
-
41usrc/main.cpp
-
4usrc/project_configs.h
-
89usrc/transparent_version.cpp
-
3usrc/transparent_version.hpp
@ -1,10 +1,9 @@ |
|||
开发板资料 |
|||
http://47.111.11.73/docs/boards/stm32/zdyz_stm32f407_explorer.html |
|||
|
|||
|
|||
``` |
|||
注意事项: |
|||
1.注意将CAN/USB选择跳帽,接到CAN接口那一端(否则代码会卡死在CAN初始化处) |
|||
|
|||
``` |
|||
---------------------------------------- |
|||
工程初始化: |
|||
git submodule update --init --recursive |
|||
``` |
|||
|
|||
``` |
@ -1 +1 @@ |
|||
Subproject commit 962fc1f81b210bcc13cb87a033d8bd04ead290a6 |
|||
Subproject commit aa9d1dda89f177ad23af5013fdaf5d8f29c0f8a6 |
@ -0,0 +1,152 @@ |
|||
#include "device.hpp"
|
|||
|
|||
#include "sdk\components\eq_20_asb_motor\eq20_servomotor.hpp"
|
|||
#include "sdk\components\mini_servo_motor\mini_servo_motor_ctrl_module.hpp"
|
|||
|
|||
using namespace iflytop; |
|||
|
|||
// void init();
|
|||
#define TAG "main"
|
|||
void Device::init() { |
|||
/**
|
|||
* @brief 芯片基础配置 |
|||
*/ |
|||
chip_cfg_t chipcfg; |
|||
chipcfg.us_dleay_tim = &PC_SYS_DELAY_US_TIMER; |
|||
chipcfg.tim_irq_scheduler_tim = &PC_SYS_TIM_IRQ_SCHEDULER_TIMER; |
|||
chipcfg.huart = &PC_DEBUG_UART; |
|||
chipcfg.debuglight = PC_DEBUG_LIGHT_GPIO; |
|||
|
|||
chip_init(&chipcfg); |
|||
|
|||
/**
|
|||
* @brief ZOS初始化 |
|||
*/ |
|||
zos_cfg_t zoscfg; |
|||
zos_init(&zoscfg); |
|||
|
|||
ZLOGI(TAG, "boardId:%d", 0); |
|||
|
|||
line_locking_solenoid_valve_init(); |
|||
init_uart_cmder(); |
|||
init_dm(); |
|||
init_bus(); |
|||
sub_module_init(); |
|||
|
|||
while (true) { |
|||
OSDefaultSchduler::getInstance()->loop(); |
|||
m_uart_cmdline_parser.schedule(); |
|||
} |
|||
} |
|||
|
|||
void Device::init_uart_cmder() { |
|||
static ZUARTDmaReceiver dmaUartReceiver; |
|||
ZUARTDmaReceiver::hardware_config_t cfg = { |
|||
.huart = &PC_DEBUG_UART, |
|||
.dma_rx = &PC_DEBUG_UART_DMA_HANDLER, |
|||
.rxbuffersize = PC_DEBUG_UART_RX_BUF_SIZE, |
|||
.rxovertime_ms = 10, |
|||
}; |
|||
dmaUartReceiver.initialize(&cfg); |
|||
m_uart_cmdline_parser.initialize(&dmaUartReceiver); |
|||
} |
|||
|
|||
/**
|
|||
* @brief |
|||
* 1. 初始化设备管理器 |
|||
* 2. 设备管理器支持串口指令解析 |
|||
*/ |
|||
void Device::init_dm() { |
|||
m_device_manager.initialize(); |
|||
// m_device_manager 支持命令行解析操作
|
|||
static MicroComputerModuleDeviceScriptCmderPaser m_zModuleDeviceScriptCmderPaser; // 脚本解析器
|
|||
m_zModuleDeviceScriptCmderPaser.initialize(&m_uart_cmdline_parser, &m_device_manager); |
|||
} |
|||
|
|||
void Device::init_bus() { |
|||
/*******************************************************************************
|
|||
* 初始化CAN总线 * |
|||
*******************************************************************************/ |
|||
ZLOGI(TAG, "init can bus"); |
|||
m_zcanbus.init(m_zcanbus.createCFG()); |
|||
m_device_manager.regCanCmder(&m_zcanbus); |
|||
ZLOGI(TAG, "init can bus end..."); |
|||
|
|||
/*******************************************************************************
|
|||
* 初始化FEITE BUS * |
|||
*******************************************************************************/ |
|||
ZLOGI(TAG, "init feite bus"); |
|||
ZASSERT(huart3.Init.BaudRate == 115200); |
|||
m_feitebus.initialize(&huart3, &hdma_usart3_rx, &hdma_usart3_tx); |
|||
|
|||
/*******************************************************************************
|
|||
* 初始化MODBUS总线 * |
|||
*******************************************************************************/ |
|||
m_modbus.initialize(&huart2, &hdma_usart2_rx, &hdma_usart2_tx); |
|||
} |
|||
|
|||
#define REG_SUB_MODULE(table) \
|
|||
for (size_t i = 0; i < sizeof(table) / sizeof(table[0]); i++) { \ |
|||
m_device_manager.registerModule(&table[i]); \ |
|||
} |
|||
|
|||
/**
|
|||
* @brief |
|||
* 子CAN模块初始化 |
|||
*/ |
|||
void Device::sub_module_init() { |
|||
/**
|
|||
* @brief 初始化舵机 |
|||
* 11->16 |
|||
*/ |
|||
static MiniRobotCtrlModule::flash_config_t servo_cfg = {.default_torque = 330}; |
|||
static MiniRobotCtrlModule mini_servo[10]; |
|||
for (size_t i = 0; i < 6; i++) { |
|||
int idnum = 10 + i; |
|||
ZLOGI(TAG, "init servo:%d", idnum); |
|||
mini_servo[i].initialize(idnum, &m_feitebus, idnum, &servo_cfg); |
|||
m_device_manager.registerModule(&mini_servo[i]); |
|||
} |
|||
/**
|
|||
* @brief 初始化主轴电机 |
|||
*/ |
|||
static Eq20ServoMotor eq20_motor; |
|||
eq20_motor.init(1, &m_modbus, 1); |
|||
m_device_manager.registerModule(&eq20_motor); |
|||
|
|||
/**
|
|||
* @brief 初始化XY平台 |
|||
*/ |
|||
static ZIProtocolProxy xyboard_module_proxy[2]; |
|||
xyboard_module_proxy[0].initialize(20, &m_zcanbus); // BOARD2 XY轴板子
|
|||
xyboard_module_proxy[1].initialize(21, &m_zcanbus); |
|||
REG_SUB_MODULE(xyboard_module_proxy); |
|||
|
|||
/**
|
|||
* @brief 初始化Z轴上的设备 |
|||
*/ |
|||
static ZIProtocolProxy z_axis_board_can_module_proxy[4]; |
|||
z_axis_board_can_module_proxy[0].initialize(30, &m_zcanbus); // BOARD3 Z轴板子
|
|||
z_axis_board_can_module_proxy[1].initialize(31, &m_zcanbus); |
|||
z_axis_board_can_module_proxy[1].initialize(32, &m_zcanbus); |
|||
z_axis_board_can_module_proxy[2].initialize(33, &m_zcanbus); |
|||
REG_SUB_MODULE(z_axis_board_can_module_proxy); |
|||
|
|||
/**
|
|||
* @brief 初始化 |
|||
* CAN步进电机模块 |
|||
*/ |
|||
static ZIProtocolProxy can_step_motor_proxy[6]; |
|||
can_step_motor_proxy[0].initialize(40, &m_zcanbus); // BOARD4
|
|||
can_step_motor_proxy[1].initialize(41, &m_zcanbus); |
|||
|
|||
can_step_motor_proxy[2].initialize(50, &m_zcanbus); // BOARD5
|
|||
can_step_motor_proxy[3].initialize(51, &m_zcanbus); |
|||
|
|||
can_step_motor_proxy[4].initialize(60, &m_zcanbus); // BOARD6
|
|||
can_step_motor_proxy[5].initialize(61, &m_zcanbus); |
|||
REG_SUB_MODULE(can_step_motor_proxy); |
|||
} |
|||
|
|||
void Device::line_locking_solenoid_valve_init() {} |
|||
void Device::line_locking_solenoid_valve(bool on) {} |
@ -0,0 +1,94 @@ |
|||
#pragma once
|
|||
|
|||
#include "sdk/os/zos.hpp"
|
|||
#include "sdk\components\flash\zsimple_flash.hpp"
|
|||
#include "sdk\components\zcancmder\zcanreceiver.hpp"
|
|||
#include "sdk\components\zcancmder_module\zcan_basic_order_module.hpp"
|
|||
#include "sdk\components\zprotocols\zcancmder_v2\protocol_parser.hpp"
|
|||
//
|
|||
#include "sdk\components\flash\znvs.hpp"
|
|||
//
|
|||
#include "sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp"
|
|||
#include "sdk\components\cmdscheduler\cmd_scheduler_v2.hpp"
|
|||
#include "sdk\components\hardware\uart\zuart_dma_receiver.hpp"
|
|||
#include "sdk\components\mini_servo_motor\mini_servo_motor_ctrl_module.hpp"
|
|||
#include "sdk\components\modbus\modbus_block_host.hpp"
|
|||
#include "sdk\components\pipette_module\pipette_ctrl_module_v2.hpp"
|
|||
#include "sdk\components\sensors\m3078\m3078_code_scaner.hpp"
|
|||
#include "sdk\components\sensors\tmp117\tmp117.hpp"
|
|||
#include "sdk\components\ti\drv8710.hpp"
|
|||
#include "sdk\components\tmc\ic\ztmc5130.hpp"
|
|||
#include "sdk\components\water_cooling_temperature_control_module\pwm_ctrl_module.hpp"
|
|||
#include "sdk\components\water_cooling_temperature_control_module\water_cooling_temperature_control_module.hpp"
|
|||
#include "sdk\components\zcancmder\zcan_board_module.hpp"
|
|||
#include "sdk\components\zcancmder\zcanreceiver_master.hpp"
|
|||
#include "sdk\components\zprotocol_helper\micro_computer_module_device_script_cmder_paser.hpp"
|
|||
#include "sdk\components\zprotocols\zcancmder_v2\protocol_proxy.hpp"
|
|||
#include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_manager.hpp"
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
|
|||
typedef enum { |
|||
|
|||
// 主轴绕线电机
|
|||
kdevice_widing_motor = 1, |
|||
// 线锁死电磁阀
|
|||
kdevice_line_locking_solenoid_valve = 2, |
|||
|
|||
// 退线舵机
|
|||
kdevice_back_line_servo_motor = 10, |
|||
// 线宽探测舵机
|
|||
kdevice_line_width_servo_motor = 11, |
|||
// 压线舵机
|
|||
kdevice_press_line_servo_motor = 12, |
|||
// 线引导舵机
|
|||
kdevice_line_guide_servo_motor = 13, |
|||
// 线夹舵机
|
|||
kdevice_line_clamp_servo_motor = 14, |
|||
// 线拉紧舵机
|
|||
kdevice_line_tighten_servo_motor = 15, |
|||
|
|||
// XY平台
|
|||
kdevice_xy_platform = 21, |
|||
|
|||
// Z轴
|
|||
kdevice_z_axis_motor = 31, |
|||
// Z轴压线电机
|
|||
kdevice_z_axis_press_line_motor = 32, |
|||
// Z轴梭夹
|
|||
kdevice_z_axis_shuttle_clamp = 33, |
|||
|
|||
} sub_device_list_t; |
|||
|
|||
class Device { |
|||
ZModuleDeviceManager m_device_manager; |
|||
CmdSchedulerV2 m_uart_cmdline_parser; |
|||
|
|||
ModbusBlockHost m_modbus; |
|||
/*******************************************************************************
|
|||
* CAN_BUS * |
|||
*******************************************************************************/ |
|||
ZCanCommnaderMaster m_zcanbus; |
|||
/*******************************************************************************
|
|||
* FEI_TE_BUS * |
|||
*******************************************************************************/ |
|||
FeiTeServoMotor m_feitebus; |
|||
/*******************************************************************************
|
|||
* SUB CAN MODULE * |
|||
*******************************************************************************/ |
|||
public: |
|||
void init(); |
|||
|
|||
/**
|
|||
* @brief 锁线电磁阀控制 |
|||
*/ |
|||
void line_locking_solenoid_valve_init(); |
|||
void line_locking_solenoid_valve(bool on); |
|||
|
|||
private: |
|||
void init_uart_cmder(); |
|||
void init_dm(); |
|||
void init_bus(); |
|||
void sub_module_init(); |
|||
}; |
|||
} // namespace iflytop
|
@ -1,9 +0,0 @@ |
|||
|
|||
#include "sdk\components\zcancmder\zcanreceiver_master.hpp"
|
|||
namespace iflytop { |
|||
ZGPIO g_Key0; |
|||
ZGPIO g_Key1; |
|||
ZGPIO g_Key2; |
|||
ZGPIO g_StateLight1; |
|||
ZCanCommnaderMaster g_zcanCommnaderMaster; |
|||
} // namespace iflytop
|
@ -1,10 +0,0 @@ |
|||
#pragma once
|
|||
#include "sdk\components\zcancmder\zcanreceiver_master.hpp"
|
|||
|
|||
namespace iflytop { |
|||
extern ZGPIO g_Key0; |
|||
extern ZGPIO g_Key1; |
|||
extern ZGPIO g_Key2; |
|||
extern ZGPIO g_StateLight1; |
|||
extern ZCanCommnaderMaster g_zcanCommnaderMaster; |
|||
} // namespace iflytop
|
@ -1,89 +0,0 @@ |
|||
#include <stddef.h>
|
|||
#include <stdio.h>
|
|||
|
|||
#include "sdk/os/zos.hpp"
|
|||
#include "sdk\components\flash\zsimple_flash.hpp"
|
|||
#include "sdk\components\zcancmder\zcanreceiver.hpp"
|
|||
#include "sdk\components\zcancmder_module\zcan_basic_order_module.hpp"
|
|||
#include "sdk\components\zprotocols\zcancmder_v2\protocol_parser.hpp"
|
|||
//
|
|||
#include "sdk\components\flash\znvs.hpp"
|
|||
//
|
|||
#include "sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp"
|
|||
#include "sdk\components\cmdscheduler\cmd_scheduler_v2.hpp"
|
|||
#include "sdk\components\hardware\uart\zuart_dma_receiver.hpp"
|
|||
#include "sdk\components\mini_servo_motor\mini_servo_motor_ctrl_module.hpp"
|
|||
#include "sdk\components\pipette_module\pipette_ctrl_module_v2.hpp"
|
|||
#include "sdk\components\sensors\m3078\m3078_code_scaner.hpp"
|
|||
#include "sdk\components\sensors\tmp117\tmp117.hpp"
|
|||
#include "sdk\components\ti\drv8710.hpp"
|
|||
#include "sdk\components\tmc\ic\ztmc5130.hpp"
|
|||
#include "sdk\components\water_cooling_temperature_control_module\pwm_ctrl_module.hpp"
|
|||
#include "sdk\components\water_cooling_temperature_control_module\water_cooling_temperature_control_module.hpp"
|
|||
#include "sdk\components\zcancmder\zcan_board_module.hpp"
|
|||
#include "sdk\components\zcancmder\zcanreceiver_master.hpp"
|
|||
#include "sdk\components\zprotocol_helper\micro_computer_module_device_script_cmder_paser.hpp"
|
|||
#include "sdk\components\zprotocols\zcancmder_v2\protocol_proxy.hpp"
|
|||
#include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_manager.hpp"
|
|||
#include "string.h"
|
|||
// #include "M3078CodeScanner"
|
|||
#include "global.hpp"
|
|||
|
|||
#define TAG "main"
|
|||
using namespace iflytop; |
|||
using namespace std; |
|||
|
|||
uint32_t m_rxbufsize; |
|||
bool m_dataisready = false; |
|||
char m_cmdcache[1024] = {0}; |
|||
|
|||
void transparent_version_main() { |
|||
chip_cfg_t chipcfg; |
|||
chipcfg.us_dleay_tim = &PC_SYS_DELAY_US_TIMER; |
|||
chipcfg.tim_irq_scheduler_tim = &PC_SYS_TIM_IRQ_SCHEDULER_TIMER; |
|||
chipcfg.huart = NULL; |
|||
chipcfg.debuglight = PC_DEBUG_LIGHT_GPIO; |
|||
|
|||
chip_init(&chipcfg); |
|||
|
|||
zos_cfg_t zoscfg; |
|||
zos_init(&zoscfg); |
|||
|
|||
ZLOGI(TAG, "boardId:%d", 0); |
|||
|
|||
ZLOGI(TAG, "init can bus"); |
|||
auto* m_zcanCommnaderMaster_cfg = g_zcanCommnaderMaster.createCFG(); // can×ÜÏßÅäÖÃ
|
|||
g_zcanCommnaderMaster.init(m_zcanCommnaderMaster_cfg); // can×ÜÏß
|
|||
ZLOGI(TAG, "init can bus end..."); |
|||
|
|||
static ZUARTDmaReceiver dmaUartReceiver; |
|||
static CmdSchedulerV2 cmder; |
|||
ZUARTDmaReceiver::hardware_config_t cfg = { |
|||
.huart = &PC_DEBUG_UART, |
|||
.dma_rx = &PC_DEBUG_UART_DMA_HANDLER, |
|||
.rxbuffersize = PC_DEBUG_UART_RX_BUF_SIZE, |
|||
.rxovertime_ms = 3, |
|||
}; |
|||
ZLOGI(TAG, "init cmder"); |
|||
dmaUartReceiver.initialize(&cfg); |
|||
dmaUartReceiver.startRx([](uint8_t* data, size_t len) { |
|||
if (!m_dataisready) { |
|||
memcpy(m_cmdcache, data, len); |
|||
m_rxbufsize = len; |
|||
m_dataisready = true; |
|||
} |
|||
}); |
|||
|
|||
g_zcanCommnaderMaster.regRawPacketListener([](uint8_t* packet, size_t len) { //
|
|||
HAL_UART_Transmit(&PC_DEBUG_UART, packet, len, 1000); |
|||
osDelay(5); |
|||
}); |
|||
|
|||
while (true) { |
|||
OSDefaultSchduler::getInstance()->loop(); |
|||
if (m_dataisready) { |
|||
g_zcanCommnaderMaster.sendRawPacket((uint8_t*)m_cmdcache, m_rxbufsize); |
|||
m_dataisready = false; |
|||
} |
|||
} |
|||
}; |
@ -1,3 +0,0 @@ |
|||
#pragma once
|
|||
void transparent_version_main(); |
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue