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 support@ccsinfo.com

Analog to PWM controlling

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Aamir



Joined: 11 Apr 2010
Posts: 13

View user's profile Send private message

Analog to PWM controlling
PostPosted: Sun Apr 11, 2010 2:19 pm     Reply with quote

I am working on a robotic structure using PIC16F877A and servo motors. There are 6 motors in all, controlling them all was not an issue. But one servo needs to be controlled via analog input which is creating a confusion.

So is there any help regarding controlling the servo (PWM) from analog input of PIC??
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 11, 2010 2:29 pm     Reply with quote

Quote:

So is there any help regarding controlling the servo (PWM) from analog input of PIC?

http://www.ccsinfo.com/forum/viewtopic.php?t=40007&start=1
Aamir



Joined: 11 Apr 2010
Posts: 13

View user's profile Send private message

PostPosted: Sun Apr 11, 2010 2:48 pm     Reply with quote

Well I guess I have been through this code, but the problem is would I be able to provide PWM on all 6 motors simultaneously? Right now what I have done is to provide a high signal, delay, a low signal and delay such that it makes 50Hz of desired duty cycle. And somehow I managed to code them in such a way that all motors are working in 'simultaneously'.

Now the issue is will this CCP1 effect in my programming?
bungee-



Joined: 27 Jun 2007
Posts: 206

View user's profile Send private message

PostPosted: Sun Apr 11, 2010 2:56 pm     Reply with quote

PCM programmer, I think that Aamir wants to control RC servo, not an usual PWM.

For RC servo, do a little search here on forum it was quite some topics written on the subject. For RC servo you need to send 50Hz pulses with this specifics: pulse length (on time) must be from ~1ms to 2ms and the rest ~19ms is off time.

Depending on pulse width the servo position will be, generally 1ms is full left, 1.5ms is middle and 2ms is full right .... this times will vary depending on manufacturer.

So what you need to do is to convert your analog input to different pulse "delays"
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 11, 2010 3:20 pm     Reply with quote

Quote:

I think that Aamir wants to control RC servo, not an usual PWM.

http://www.ccsinfo.com/forum/viewtopic.php?t=34560&start=22
Aamir



Joined: 11 Apr 2010
Posts: 13

View user's profile Send private message

PostPosted: Mon Apr 12, 2010 2:46 pm     Reply with quote

Yes exactly, I am working on RC servos. But here is what I am currently doing.

I have 6 motors, all will operate in predefined movements. But one motor (actually the gripper for robotic arm) must move as per the input of force sensor (analog input).

Now what I need is to control the positions of this motor without using CCP pins, as they may cause the other operations to with held while I am providing pulses to all 6 motors.

To make things more clear I want this work done by PIC, rather than 555 Timer
http://www.youtube.com/watch?v=u8vr6nMSh80

But please I want a solution without using CCP as it may disturb my other motors process, or not??
John P



Joined: 17 Sep 2003
Posts: 331

View user's profile Send private message

PostPosted: Tue Apr 13, 2010 6:52 am     Reply with quote

I don't see how this is a big problem. You start the A/D at some point in the 1/50 sec cycle, maybe when one of the other servos starts its pulse. You grab the result of the A/D and turn it into a pulse width for the 6th servo, maybe ahead of time or maybe at the last moment when servo 6 starts its pulse. But servo 6 just operates the same way as the other 5. Have I missed something here?
Aamir



Joined: 11 Apr 2010
Posts: 13

View user's profile Send private message

PostPosted: Tue Apr 13, 2010 1:14 pm     Reply with quote

well here is what i am doing
Code:
#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT
#use delay(clock=20000000)

#bit grey=7.0
#bit orange=7.1
#bit yellow=7.2
#bit white=7.3
#bit blue=7.4
#bit green=7.5

void main (void)
{
set_tris_c(0);
while(1)
{
do
{
grey=orange=yellow=green=white=blue=1;
delay_us(1500);
grey=0;
delay_us(100);
orange=yellow=0;
delay_us(100);
white=0;
delay_us(100);
green=0;
delay_us(100);
blue=0;
delay_us(18100);
}while(!input(PIN_E1));
}
}


'green' is the motor i want to stop in accordance with ADC input.
can anyone help me out in this??
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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