Jump to content

Low resolution DOUT PWM


Duggle
 Share

Recommended Posts

The idea is inspired by the desire to drive DOUT attached LED's with individual variable brightness.

Rather than have a single dimension array

volatile u8 mios32_srio_dout[MIOS32_SRIO_NUM_SR];

The idea is to have 2D array with a number of buffer pages:

#define DOUT_NUM_BUFPAGES 2

volatile u8 mios32_srio_dout[DOUT_NUM_BUFPAGES][[MIOS32_SRIO_NUM_SR];

At a lower level MIOS would alternate pages by presumably setting a pointer prior to each DMA transfer.

In the above example any attached LED could be run at 100%, 50% (or 0%) brightness. When setting the brightness level for a particular LED, the same bit is set and/or cleared in different pages.

Taking the concept further

#define DOUT_NUM_BUFPAGES 10

would produce 10 level, 100Hz, brightness control. Actually its does not have to be Pulse Width Modulation exactly. It is more like Pulse Density Modulation (if such a term exists). This is because the on and off bits can be randomly distributed in the pages, for any given LED.

When set, the background processing is achieved with almost zero extra overhead. Just updating the page pointer each SRIO cycle?

Link to comment
Share on other sites

A nice idea - I haven't considered such possibilities yet since MIOS8 was always restricted on RAM limitations.

Note that the same concept can be used to drive a LED matrix - e.g. set DOUT_NUM_BUFPAGES to 8 and output (1 << counter) to an additional DOUT register.

If you are working on an extension on MIOS32, you could consider this usecase as well.

Best Regards, Thorsten.

Link to comment
Share on other sites

Note that the same concept can be used to drive a LED matrix - e.g. set DOUT_NUM_BUFPAGES to 8 and output (1 << counter) to an additional DOUT register.

If you are working on an extension on MIOS32, you could consider this usecase as well.

Sure, but I'm not quite sure how the additional DOUT register is wired to the matrix, and why 8 pages?

Edit:

Having thought a some more about this, if there is a page each for the number of matrix columns,then row/column matrix's can be driven this way.

Edited by Duggle
Link to comment
Share on other sites

Ok, looks simple enough.

As an extension to MIOS32

  1. define volatile u8 mios32_srio_dout_bufpages[DOUT_NUM_BUFPAGES][[MIOS32_SRIO_NUM_SR]; //paged buffer dout array
  2. A family of helper functions to set the page data for RGB, TriLED, single variable brightness LED, row/col matrix wired LED, etc.
  3. define MIOS32_SRIO_ScanStart_DoutPaged() which has a rotating index when providing a dout array pointer to MIOS32_SPI_TransferBlock(..)
  4. Put a #ifdef switch in void vApplicationTickHook(void) so that MIOS32_SRIO_ScanStart_DoutPaged() is called instead of MIOS32_SRIO_ScanStart()

Question:

Is there a way of achieving (4.) without modifying MIOS32 source code?

If I'm correct then the rest can be achieved as a pure add on module i.e not modifying MIOS32 source. I'm very happy to commit to the repo, but I dont want to "bloat" anything!

Link to comment
Share on other sites

  • 4 weeks later...

Well I can report the method certainly works well.

To proceed as simply as possible I've added

s32 MIOS32_DOUT_SRSet_Paged(u32 pg, u32 sr, u8 value)

and

s32 MIOS32_DOUT_SRGet_Paged(u32 pg, u32 sr)

to mios32_dout.c for get/setting the data.

Plus changed s32 MIOS32_SRIO_ScanStart(void *_notify_hook) to roll through the pages with each execution.

I use conditional compilation to allow for compiling normal unpaged dout apps. I think this is the most transparent and simplest way for now.

I'll continue to develop the application support routines for this and report back later!

Edited by Duggle
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...