I have an idea to control lots of (>10) servos from a PIC at the same time.
Normaly everbody would choose this way to control multiple servos:
High Ch1pin 'Or pulseout pin,ch1
Pause ch1
low Ch1pin
High Ch2pin
Pause ch2
low Ch2pin
High Ch3pin
Pause ch3
low Ch3pin
This is uneffecient, and its also limits the maximum servo number
becasuse a servo needs to update its position in every 18ms (19mS) (~50Hz).
When using this technic we must run allover every signal sendout.
Its limited to max ~11 servos (@50Hz)
Here is the normal way to send out control signals:
http://kepfeltoltes.hu/view/060913/O...toltes.hu_.gif
There is a another solution, when we set High all Ch pins
and give out a pause command, length of the first pause is the lowest ch time ,after the pause, Low the smallest ch pin.
Then we have to figure out wich is the next lowest ch,then subtract the previous ch from this.
We get a delta time. Give pause out for delta time, then Low the second lowest ch pin. Then search for the third lowest ch, subtrack the previous ch, pause delta time,low pin, search for the 4th lowest... and all over for all n servos.
Here is the Faster way:
http://kepfeltoltes.hu/view/060913/M...toltes.hu_.gif
we have ch1,ch2,ch3,ch4,ch5,ch6,...ch(n) VAR byte 'for 8bit control
ch1 is RB0,ch2 is RB1 ............
1, High all servo pins (RB0,RB1....)
2, find the smallest ch
3, pause for smallest ch time
4, low smallest ch pin
5, find next! smallest ch
6, subtract the previous from it
7, pause for delta time
8, low the ch pin
9, goto 5
it would be very nice when we could put in a loop (for,repeat,while)
The limits of the servo number is really just the pin number of the microcontroller
Some idea for the structure, to find the lowest ch:
'---------
For i=0 to (# of the servos)
Select case Ch# 'current servo
case is > ch1
..?
case is > ch2
..?
case is > ch3
..?
.
.
.
End select
Next i
'--------
of course its not so simple, but please help me how to code this.
Thx
Bookmarks