简体   繁体   中英

PIC or ARDUINO for servo motor controling

Im a PIC fan. I have not used arduino. but I have got a problems when Im going to control servos with pic.

1) when PIc is controlling the servo it cannot do enything else. so during that period it cannot get the sensor readings.

2) after driving the servo to a certain position and now when the pic is doing something else, the pic does not further more generate the pwm signal in the servo connected pin. so the servo may rotate back due to the load.

now my first question is will arduino genarate the pulse continously in the attached pin after the codes

 servo s;
 s.attach(13);
 s.write(120);

or are there eny librarys to control multi servos using PIC in mikroc to avoid the above mentioned problems.

or is it better to use two PICs one to drive servos only and the other for processing and sensor reading, and connect them using I2C.

please I need help from an expert. please reply. thank you...

Yes the Arduino is able to generate the pwm continuously.

Arduino langage is C/C++ with some build in features like analogWrite() for pwm , which make it really easy to program.

Regarding your "when something is running, it can't do anything else" problem, that's one of the major limitation of the Arduino platform as is. You can overcome those limitations by using ISR (Interrupt Service Routine), timers and hardware interrupts .

If you're comfortable with C/C++, you can also use a Real Time Operating System (RTOS) which lets you run think like a regular operating system would: allow cpu time to each task so fast that they seem to run in parallel. But that's not as easy to use as the basic Arduino features, so think carefully if you really need those functions (scheduler, "multi-task", round rubin, etc.)

Hope it helps!

I am planning a similar project, using a PIC16F872, to control a servo motor. I am thinking of using a 32 kHz crystal to have a PWM suitable, of 35Hz and pulse width centred on 1.05 mS. In my case I will first be doing A/D measurements; then when required running the motor. The motor will have a continuous signal until a 'stop' switch gives an interrupt to the PIC. I should mention that I have modified the servo for continuous running by disconnecting the feedback pot.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM