element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Embedded Forum delay generation
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Embedded and Microcontrollers to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 17 replies
  • Subscribers 474 subscribers
  • Views 1637 views
  • Users 0 members are here
Related

delay generation

mr.rohit
mr.rohit over 8 years ago

Delay generation using timer in pic18f46k22

 

I am using timer interrupt for delay generation in pic18f

when i generate  any delay using timer that time this delay is not proper which i want,it showing some difference in time.

i want knw what is the reason of that difference ?

plz help me...

thank u..

  • Sign in to reply
  • Cancel

Top Replies

  • koudelad
    koudelad over 8 years ago in reply to mr.rohit +4
    Well... A calculator is useful only after you fully understand, what it calculates. There is no information about age or function... First, trust the datasheet of PIC18F46K22 . Microchip tries to have…
  • koudelad
    koudelad over 8 years ago in reply to mr.rohit +4
    I am glad I could help. And welcome to element14 community To be honest, when I started with 16F PICs (13 years ago), I only had some book that didn't provide much explanation. Then I opened the datasheet…
  • koudelad
    koudelad over 8 years ago +3
    Hello, there are too many variables. The more details you add, the more we would be able to help you. Basically, I would focus on the following: 1) oscillator frequency and stability - this is crucial…
  • koudelad
    koudelad over 8 years ago in reply to mr.rohit

    Hello,

    Please create a separate discussion (or question) for each separate issue you have. There is less chance it will be lost in a discussion with different topic and higher possibility that someone will notice and help.

     

    To the subject:

    First, you haven't provided any schematics, so make sure you know how is the LED connected to a PIC pin and whether it sources or sinks the current for your LED.

    Second, according to what you wrote, I don't think you have problem with the code toggling an LED itself, but somewhere else in the code, handling / responding to the detection of a touch. Helping would be easier if we could actually look at the code.

     

    what you probably have in pseudocode:

         if touch_detected > turn LED on

              else turn LED off

     

    what you need:

         if touch_detected > toggle LED

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • mr.rohit
    mr.rohit over 8 years ago in reply to COMPACT

    hello..

    I am working with capacitive touch sensor with pic18f microcontroller using CTMU.

    i want to toggle the LED with capacitive touch sensor..means  when i touch the sensor that time i want  LED in ON State till the next touch,when i again touch the sensor that time i want LED in OFF state till next touch...

    for toggling this LED i used following syntax..ie

    LATDbits.LATD1 = ~ LATDbits.LATD1 ;

    LATDbits.LATD1 = ! LATDbits.LATD1;

    and also

    LATDbits.LATD1 = 1

    LATDbits.LATD1 = 0

    but using all above methodes LED is turning ON when i touch the sensor,and turning OFF when i release touch sensor..

    i dont know which methode is use for this operation...

    what should i do for this operation ?

    plz help me...

    thank u......image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • COMPACT
    COMPACT over 8 years ago

    The old fashioned way used coils of wire as a delay line. The length required is 300mm per nanosecond * the velocity factor of the conductor used.

    These were superseded with digital versions.

    http://au.element14.com/webapp/wcs/stores/servlet/Search?pageSize=25&st=delay+line&catalogId=15001&categoryId=800000000312&langId=43&storeId=10184

     

    You can also use 74HC5555 or its inspiration the NE555 timer.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • mr.rohit
    mr.rohit over 8 years ago in reply to koudelad

    ok thank u david..

    i think time delay in microsecond is suitable for this unit..

    i will try to maintain that boudaries...

    thank u so much...image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • koudelad
    koudelad over 8 years ago in reply to mr.rohit

    I think you got the CTMU wrong. There is a current source, but the voltage to be measured by ADC can't be higher than Vdd of the PIC. (It is just a regular ADC, with +Vref as Vdd or something else smaller than Vdd.) I hope no manufacturer will design a chip with such self destruction capability image

     

    Your calculation has to count with all the variables. You can set the current value of the current source, you can create variable time delay. The capacity is something you want to measure by measuring the voltage (charge) created by the current source for the time delay.

     

    To your question - with 1 ms delay, you will just measure Vdd, which is meaningless and gives you no answer about the measured capacity.

    Try to stay within Vss and Vdd boundaries otherwise your measurement makes no sense.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • mr.rohit
    mr.rohit over 8 years ago

    Thanks David..

    see in CTMU there is one internal capacitor inbuild

    when we set EDGSTAT1 bit in CTMUCON register that time internal capacitor start charging using internal 5.5uA current source

    after that we have to wait some time for charging thats why we need time in microsecond,then we dissable EDGSTAT1 bit in CTMUCON register ie stop charging of internal capacitor

    so i was asked the question,becoz i want to know what happen if i use time between charging and discharging capacitor is microsecond ?

     

    Can i use the time delay in millisecond using timer interrupt for CTMU ?

     

    according to calculation when i consider time in millisecond that time voltage is increasing

    ex.

    I = 5.5uA

    T = 1ms

    C = 30pf

    V = 183.3v

     

    and  183.3 V on ADC pins for microcontroller  is not possible..

    plz share some tips for me..

    Thank you...image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • koudelad
    koudelad over 8 years ago in reply to mr.rohit

    Hello,

    I am sorry, but I don't understand your question. What do you mean by

    Can i use the time delay in millisecond using timer interrupt for CTMU ?

     

    I personally haven't used CTMU unit in PICs, however, I've quickly gone through the referenced application note AN1375 and 18F46K22 datasheet. It is up to you, how you implement the delay (a timer, fixed length loop, ...).

     

    (BTW, I recommend reading application number 47. and 48. in that application note. Seems that engineers wanted to accompany the useful text with some fun image )

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • mr.rohit
    mr.rohit over 8 years ago in reply to DAB

    hello...

     

    I am working with Capacitive sensor using CTMU in pic18f46k22..I am refering AN1375 App note for CTMU..

    this microcontroller having CTMU unit for capacitive sensor.in CTMU registers , i am using 5.5uA internal current source,and 14us delay which is generated by timer interrupt for CTMU.

    calculations....

    c = 30 pf

    I = 5.5uA

    T = 14us

    v = ?

     

    according to mathematical calculation

    v = (I*T)/C

    v = (5.5uA * 14us)/30pf

    v = 2.56v

     

    my question is ,

    Can i use the time delay in millisecond using timer interrupt for CTMU ?

    plz help me, i am not able to understand the accurate calculations..

    thank u..

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • DAB
    DAB over 8 years ago

    How precise and how accurate?

     

    Accurate timing comes down to a time base and synchronization.

     

    You can accomplish these tasks depending upon your requirements.

     

    Please share them if you want a good answer.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • mr.rohit
    mr.rohit over 8 years ago in reply to koudelad

    hmm...

    Really u have lots of experience in Embedded..

    nice to meet u..image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube