Feb 15th, 2017 11:56 PM
How to work out a formula for the duty cycle
I am implementing a 4-20mA current loop to my PIC. I have everything working.
I am measuring the distance away from an object.
When I hardcoded the distance as 300 the output voltage is 4V and when the distance is 12cm the output voltage is 0.8V.
These values are got because the current needs to be 200uA before it enters the current loop.
The current loop has a gain of 100, therefore giving 20mA on the output.
The resistor I use is 20K.
Here is the datasheet of my proximity sensor: http://www.kynix.com/uploadfiles/pdf8827/XTR115UA.pdf
(300cm) Current=420K=200uA×100=20mACurrent=420K=200uA×100= 20mA
(12cm) Current=0.820K=40uA×100=4mACurrent=0.820K=40uA×100 =4mA
The problem is I have to work out a formula for the duty cycle to get these values.
The formula I am using is D.C = 300×2.2+158=818300×2.2+158=818 which gives 4V but if i substitute 12 for 300 I get 184 which does not correspond to 0.8V which is what I need.
Can anyone help on this, if I am going about the wrong way or what way I need to approach this.
Last edited by speculor; Feb 15th, 2017 at 11:59 PM.
All content and materials on this site are provided “as is“. Infineon makes no warranties or
representations with regard to this content and these materials of any kind, whether express or
implied, including without limitation, warranties or representations of merchantability, fitness for
a particular purpose, title and non-infringement of any third party intellectual property right. No
license, whether express or implied, is granted by Infineon. Use of the information on this site may
require a license from a third party, or a license from Infineon.
Infineon accepts no liability for the content and materials on this site being accurate, complete or up-
to-date or for the contents of external links. Infineon distances itself expressly from the contents of
the linked pages, over the structure of which Infineon has no control.
Content on this site may contain or be subject to specific guidelines or limitations on use. All postings
and use of the content on this site are subject to the Usage Terms of the site; third parties using
this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of
this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements,
improvements and other changes to the content and materials, its products, programs and services
at any time or to move or discontinue any content, products, programs, or services without notice.