CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Pwm with pulsin.c base
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Feb 10, 2016 11:52 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Feb 10, 2016 12:01 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Feb 10, 2016 12:05 pm     Reply with quote

Yes, that's it jay!
Ttelmah



Joined: 11 Mar 2010
Posts: 19550

View user's profile Send private message

PostPosted: Wed Feb 10, 2016 12:23 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Feb 10, 2016 12:47 pm     Reply with quote

Ok I'll look for a pic with more hardware PWM.
Ttelmah



Joined: 11 Mar 2010
Posts: 19550

View user's profile Send private message

PostPosted: Wed Feb 10, 2016 3:24 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Feb 10, 2016 3:38 pm     Reply with quote

I will test and then post the results. thank you
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group