完善资料让更多小伙伴认识你,还能领取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}
举报
觉新醒
萧猎
曲终人散
h1654155918.5821
廖凡
刘爽
疯靡全球
mkx
birdinskydzfsy
梁雄健
观天玉
h1654155916.9258
wzqwzq1012
永恒☆
任我行1205
1948896143
还有神秘人
电子工程师2014
发布
谁知道这个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 16:39 , Processed in 0.982277 second(s), Total 78, Slave 67 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com