multi-tasking


Closed Thread
Results 1 to 11 of 11

Thread: multi-tasking

Hybrid View

  1. #1
    malc-c's Avatar
    malc-c Guest

    Default multi-tasking

    Guy's, just need some general pointers on how to move something forward. I don't want to go into actual code at this time for personal reasons, more simply for guidance as to what to use

    Lets say I had a routine that calculated a value and then I used that value in a pause statement to control how long a pin remains high. This works fine for one output and is achieving the desired result in my tests. However I now want to replicate this 4 times, which causes me a slight problem.

    If I had something like:

    Calculate value 1
    Calculate value 2
    Calculate value 3
    Calculate value 4

    high pin 1
    pause value 1
    low pin 1

    high pin 2
    pause value 2
    low pin 2

    etc etc

    The problem is that the total time all pins are off is the sum of all the other pause values. ie pin one is low for pause value 2 + value 3 + value 4. This is not what I want. I want to have pin 1 pulse at the rate set by value 1 and pin 2 at the rate set by value 2 etc etc..

    What would be the the best way forward.

  2. #2
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    lets say you need to pause these pins starting from the same initial port status and time:

    porta.1 15 secs
    porta.2 10 secs
    porta.3 5 secs

    you can do this:

    porta=%00000111
    pause 5
    porta=%00000011
    pause 5
    porta=%00000001

    is this what you are looking for?

  3. #3
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks for the input, but not quite as the pause period is not static.

    Each pause will be variable each time the loop runs round, and needs to be totally independent. In effect I need to run 4 loops simultaneously so that the pause delay in each has no affect on the others.

  4. #4
    Join Date
    Apr 2007
    Location
    Pennsylvania, USA
    Posts
    158


    Did you find this post helpful? Yes | No

    Default

    Driving fuel injectors?

    Depending on what kind of time frame you are talking it could be done by running a timer.

    #1 on at x time
    #1 off at x time
    #2 on at x time
    #3 off at x time
    #4 on at x time
    #4 off at x time

    Each loop can adjust the values that the timer falls on for the on and off times to adjust your output periods. Interupts could be used depending on how time sensitive you need it.
    Shawn

  5. #5
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by spcw1234 View Post
    Driving fuel injectors?
    More likely simultaneous output of 4 R/C PWM pulses - 1-2mS width, 50Hz frequency.

  6. #6
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rmteo View Post
    More likely simultaneous output of 4 R/C PWM pulses - 1-2mS width, 50Hz frequency.
    LOL - on this occasion you're not even warm.....

Similar Threads

  1. Multi Slow speed PWM and Instant Interrupts
    By DaveC3 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 2nd November 2010, 12:50
  2. multi functions button press
    By malwww in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th May 2009, 00:12
  3. 16-48 pin Multi slow PWM
    By krohtech in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 28th March 2009, 03:28
  4. Multi diomencinal array
    By morphyn in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th February 2009, 21:19
  5. parallel port multi pic programmer?
    By SuB-ZeRo in forum Schematics
    Replies: 8
    Last Post: - 25th June 2005, 10:20

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