Performing a loop every 10ms


Closed Thread
Results 1 to 40 of 41

Hybrid View

  1. #1
    Join Date
    Nov 2007
    Location
    Cebu, Philippines
    Posts
    14


    Did you find this post helpful? Yes | No

    Post needed

    Can you display your code so that I will have an idea on what's going on.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi, Wassup

    As Timer 0 is a 8 bits timer ... and we suppose clock is 4Mhz ( ... )

    I will be necessary to have a counting loop in the interrupt stub , because interrupts will occur every 256 µs as a maximum

    The other solution is to use Timer 1 that has a 16 bits counting range ... and won't need any calculations.

    Have a SEARCH for "PicMultiCalc" from Mr E. it's a nice tool to help for Timer designs ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    ...256 µs as a maximum
    ??

    Minimum?

    Maximum?

    I must be on the other side of the mirror.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer View Post
    ??

    Minimum?

    Maximum?

    I must be on the other side of the mirror.


    The other side of the Bosphor, certainly !!!

    1x 1µs = 1µs ... 256x 1µs = 256µs ...

    so, the maximum period is 256 µs ...

    what was requested for, is a period duration of 10 ms ... or a 10,000 timer count !

    Tell me if I'm wrong !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    The other side of the Bosphor, certainly !!!

    Alain
    Depends on what side you are standing at.


    Quote Originally Posted by Acetronics View Post
    1x 1µs = 1µs ... 256x 1µs = 256µs ...

    so, the maximum period is 256 µs ...

    what was requested for, is a period duration of 10 ms ... or a 10,000 timer count !

    Tell me if I'm wrong !!!

    Alain
    The "maximum" means fastest then.

    Also, what do we get from TMR0 at 4Mhz at 1:4 prescaler ?
    I get roughly 1.03ms.

    I may be doing a wrong math here.
    Last edited by sayzer; - 8th February 2008 at 19:11.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  6. #6
    Join Date
    Feb 2008
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Thankyou

    Wow, thankyou for all of your replies.

    I forgot to mention that my crystal is 20MHz and both CCP1 and CCP2 are being used for HPWM.

    I found PicMultiCalc and it is saying that I can use the 8-bit timer (Timer0) for an error of 0.371%. It says that if I use the 16-bit timer I will get an error of 0%. Now I have decided that I will use the 16-bit timer only if it won't interupt my HPWM. The HPWM is driving two motors. I am not at all familure with these timers and I don't know how to set them up or know when to start my 10ms loop so that the gyro can be read at the start of every loop at 100Hz (10ms intervals). Integration calculations and other processes are carried out after the gyro has been read. If all calculations and procesess have been done before the next loop should start, the processor should wait until the timer flag or whatever signals the loop to start over.

    FYI I am making a balancing robot.

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by wasssup1990 View Post
    Wow, thankyou for all of your replies.
    Said it before, I'll say it again...
    Start simple...
    Get the LED blinking at a known rate under an interrupt drive (or just get an LED blinking ), get the HPWM working on all channels in all situations, get the interfaces working, THEN tie them all together.
    Otherwise you'll be shooting yourself in the foot wondering why...no more...just wondering WHY!!!!

  8. #8
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Talking

    Quote Originally Posted by wasssup1990 View Post
    FYI I am making a balancing robot.
    You should browse the parallax site ...

    They already did it ( and they share it !!! ) ... and moreover their basic is PbP compatible !!!

    ... at least TONS of understandable solutions to your headaches ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Controlsystem for compact sporting (clay shooting)
    By Fredrick in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 30th July 2009, 16:48
  2. Serin to Serin2 ??
    By Gixxer in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th January 2008, 03:56
  3. Serial Relays
    By tazntex in forum General
    Replies: 3
    Last Post: - 17th May 2007, 17:42
  4. newbie Q - edge detection?
    By RMCRAVEN in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 9th October 2006, 08:20
  5. Newbie question:
    By Izone in forum mel PIC BASIC
    Replies: 2
    Last Post: - 26th February 2006, 16:24

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts