السلام عليكم
إليك هذا الكود أخي الكريم لدارة كنت قد صممتها لهذا الغرض يمكن بواستطها التحكم
ب أكثر من 10 موتورات بنفس الوقت و لكن بسرعة واحدة و بمنفذ PWM واحد طبعا لا تنسى وحدات الاستطاعة الخاصة بقيادة المحرك و طبعا هو المحرك DC عادي ...
أتركك مع الكود و المخطط و أي سؤال أنا تراني جاهز :

و الكود واضح و اسئل قد مابدك ........
كود:
//in the name of allah
//this project designed by Eng.Nour p.4
//with this simple project you can use two motor and one ccp port to
//control the speed of two motor this code show how you can move the
//motor street or back ..... but you can move right or lift try and enjoy ..
//don't forget to connect Transistor with motor because the high amp....
//don't forget :If you want to say "thank you" please pray for me to be better....
void motor()
{
pwm_change_duty(150);
delay_ms(1000);
pwm_change_duty(175);
delay_ms(1000);
pwm_change_duty(200);
delay_ms(1000);
pwm_change_duty(225);
delay_ms(1000);
}
void main ()
{
TRISB=0;
PORTB=0;
PORTB.F6=1; //RIGHT MOTOR MOVE STREET
PORTB.F7=0; //LIFT MOTOR MOVE STREET
delay_ms(1500);
PORTB.F6=0; //RIGHT MOTOR MOVE BACK
PORTB.F7=1; //LIFT MOTOR MOVE BACK
delay_ms(1500);
pwm_Init(250);
pwm_start();
while (1)
{
motor();
}
}