| View previous topic :: View next topic |
| Author |
Message |
clcheung
Joined: 14 Apr 2008 Posts: 27
|
Posted: Tue Apr 22, 2008 2:59 am Post subject: active notification |
|
|
Hi,
Is there a way for the openservo to notify the twi master when an event occur (say when the motion finish, pwm turn to zero, velocity turn to zero) ?
It seems current it relies on the master to poll and read these status regularly ? |
|
| Back to top |
|
 |
stefanengelke
Joined: 03 Jan 2006 Posts: 59 Location: Stuttgart, Germany
|
Posted: Tue Apr 22, 2008 1:07 pm Post subject: |
|
|
Hi,
at the moment the TWI is implemented as slave only. You would need a multi-master implementation. The avr is capable of the needed arbitration and synchronization but you need to implement this feature for the OpenServo and your current master. When using multi-master mode with many OpenServos there may be a problem that the main controller (your current master) don't get the master role for a while. A solution could be that each OpenServo only transmit one byte with it's address so the main controller knows that this servo needs attention. The scenario would looks like this:
* main controller is the master most of the time
* if it has nothing to say it releases the bus
* if an OpenServo needs attention it tries to get the master role, send it's address to the main controller and releases the bus again
* main controller polls the needed information from the OpenServo
-stefan |
|
| Back to top |
|
 |
clcheung
Joined: 14 Apr 2008 Posts: 27
|
Posted: Tue Apr 22, 2008 1:54 pm Post subject: |
|
|
Hi Stefan
Thank you for the information. I will look into this direction. |
|
| Back to top |
|
 |
ginge Site Admin
Joined: 14 Jan 2006 Posts: 1029 Location: Manchester, UK
|
Posted: Tue Apr 22, 2008 4:30 pm Post subject: |
|
|
There are another options, but not implemented in software, and have many pitfalls.
Option: Interrupt line
The OpenServo connector has a spare pin while in I2C mode called int. (pin 4)
as seen on the Pinout page
It would be trivial to make a patch to toggle this pin based on an event to notify the master.
pitfalls:
* You would have to write code to check for other device events.
* You don't know which device pulled interrupt (unless you encode it) so you need to poll anyway.
* It is yet another line on I2C
Option: Alerts
The OpenServo v3-dev branch has support for alerts based on events. We could add support for alert events based on pretty much any option (pwm is 0 etc) You would still need to poll the servos, but polling one register from each device is much more efficient.
This could additionally be combined with option above to register an alert, and then have the master read the alert code.
Pitfalls:
* Still not an instant notification.
* Can be slow with lots of devices
The last option is to implement another protocol in place of I2C. A 2 line serial protocol would probably work well.
The best method would be to use multi-master mode, but the AVR implementation is pretty terrible and there are many corner cases that have to be carefully coded around. There are extensive threads on www.avrfreaks.net about these issues.
Barry _________________ http://www.headfuzz.co.uk/
http://www.robotfuzz.co.uk/ |
|
| Back to top |
|
 |
clcheung
Joined: 14 Apr 2008 Posts: 27
|
Posted: Wed Apr 23, 2008 11:29 am Post subject: |
|
|
Hi Barry
Thank you for showing me the options. Looks like a simple way is to have the TWI master polling the openservo at appropriate intervals. I will take a look on how complicated is the multi-master mode. |
|
| Back to top |
|
 |
|