完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
VPOWEREXP.pdfTOPLAYER.pdfBOTTONLAYER.pdfVPOWER.pdsprj
PIC18F4550单片机20MHz晶振3到6个LED(PCB上只使用了3个)3个220欧姆电阻(用于LED)2个10nF陶瓷电容2个18nF陶瓷电容L293D或SN7544(电机驱动模块)开关三个按钮7805三端稳压器(为单片机提供5V电压)线材等
void MotorsSpeed(int A,int B){///If mode equals alfa then we invert the motors voltage MotorASpeed(MODE == ALFA ? A : B); MotorBSpeed(MODE == BETA ? A : B);}void MotorASpeed(int S){S = min(S,1000); S = max(S,-1000); ADIR = S > 0 ? 0 : 1; S = S > 0 ? S : 1000 + S; CCP1CONbits.DC1B1 = S % 4; CCPR1L = S / 4;}void MotorBSpeed(int S){ S = min(S,1000); S = max(S,-1000); BDIR = S > 0 ? 0 : 1; S = S > 0 ? S : 1000 + S; CCP2CONbits.DC2B = S % 4; CCPR2L = S / 4;}
void LineFollow(){ double kp,kd,kr,speed;///POSICION has the value of the center of the line previously calculated kp = KP[speedMode]; kd = KD[speedMode]; kr = KR[speedMode]; DER = POSICION - LP; ///We calculate how much the line has moved from the last iteration PIDf = (POSICION* kp + DER * kd); if (PIDf > 0){ MotorsSpeed(Mr(speed-PIDf,kr) , speed); ///Mr makes the value to multiply by KR if it is negative. You can delete it }else{ MotorsSpeed(speed , Mr(speed+PIDf,kr) ); ///Mr makes the value to multiply by KR if it is negative. You can delete it } LP = POSICION; ///We store the last line position}
举报
苏辉
梵音solo
BAO12345678
Walker。Clown
电源新手
林
张金权
haohao833
万子藤
刘先行
王朋
贤达
小新鲜
陳
谢海嘉
韩生
Blank4826664
张
chaoyueTX
杨鑫杰
发布
谁知道这个16脚的芯片是什么型号2-15脚输出的互补的450KHZ方波电流达到200MA
391 浏览 0 评论
【开源项目】做一只由 OpenCV 控制的仿生手
555 浏览 0 评论
【开源项目】你准备好DIY一款功能强大的机器人了吗?
1239 浏览 0 评论
DIY音箱,有没有推荐的软件?
1089 浏览 0 评论
开源项目!基于Arduino做的“鱿鱼游戏”BOSS面具,支持动作检测
675 浏览 0 评论
电子发烧友网
电子发烧友论坛
查看 »
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-21 18:31 , Processed in 0.848924 second(s), Total 77, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com