资源简介
喷墨打印机单片机驱动,写字机,激光雕刻机,点胶机,绘画机,笔式打印机
代码片段和文件信息
/*The MIT License (MIT)
Copyright (c) 2014 Leonardo Ciocari
Permission is hereby granted free of charge to any person obtaining a copy
of this software and associated documentation files (the “Software“) to deal
in the Software without restriction including without limitation the rights
to use copy modify merge publish distribute sublicense and/or sell
copies of the Software and to permit persons to whom the Software is
furnished to do so subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND EXPRESS OR
IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER
LIABILITY WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING FROM
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
//COMMAND EXAMPLES (With CNC at reset position “x00000y00000z1“):
//x000147y000147z1 - Invalid can‘t move X and Y axis with Z down
//x000147y000147z2 - Valid can move X and Y axis with Z up (will move X first then Y)
//x000147y000000z1 - Valid can move X to 00147 from actual 00000 position
//x000000y000294z1 - Valid can move Y to 00294 from actual 00000 position
//#include
#include
#include
#include “defineports.h“
__CONFIG(INTIO & WDTDIS & MCLRDIS & BORDIS & LVPDIS);
#define SERIAL_TIMEOUT 65530
unsigned int xStepDelay = 100; //X轴脉冲中的间隔时间
unsigned int yStepDelay = 120; //Y轴脉冲中的间隔时间
unsigned int zStepDelay = 80; //Z轴脉冲中的间隔时间,Z轴是软驱电机,启动频率不能太高
unsigned int xMinStepDelay = 50; //电机性能不好,速度无法提高,特使用一个加速过程
unsigned int yMinStepDelay = 60; //电机性能不好,速度无法提高,特使用一个加速过程
unsigned int stepDelayCnt = 100; //每隔多少步后开始升速,设置为0则为固定值
//延时函数,一个循环刚好10个指令,在最后加上函数调用的花销7个指令即可。
//假定4m晶体,则:
//延时0.5ms可以用:delayit(50)
//延时1ms可以用:delayit(100)
//延时10ms可以用:delayit(1000)
void delayit(unsigned int d)
{
while(--d){;}
}
//直接移动多少步,moveLeft=1为向左,=0为向右
void Xmove(unsigned int steps unsigned char moveLeft)
{
unsigned int n;
unsigned int delayNum;
unsigned char runnedStep;
if (steps == 0)
return;
if (moveLeft)
X_DIR = 1;
else
X_DIR = 0;
delayNum = xStepDelay; //兼顾不丢步和速度考虑,使用一个加速过程
runnedStep = 0;
for (n = steps; n > 0; n--)
{
if ((moveLeft && (X_STOP_SW_LEFT == 0))
|| (!moveLeft && (X_STOP_SW_RIGHT == 0)))
break;
X_STEP = 1; //上升沿启动
delayit(delayNum);
X_STEP = 0;
delayit(delayNum);
if ((stepDelayCnt > 0) && (++runnedStep >= stepDelayCnt)) //每隔一定的步数提升一次速度
{
runnedStep = 0;
if (delayNum > xMinStepDelay
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-05-08 01:56 PrinterCnc-master\
目录 0 2016-05-08 01:56 PrinterCnc-master\Eagle\
文件 40507 2016-05-08 01:56 PrinterCnc-master\Eagle\import_bmp_as_wire.ulp
目录 0 2016-05-08 01:56 PrinterCnc-master\Firmware\
文件 9676 2016-05-08 01:56 PrinterCnc-master\Firmware\Main.c
文件 556 2016-05-08 01:56 PrinterCnc-master\Firmware\cmdlist.md
文件 659 2016-05-08 01:56 PrinterCnc-master\Firmware\defineports.h
文件 3960 2016-05-08 01:56 PrinterCnc-master\Firmware\myPrinterCnc.X.production.hex
文件 1084 2016-05-08 01:56 PrinterCnc-master\LICENSE
目录 0 2016-05-08 01:56 PrinterCnc-master\Photos\
文件 103474 2016-05-08 01:56 PrinterCnc-master\Photos\DC电机加光栅条结构.JPG
文件 168520 2016-05-08 01:56 PrinterCnc-master\Photos\DC电机驱动板.JPG
文件 149257 2016-05-08 01:56 PrinterCnc-master\Photos\DC电机驱动板电路图.JPG
文件 202912 2016-05-08 01:56 PrinterCnc-master\Photos\DC电机驱动板背面.JPG
文件 179637 2016-05-08 01:56 PrinterCnc-master\Photos\JDM编程器.JPG
文件 222494 2016-05-08 01:56 PrinterCnc-master\Photos\X轴步进电机齿轮组正面.JPG
文件 262990 2016-05-08 01:56 PrinterCnc-master\Photos\X轴步进电机齿轮组背面.JPG
文件 220339 2016-05-08 01:56 PrinterCnc-master\Photos\Y轴支撑平台固定角铝.JPG
文件 215146 2016-05-08 01:56 PrinterCnc-master\Photos\Z轴笔架固定特写.JPG
文件 115890 2016-05-08 01:56 PrinterCnc-master\Photos\上位机.JPG
文件 253172 2016-05-08 01:56 PrinterCnc-master\Photos\墨车固定和Z轴特写.JPG
文件 211207 2016-05-08 01:56 PrinterCnc-master\Photos\打印龙字.JPG
文件 214115 2016-05-08 01:56 PrinterCnc-master\Photos\扫描仪组件改装.JPG
文件 274305 2016-05-08 01:56 PrinterCnc-master\Photos\控制板盒子.JPG
文件 195889 2016-05-08 01:56 PrinterCnc-master\Photos\整机正面.JPG
文件 324172 2016-05-08 01:56 PrinterCnc-master\Photos\最终控制板.JPG
文件 172965 2016-05-08 01:56 PrinterCnc-master\Photos\最终洞洞板背面.JPG
文件 259006 2016-05-08 01:56 PrinterCnc-master\Photos\最终洞洞板(没EasyDriver).JPG
文件 215627 2016-05-08 01:56 PrinterCnc-master\Photos\滚轮特写.JPG
文件 259275 2016-05-08 01:56 PrinterCnc-master\Photos\第一次尝试洞洞板.JPG
文件 4588 2016-05-08 01:56 PrinterCnc-master\README.md
............此处省略60个文件信息
- 上一篇:BMS-LTC6803-stm32
- 下一篇:礼物特效.rar
评论
共有 条评论