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

digital servo & analog servo

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



Joined: 20 Apr 2013
Posts: 50

View user's profile Send private message

digital servo & analog servo
PostPosted: Sat Apr 20, 2013 6:34 pm     Reply with quote

Hello everyone,
I'm designing a program for driving rc servo motor, but i have a problem,
the digital servo motor is not working with the same code as the analog servo motor.
This is my code:
Code:

float value;
int16 i, math_value;
void main()
{
   lcd_init();
   delay_us(10);
   
   setup_adc_ports(AN0);
   setup_adc(ADC_CLOCK_INTERNAL);
   
   set_adc_channel(0);
   delay_us(15);
   
   While(true)
   {
      value = read_adc();
      math_value = ((value * 1.61) + 650);
     
      output_high(PIN_B1);
      delay_us(math_value);
      output_low(PIN_B1);
      delay_us(4000 - math_value);
     
      lcd_gotoxy (1,0);
      printf(LCD_PUTC, "%lu  ", math_value);
   }
}


This code simply take the value from ADC and use it as the width of the pulse range from 650--2200 us (Not all servo follow standard pulse width).

My question is, Is this code reliable (or there is something better), and how can I operate digital servo motor?
Need help please!
Thanks in advance,
z3ngew
Ttelmah



Joined: 11 Mar 2010
Posts: 19451

View user's profile Send private message

PostPosted: Sun Apr 21, 2013 1:10 am     Reply with quote

Your timings are pushing the legal range. Now most traditional servos don't mind this, but more sophisticated units will ignore pulses outside the normal range. The 'standard' for servos, is 1.5mSec centre. 1mSec to 2mSec for the legal travel range, with maximum 'overrange' of 0.6 to 2.4mSec. Traditional servos allow these overrange times to be used, and in some cases even allow you to go beyond these, but modern units don't. Radios, will stick to these timings, usually with about 10% margin when trims are used. Futaba for instance on some of their digital units, now use a pulse time below 0.8mSec, as an 'error' flag, and stop moving.

Linked to this, there are two servo signalling standards. Generally digital units will support higher frequency updates. The 'old' standard 50Hz update, and later 'high speed' standards (270Hz, 333Hz, and 400Hz). On the old standard, the radio generates a sequence of servo pulses one after another, in a 20mSec (sometiimes 25mSec) 'frame'. The receiver then decoded these, sending the first pulse to the first servo, second to the second etc., so there was just one pulse every 20mSec, and gaps between. With the later signalling standards, the gaps are massively reduced. The pulse train to each servo is continuous, with one pulse every 2.5mSec (400Hz). In some cases units supporting the higher speed standards also require pulses that are shorter. The 300Hz standard for example, requires pulses 1/6th the standard width. However (oddly), the 400Hz standard retains the standard pulse widths, but with a absolute maximum width allowed of 2.14mSec (and, yes', it is specified to 2DP!...).
Servos built to support the 400Hz standard, will normally retain this upper limit even when running at 50Hz. HiTec for instance specify the pulse range for their digital servos as 840uSec to 2140uSec.
Generally digital servos _require_ the timing to be accurate. No more than 20mSec pulse repeat time, and correct pulse widths.

Errors you could get away with on traditional servos, will be blocked by digital units.

Best Wishes
temtronic



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

View user's profile Send private message

PostPosted: Sun Apr 21, 2013 5:59 am     Reply with quote

HAY T, That's a great explanation on RC servos !! Yeesh...seems yet another 'standard' from the early days has been 'modified'....

I can't keep up,getting too old for it, I'd rather fix good old Teletypes and wirewrap projects!

cheers
jay
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sun Apr 21, 2013 9:07 am     Reply with quote

Quote:

50Hz update


i have worked with several models of newer digital servos that need NO REFRESH at all. ( so long as power is not interrupted)

simply sending the position data TWICE does the trick
( once to wake the servo if sleep and again , 50 ms later to make sure it is set )

used in a medical research device with no problems at all.
periodic refresh is the greatest shortcoming of all cheapie
hobby servos IMHO, and being freed of it is a huge blessing... Very Happy

and as to resolution, my standard is control in 500ns increments using a 16mhz master xtal clock , and timer control of the delays- NOT CCS delay_??();
Ttelmah



Joined: 11 Mar 2010
Posts: 19451

View user's profile Send private message

PostPosted: Sun Apr 21, 2013 9:24 am     Reply with quote

Yes, once they have received a legal position, the digital servos will normally just sit and hold. However there is a caveat to them, that they generally draw more power than traditional servos. It can be quite surprising just how much power they do draw just to stay still. Beware if your supply can't handle significant pulse currents.....

Best Wishes
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