0

我是 PIC 粉丝。我没有用过arduino。但是当我用 pic 控制舵机时遇到了问题。

1)当 PIC 控制伺服时,它不能做任何其他事情。因此在此期间它无法获得传感器读数。

2)将伺服驱动到某个位置后,现在当pic正在做其他事情时,pic不再在伺服连接引脚中产生pwm信号。所以伺服可能会因负载而旋转回来。

现在我的第一个问题是arduino会在代码之后在附加的引脚中连续生成脉冲吗

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

或者是否有任何库可以在 mikroc 中使用 PIC 控制多舵机以避免上述问题。

或者最好使用两个 PIC 一个仅驱动伺服器,另一个用于处理和传感器读取,并使用 I2C 连接它们。

请我需要专家的帮助。请回复。谢谢你...

4

2 回答 2

1

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!

于 2013-10-15T16:22:17.810 回答
0

我正在计划一个类似的项目,使用 PIC16F872 来控制伺服电机。我正在考虑使用 32 kHz 晶体来获得 35Hz 的 PWM 和以 1.05 mS 为中心的脉冲宽度。就我而言,我将首先进行 A/D 测量;然后在需要时运行电机。电机将持续发出信号,直到“停止”开关向 PIC 发出中断。我应该提一下,我已经通过断开反馈电位器来修改伺服以实现连续运行。

于 2013-10-16T20:20:30.663 回答