Bit Angle Modulation (BAM) in a PIC


Closed Thread
Results 1 to 40 of 151

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default BAM theory problem

    I've been working with this on and off for quite some time now.
    I've also had it working for quite some time now ... (with 1 exception).

    It creates some of the smoothest fading effects I've seen so far, so I really want to figure out this one last problem with BAM theory.

    The problem happens when passing in either direction of 128 DutyCycle.
    Before that point, after that point, even continuously at that point, all works perfectly. But as it transitions from either above or below 128 there is a visble BLINK from the LEDs.

    It's taken me Waaaay too long to figure out why, but I'm now pretty sure this is the reason ...

    With anything below 128, the waveform looks something like this ...

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3127" /> <!-- Name:  BAM127.GIF
Views: 51512
Size:  4.2 KB -->
    <br>
    And with anything equal or above 128, it looks like this ...
    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3125" /> <!-- Name:  BAM128.GIF
Views: 51268
Size:  4.2 KB -->

    A continuous stream of either of the above pulses works perfect.
    It's only in the transition from below to above 128 that 1 out of the 100 pulses that second looks like this ...

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3126" /> <!-- Name:  BAM127-128.GIF
Views: 51499
Size:  7.4 KB -->

    The change in pulse positions creates an ON period equal to 255, just for 1 period. Then it's fine again.
    But that 1 period, is extremely visible.

    Going from 127 to 128 it's a bright blink. From 128 to 127 it's a Dim blink, because they line up the other way (combined period = 0 dutycycle).

    The visual appeal and resulting reduction in processor requirements are too great to just give up on BAM.
    So I ask for your thoughts.
    <br>
    DT

  2. #2
    Join Date
    Jan 2009
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    You can invert the value of the bits in each cycle.

    In odd cycles, do first the normal order retard for each bit:
    1,2,4,8,16,32,64,128

    and, in the even cycles, reverse the value of each bit:
    128,64,32,16,8,4,2,1

    Edit:
    Oops this can generate the problem even without transtitions of the dutty cycle used... hummm... maybe rearranging the value of the bits, not just reversing them :?
    Last edited by RadikalQ3; - 16th January 2009 at 09:41.

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


    Did you find this post helpful? Yes | No

    Default

    Hmmmm, such a Radikal idea.
    Very interesting ...

    I had thought of putting the 7th bit in the middle, but it always came up lop-sided since it's Half of the period.

    But making a mirror image of the pulses (at twice the frequency) would put it smack dab in the middle of a nice symetrical waveform that might actually work.

    I must try this ...

    Oh, and Hi there Q3.
    Welcome to the forum!
    DT

  4. #4
    Join Date
    Nov 2008
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Hmmmm, such a Radikal idea.
    Very interesting ...

    I had thought of putting the 7th bit in the middle, but it always came up lop-sided since it's Half of the period.

    But making a mirror image of the pulses (at twice the frequency) would put it smack dab in the middle of a nice symetrical waveform that might actually work.

    I must try this ...

    Oh, and Hi there Q3.
    Welcome to the forum!
    Just my musings can you do a check if duty cycle = 127 + 1 then bit 7=0 (0.005s interrupt) then 128 duty cycle. I.e cause a timer interupt delay before starting on with the BAM again.

  5. #5
    Join Date
    Nov 2008
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by anonymouse View Post
    Just my musings can you do a check if duty cycle = 127 + 1 then bit 7=0 (0.005s interrupt) then 128 duty cycle. I.e cause a timer interupt delay before starting on with the BAM again.
    Thats as clear as mud, => 128 begin reverse read byte and vice versa

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


    Did you find this post helpful? Yes | No

    Default

    RadikalQ3,

    Thanks for the Mirror Image idea!
    It has completely removed the blinking problem.

    Unfortunately the higher frequency and extra code to reverse things has created some new ones, but I think I can work through them.

    For your first post here, it was an awesome one.

    Thanks again,

    Also, thanks anonymouse,
    But with multiple channels at different dutycycles all using the same timer, changing the interrupt sequence at 127 isn't possible.
    I hadn't mentioned the multi-channel part yet ... oops.
    DT

  7. #7
    Join Date
    Jan 2009
    Posts
    3


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by Darrel Taylor View Post
    RadikalQ3,
    Thanks for the Mirror Image idea!
    It has completely removed the blinking problem.
    Oh, it's nothing... just was an idea.
    I have spent the last days reading all I found in internet about PWM, BAM, Frecuency Modulation, etc.
    I have a project to do and I am gathering all the information about this topic.
    Simply... I found your topic (and this forum) and I thought that was a nice challenge solve your blinking problem O
    I am waiting the recepcion of some hardware and in a few days I can do test with this for my own.

    Later, I realized that this is a forum on basic! (and I just use assembler)

Similar Threads

  1. decoding quadrature encoders
    By ice in forum mel PIC BASIC Pro
    Replies: 93
    Last Post: - 28th February 2017, 10:02
  2. Cordic trig assembly code for PIC18f
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 54
    Last Post: - 8th September 2015, 06:36
  3. AT/PS2 Keybord - PIC Interface?
    By Kamikaze47 in forum Code Examples
    Replies: 73
    Last Post: - 9th August 2009, 17:10
  4. MIBAM - (Mirror Imaged Bit Angle Modulation)
    By Darrel Taylor in forum Code Examples
    Replies: 2
    Last Post: - 15th February 2009, 17:02
  5. Bit Angle Modulation
    By BH_epuk in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th November 2008, 08:01

Members who have read this thread : 2

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