View previous topic :: View next topic |
Author |
Message |
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Wed Feb 10, 2016 11:52 am |
|
|
I _think_ he wants to input a pulse width, modify it, and send the new version to an RC servo. Say input=1.2ms, have the PIC modify it to say 1.7ms and send to RC servo.
So his problem is that pulsin() modifies his software PWM code timing.
He really needs to have a 'standalone' hardware PWM routine that will not be afftected by the pulsin() function.
Jay |
|
|
Laus
Joined: 16 Jan 2016 Posts: 17 Location: Brazil
|
|
Posted: Wed Feb 10, 2016 12:01 pm |
|
|
Is simple, want to get PPM pulses from a RC receiver with pic and increase or decrease the time of the positive pulse, and launch this pulse in the pic output to control a "4" servo motor, that is a balance control for a robot wrist increases or decreases with the aid of an analog accelerometer. |
|
|
Laus
Joined: 16 Jan 2016 Posts: 17 Location: Brazil
|
|
Posted: Wed Feb 10, 2016 12:05 pm |
|
|
Yes, that's it jay! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19550
|
|
Posted: Wed Feb 10, 2016 12:23 pm |
|
|
and as Jay says:
"He really needs to have a 'standalone' hardware PWM routine that will not be afftected by the pulsin() function. "
Note _hardware_.
The point is that you can use the CCP, as I said right at the start, to generate timings that sre not affected by the pulse timings.
Pulsin, does not affect the hardware timers.
The point is that the pulsin routine takes variable time, according to the width of the pulses, and the phase relationship of the pulses arriving. To measure all four pulses (and possibly have to wait for all four to arrive), is taking more than the 20mSec gap you want. This is fundamental to the approach being used, which is why the approach needs to change. |
|
|
Laus
Joined: 16 Jan 2016 Posts: 17 Location: Brazil
|
|
Posted: Wed Feb 10, 2016 12:47 pm |
|
|
Ok I'll look for a pic with more hardware PWM. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19550
|
|
Posted: Wed Feb 10, 2016 3:24 pm |
|
|
You don't need more hardware PWM's.
The hardware PWM's, in general, will not be able to give you a timing as slow as you want.
I posted here only a few days ago, a single servo pulse output routine based on the CCP.
Since your outputs are sequential, you can use this repeatedly to give the four outputs.
Then instead of pulsein, use the interrupt on change to record the actual times of the rising and falling edges (reading a hardware timer), of the four inputs.
You can then calculate your new times from these. |
|
|
Laus
Joined: 16 Jan 2016 Posts: 17 Location: Brazil
|
|
Posted: Wed Feb 10, 2016 3:38 pm |
|
|
I will test and then post the results. thank you |
|
|
|