Hi,

So, if I understand, using non-blocking delay is not the best way to do this
at all. If we use blocking delays ("normal" delays), and ISR for serial or
i2c, buffer the received commands, and process them when possible (pwm is
low), questions now are:

 - what if all servos are at max position ? This means no pwm low... so no
time to process buffered commands.
 - postponed the received command processing might be overkill. What will be
the process ? Probably few assignments. Expect maybe when accessing EEPROM.
Buffering commands is probably not useful.
 - when receiving something, this will potentially interrupt pwm while high.
This is the problem you talk about. Let's consider 10µs is long enough to
have impact on position, as you say. This means under 10µs, it's acceptable.
At 20MHz, this is 50 instructions. Could receiving a char through i2c is
done within 50 instructions ? What about serial ? I need to count...


If we go as you suggest, that is: use ISR for PWM (how ?), polling for
i2c/serial:

 - will we miss commands ? For i2c, will the master wait for the slave
before sending a new byte ? For serial, I think it must be possible to loose
chars. My opinion is, for serial, it's acceptable, because i2c is better for
this kind of application (addressable, do use usart often used to
communicate with a PC). Serial is useful to get started, to debug.
 - if we can potentially miss commands, even using i2c, the controller
should be able to send ACK (not i2c ACK, but application ACK), so the
client, errr... the master knows if it's ok, and re-send commands as needed.


Another option is to use an AVR, something like a Tiny*, with 8 PWM
channels.... Real hardware PWM channels.


> Do you think about any other features ?
> calibration data per servo - min and max may vary from servo to servo
> and when you control many servo's, you want the controller to handle
> this corrrection.
>

Good point, I take note of this !


> About PWM software, it should be possible to extract pwm_software.jal
> > library for this. Can be useful in many, many other projects.
> ??? I don't understand what you try to tell us.


Since this is about having lots of PWM channels, and since common PICs only
have one, maybe two channels, PWM must be implemented in software.
Implementing a PWM software channel something usual, I can remember lots of
projects when I do this, just because one PWM channel isn't enough. So,
having a flexible, powerful lib, dedicated to PWM software channel
implementation would be great. On this servo controller, but also on many
other projects.


Cheers,
Seb



> Hi Seb,
>
> Below some remarks, but first the real issue to handle: how do you get
> stable results and deal with interrupts?
> I've made quite a few servo controllers with i2c slave and they all
> suffer from slightly longer pulses every now and then, due to
> interrupts.
> Worst case is when you use blocking delays - a delay any time within
> the pulse will give a longer pulse. And 10us longer is enough to have
> effect on the servo position.
> It is bettter to check a timer (we should have a lib for this since it
> would complete the set of delays), use a ccp unit to restore the line
> (but afaik this will only work on one pin - so not for 8 servo's
> without additional hardware) .
> What might work (but I have not tried this yet) is to use interrupts
> for the servo pulse only and use polling to handle serial and i2c
> slave.
>
> And... non-blocking run at a much too low interval (100us minimal) to
> give a proper resolution.
>
>
> > Looking at the code, I've seen the "isr_counter" pseudo variable. I
> wonder
> > if it would be better to have it named timer0_isr_counter, as there could
> be
> > collision with other potential ISR lib. What's your point on this ?
> I never had this collision and it is unlikely since you probably won't
> have more then one fixed-interval isr (whose purpose in life is to
> increment this counter). So I don't see a reason to change it (but no
> reason to stick to it either, appart that maybe we want to provide the
> same function from an other timer when 0 is in use)
>
>
> >   - can at least handle 8 servos. (maybe more ? What it the max ? Using
> > *blocking* delays, since signal must be sent every 20ms, and since delays
> > can last max 2ms per servo -- or 2.5ms ? --, this gives 20/2 = 10, or
> 20/2.5
> > = 8 servos.
> iirc it is up to 2.5 ms, so 8 will be the limit.
>
> >   - can set position between 0 and 255. O means no signals, 255 means
> max.
> > Should a higher resolution be needed ?
> No, 255 will do.
>
> >
> > Do you think about any other features ?
> calibration data per servo - min and max may vary from servo to servo
> and when you control many servo's, you want the controller to handle
> this corrrection.
>
>
> > About PWM software, it should be possible to extract pwm_software.jal
> > library for this. Can be useful in many, many other projects.
> ??? I don't understand what you try to tell us.
>
> Joep
>
> >
>


-- 
Sébastien Lelong
http://www.sirloon.net
http://sirbot.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to