Page 1 of 1

I2C, 2-4 PWM generation, PICMicro

PostPosted: Wed Sep 18, 2002 3:38 am
by mwood
We are very interested in using Salvo for an upcomming project of ours. I would like to use a pic 16 series micro-controller, to receive I2C commands and then output 4 PWM servo signals. Do you provide an I2C library, and would I be able to use the SALVO lite version for this? I basically do not want to handle the timing issues of I2C and 4 PWM signals on my own from a single thread.

Thank-you

Mark Woodward
Lockheed Martin Space Systems


Re: I2C, 2-4 PWM generation, PICMicro

PostPosted: Wed Sep 18, 2002 9:15 am
by aek
Hi Mark.

You can use Salvo Lite if you application fits within the confines of Salvo Lite -- e.g. 3 tasks, 5 events, etc. See the Libraries chapter of the Salvo User Manual.

Here's the skinny: We do not provide any library functionality outside of our own API. Therefore any I2C and PWM stuff you do would have to be obtained from the compiler vendor (HI-TECH has some examples and pre-packaged routines), or roll-your-own.

In general, integrating bit-banging into a Salvo app can be approached thusly:

1) Very-high-speed bit-banging should be done with the RTOS disabled, i.e. in a tight loop with interrupts disabled. After all, you don't want critical bit timing to be affected by any other part of the system. Hardware bit-banging falls in this category (i.e. using built-in PWM, etc.). This works especially well for burst-type communications.

2) Very low-speed bit-banging (e.g. slow RS-232, etc.) can be done wholly in software -- see our App Note AN-8 (sofware RS-232) and AN-6 (software PWM) for examples.

3) Intermediate-speed stuff is the most difficult, because the bit times are not fast enough to justify staying inside a tight, interrupt-disabled loop, and are not slow enough to do it in tasks with ms resolutions.

Also, Tx/output is always easier than Rx/input, because in the Rx case you must ensure that the worst-case "intervention" by the RTOS (which is due to disabling of interrupts during critical sections) does not exceed inter-bit times. As an example, incoming I2C at 100kHz results in an interrupt every 90us. On a 4MHz PIC, Salvo is guaranteed to disable interrupts for longer than that in a typical application (because of the length of a context switch). At 20MHz, it's another story ...

We have users who do this sort of thing with Salvo on PIC16s, of course. But what we would recommend is that you consider using a PIC18 part (often the price difference is minimal). The nice thing about PIC18 is that you can assign the high-rate + interrupt stuff to high-priority interrupts, and call Salvo services only from low-priority interrupts (if at all at the ISR level). Then, configure Salvo to only disable low-priority interrupts during its critical sections (this requires Salvo Pro). This way, your Salvo application can itself be interrupted by high-priority interrupts without any fear of corruption ... you sort of end up with a low-priority side of the system (the Salvo side, with all of its event-driven, priority-based stuff) and a high-priority side of the system (for harder real-time performance).

The short answer to your question is yes, you should be able to do it even with a PIC16, but probably not at 4MHz. What I don't have a feel for is what needs to be done on your PWM side ...

Regards,

------------------


Re: I2C, 2-4 PWM generation, PICMicro

PostPosted: Tue Jul 07, 2009 6:41 am
by tbims23822
www.drop-shopping.com is a premium website for cheap air jordans shoes and other more really nike air jordan shoes.We have varity of cheap air jordan shoes available for wholesale.Cheap China wholesale shoes including cheap Nike shoes and cheap jordan shoes,nike sneakers,nike sneakers discount,air jordan sneakers,air force sneakers.We supply nike sneakers,jordan sneakers,air jordan sneakers,air force sneakers wholesale.You can buy very cheap jordans shoes including cheap women shoes,cheap nike shoes,cheap running shoes from us.