We are trying to build an RC interface to transform a PPM signal from the RC (remote control) into a PWM signal for motor controls. The idea is to build a 2-channel robot that goes forward % back, right & left.

Right now we face the issue that the that we intend to use PIC16F628A to generate this signal, but this chip only has 1 CCP port. As I understand it, the CCP pin is how the PIC detects external interrupts.

So how do I implement the 2 interrupts needed? Do I grab another PIC or is there any way I can use some other pins to handle the required interrupts?

Any help much appreciated

EDIT for clarification: PPM - pulse-position modulation:

The remote control will send a signal that has it's information stored in the duration of the uptime of the pulse. If there are no inputs, the receiver will transmit a pulse of 1.5ms. This will correspond to an output PWM of 0%, the motors that will receive this PWM will not be moving.

If the duration of the PPM pulse is 2ms, this means that the control is moving forward or to the right (depending on the channel being used), and 1ms if the control is moving back or to the left (again depending on the channel)

Currently we are using the PIC in capture mode, as soon as the rising edge of the pulse is detected, we start the timer, which is then only stopped once it detects the falling edge.

This will give us the information we need to send the PWM signal. 2ms means 100%, 1ms means -100%, and 1.5ms means 0% (motors off). An H-bridge will be used to correct the direction of the PWM for the negative values, but this has already been implemented.

We are using this PIC because it's what we have at our school, and some other teams have used it before and it has more references. If there exists another PIC that better does what we intend, please let me know as well, but I'm not sure that is necessary.

  • \$\begingroup\$ Anybody? I really need help with this =/ \$\endgroup\$
    – triplebig
    May 26, 2013 at 21:07

1 Answer 1


First, using abbreviations, especially ones that can have multiple expansions and on a international list is not a good idea. At first I thought "RC" meant resistor capacitor, but maybe you mean remote control instead? Do it right and spell it out, or at least define unusual or ambiguous abbreviations before using them.

Second, you need to read the PIC datasheet. After doing that you will see that this PIC has a number of external interrupts. The CCP module in capture mode can be one source of external interrupt, but there are others. These include the INT pin, the interrupt on change pins, and even the two comparators.

If you plan to use the CCP module as a PWM generator, then you can't use it in capture mode to generate a external interrupt. However, there may be other ways to achieve what you want other using a CCP module. Explain exactly what this "PPM" (another ambiguous abbreviation) signal looks like, what data is encoded by it, and how it is encoded. With that information perhaps we can get clever about interpreting it using some other hardware.

All that said, I see little point is deciding to use such a old PIC, especially if it doesn't really have the hardware you want. There are many many PICs to choose from. Step back and give the real specs of what comes in and what needs to go out of this block, and we can probably help pick a PIC and advise how to use it effectively. For example, some of the 24 bit core parts have a relatively large number of modules that can do CCP-like things. On those, there are separate modules for capture and PWM so they are not called CCP modules.


You now say this block needs to interpret two usual "hobby servo" 1-2 ms pulse signals and produce two bi-directional PWM motor drive outputs accordingly.

The PIC 16F628A is the wrong PIC for this job. Since this is apparently a one-off, there is no point trying to save a $ or two at considerable cost in firmware complexity. Get the right PIC with the right mix of peripherals and have those peripherals do most of the work.

The dsPIC33FJ128MC802 looks like a good candidate after a couple of minutes with Microchip's MAPS parts selector tool. It comes in a 28 pin package, and has both input capture modules and PWM modules. It also has up to 8 motor control PWM outputs, which could allow you to use relatively simple H bridge hardware with the PIC driving each corner of the H bridge from a separate pin.

  • \$\begingroup\$ Sorry if I wasn't clear. I will edit the post in hopes to make it easier for the user to answer my question. \$\endgroup\$
    – triplebig
    May 25, 2013 at 20:51
  • \$\begingroup\$ There it is, is there anything else I may have missed that you think would be useful in answering my question? \$\endgroup\$
    – triplebig
    May 25, 2013 at 21:05
  • \$\begingroup\$ Thank you for the update. Are there any other alternative solutions? I fear that in my nearby electronics store, there won't be a PIC as specific as that (I haven't found some more mainstream versions of PICS there) Also, we don't have time to order one from internet, need to finish this next week Are there any "more complex" hardware solutions to my problem? \$\endgroup\$
    – triplebig
    May 25, 2013 at 22:50
  • \$\begingroup\$ @trip: If you use more external hardware that handles the H bridge more completely, then the PIC only has to produce a polarity and PWM signal per motor. You can also use multiple PICs, like one per channel for example. That means one PIC with two CCP modules would do it. However, in the end it may simply be too late to think about these issues with only a week left in the project. Basically that's bad engineering, and could legitimately result in a bad grade. Plan properly next time. \$\endgroup\$ May 25, 2013 at 23:22
  • \$\begingroup\$ @trip: Another possibility is to use external hardware to convert the incoming pulses to voltage proportional to their widths. That way you don't need to capture anything with accurate timing. A simple A/D input would do it. \$\endgroup\$ May 25, 2013 at 23:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.