More than a single function


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Jan 2010
    Posts
    88

    Default More than a single function

    Hello All,

    I have been watching videos and seeing actual products that use PICs and have noticed the PICs doing two things at once. For instance, I have witnessed two separate outputs flashing at different rates. Kind of like watching two vehicles with their turn signals on and the flashing lights go in sync and out of phase with each other and then back in sync again.

    How can one do this with PBP? Another example is pwming an output at one frequency while another output is at a different frequency. I thought the PIC can only do one thing at a time. Anyone have any example code?

    Thanks,
    Tony

  2. #2
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: More than a single function

    Anyone have any example code?
    This uses interrupt routines and Timers as one example.

    http://www.picbasic.co.uk/forum/cont...le-LED-flasher

    Have you considered Persistence of Vision? Some visual routines use this by changing a display at 60Hz so the display looks static but other parts of the program are executing many times in between the display refreshes, changing another LED for example.

    Clear as mud?
    It is just a case of perception it is not real magic just an illusion!

  3. #3
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: More than a single function

    This is a good demonstration

    http://www.picbasic.co.uk/forum/cont...ck-by-Pimentel

    of the reinvention of the wheel.

  4. #4
    Join Date
    Jan 2010
    Posts
    88


    Did you find this post helpful? Yes | No

    Default Re: More than a single function

    I was thinking something more along these lines.


  5. #5
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: More than a single function

    Looks simple depending on the pic you are using.
    Post your code.

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: More than a single function

    See post #3 in this thread ...

    MIBAM - (Mirror Imaged Bit Angle Modulation)
    Cylon Scanner
    http://www.picbasic.co.uk/forum/showthread.php?t=10564
    DT

  7. #7
    Join Date
    Jan 2010
    Posts
    88


    Did you find this post helpful? Yes | No

    Default Re: More than a single function

    This thread has split into two parts, but it still covers being able to do two things at once. To better explain my first question, if I made two boards, each controlling an LED and made one single flash at 1 Hz and the other quadruple flash at 2 Hz, then the LEDs would go in and out of phase with each other. My first question was how do I implement this into one chip where you can change the pulse count and speed of one output and have another output doing something else concurrently? I know it can be done because I have seen it on other products.

    Mind you on one of these products, the output that is doing single flash is also part of a trigger, so that when the trigger impulse is received, the pattern changes. I'm thinking an interrupt routine, but can that routine cause an output or two to pulse while the chip is doing something else?

    Another method was using shift registers, but I found another circuit that did not.

    The MIBAM I am familiar with. I haven't played with it yet, but can it do these effects, or do the LEDs just fade to 0? Here is a better representation of the effects.



    He provides the code for his chips here, and explains how to assemble them in MPLAB, but is there any way to implement those functions in PBP? Obviously the code doesn't transfer into PBP as it does not recognize it. I know it's written for MPASM, but can PBP code not do anything like this?

    A short example of the patterns he's written:

    Code:
    ; ----------------------------------
    ; See pwmc_SeqMacro.inc for information on the format of the sequence data
    ;
    ; ----------------------------------
    ; seq 01
                  control 0,4
                  hold 8
                  sdat 3,0,0,0,0,0,0,0
                  hold 8
                  sdat 2,3,0,0,0,0,0,0
                  hold 8
                  sdat 1,2,3,0,0,0,0,0
                  hold 8
                  sdat 1,1,2,3,0,0,0,0
                  hold 8
                  sdat 0,1,1,2,3,0,0,0
                  hold 8
                  sdat 0,0,1,1,2,3,0,0
                  hold 8
                  sdat 0,0,0,1,1,2,3,0
                  hold 8
                  sdat 0,0,0,0,1,1,2,3
                  hold 8
                  sdat 0,0,0,0,0,0,1,3
    	hold 8
                  sdat 0,0,0,0,0,0,0,3
                  hold 8
                  sdat 0,0,0,0,0,0,3,2
                  hold 8
                  sdat 0,0,0,0,0,3,2,1
                  hold 8
                  sdat 0,0,0,0,3,2,1,1
                  hold 8
                  sdat 0,0,0,3,2,1,1,0
                  hold 8
                  sdat 0,0,3,2,1,1,0,0
                  hold 8
                  sdat 0,3,2,1,1,0,0,0
                  hold 8
                  sdat 3,2,1,1,0,0,0,0
                  hold 8
                  sdat 3,1,0,0,0,0,0,0
    
                  
                  seqend
    
    ; ----------------------------------
    ; seq 02
    
                  control 0,4
                  hold 11
                  sdat 3,0,0,0,0,0,0,0
                  hold 11
                  sdat 2,3,0,0,0,0,0,0
                  hold 11
                  sdat 1,2,3,0,0,0,0,0
                  hold 11
                  sdat 1,1,2,3,0,0,0,0
                  hold 11
                  sdat 0,1,1,2,3,0,0,0
                  hold 11
                  sdat 0,0,1,1,2,3,0,0
                  hold 11
                  sdat 0,0,0,1,1,2,3,0
                  hold 11
                  sdat 0,0,0,0,1,1,2,3
                  hold 11
                  sdat 0,0,0,0,0,0,1,3
    	hold 11
                  sdat 0,0,0,0,0,0,0,3
                  hold 11
                  sdat 0,0,0,0,0,0,3,2
                  hold 11
                  sdat 0,0,0,0,0,3,2,1
                  hold 11
                  sdat 0,0,0,0,3,2,1,1
                  hold 11
                  sdat 0,0,0,3,2,1,1,0
                  hold 11
                  sdat 0,0,3,2,1,1,0,0
                  hold 11
                  sdat 0,3,2,1,1,0,0,0
                  hold 11
                  sdat 3,2,1,1,0,0,0,0
                  hold 11
                  sdat 3,1,0,0,0,0,0,0
    
                  
                  seqend
    
    ; ----------------------------------
    It's simpler to just write what the LED's intensity should be at said position. Maybe MIBAM can do this, but do any modifications have to be made to the MIBAM code?

    I was wondering if PBP code could be written in a way to implement "some" of these features. I would like the ability to write 0 through whatever limit to specify LED intensity instead of pwm. Also, this way, you can pwm more than one output.

    I know DT's MIBAM can do some of those effects, but I was wondering how to implement features as being able to write "sdat 0,1,1,2,3,0,0,0" to control pwm of the outputs.

    I have written other types of flashing sequences and would like to implement some other patterns like these. Any way of utilizing some of the code and not all of it?

    Thanks,
    Tony

  8. #8
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: More than a single function

    MIBAM can do all of the effects in that video.
    Although his code only has 4 dimming levels. MIBAM has 256 levels.

    If you have PBP3 the "sdat" command structure can be duplicated with USERCOMMANDS.
    DT

  9. #9
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: More than a single function

    Quote Originally Posted by ERMEGM View Post
    Hello All,

    I have been watching videos and seeing actual products that use PICs and have noticed the PICs doing two things at once. For instance, I have witnessed two separate outputs flashing at different rates. Kind of like watching two vehicles with their turn signals on and the flashing lights go in sync and out of phase with each other and then back in sync again.

    How can one do this with PBP? Another example is pwming an output at one frequency while another output is at a different frequency. I thought the PIC can only do one thing at a time. Anyone have any example code?

    Thanks,
    Tony
    A PIC can only do one thing at a time. Or should I say it can only run one program at a time unlike computers for example. As Darrel has shown PBP can be used to give the effects you want. The appearance that you get of two things being done at the same time is an illusion created by POV.

    If anyone has a way to make a PIC multitask please let me know.

  10. #10
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: More than a single function

    PIC's can do many things at the same time.

    It can only execute one instruction of the program at a time ...
    But simultaneously, all the hardware peripherals are doing their "thing" too.

    Timers are counting, the A/D can be converting, LCD drivers are scanning, USARTS and SSP modules are sending/receiving data... etc.

    It can be difficult to keep track of everything that's going on.
    But when you do get a handle on it ... amazing feats of magic will follow.

    You cannot say PIC's only do one thing at a time.
    DT

  11. #11
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: More than a single function

    Thanks Darrel

    You cannot say PIC's only do one thing at a time.
    That was what I was trying not to say.

    But they can only execute one instruction at a time.
    Is what I was trying to say. But you said it better.

Similar Threads

  1. Single button function
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 40
    Last Post: - 4th April 2020, 19:33
  2. Multiple RETURNS within a single subroutine
    By BrianT in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st June 2009, 17:43
  3. single sided PCB
    By schu4647 in forum General
    Replies: 1
    Last Post: - 10th December 2008, 19:22
  4. Replies: 5
    Last Post: - 23rd February 2005, 18:35
  5. Tx and Rx of Single Pin PIC's
    By Dwayne in forum Code Examples
    Replies: 0
    Last Post: - 26th May 2004, 15:55

Members who have read this thread : 1

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