完善资料让更多小伙伴认识你,还能领取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}
举报
不明觉厉、
爱吃鱼的喵
杜峰
刘健东
zcr9527
h1654155272.6760
糟辣子
李琴
紫墨幻歌
杨龙烨
Dangerous24
shine与偶
qa2551902421
刘李贵
精彩人生1021
不知道9768
坏人在此
映途咎晓
发布
谁知道这个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 19:08 , Processed in 0.837948 second(s), Total 77, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com