lpcware

Request for help with embedded software design

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by IntStarFoo on Tue Oct 23 08:58:41 MST 2012
Hi All, I'm a hobby embedded programmer and I have a few questions... I have been playing with a set of LED holiday lights and trying to control them using an LPC1769 board from Embedded Artists.  A friend helped me get started with the tools, hardware and the initial code and I have been modifying it from there.

The signal to address one LED takes just under 1000us to send (a bunch of 1s and 0s represented by +5v low for 10us or 20us).  I have 50 bulbs, so the entire signal takes about 50ms every time I want to update the bulbs with a new color.  So, I configured a timer to interrupt every 1us then built the signal from there.

Everything works great!  I am able to address the bulbs, change colors and even create little light shows.  I decided to step it up a notch and purchased the EA Baseboard to add some user input functionality.  This is when I started running into trouble.  As "frame" points out below from another post, I am running out of processing power.


Quote: frame
Apart from the timer bug in the library, a 1us interrupt is a rather heavy load for the uC.
These are about 120 instructions (at max. speed), for servicing the interrupt AND doing anything else.
It might work if there is no other performance load, but don't be surprised if the code misbehaves
when adding modest functionality.



The baseboard includes a bunch of IO devices. 

I decided to use a rotary dial to allow the lights to be moved when a user turns the dial left or right.  [I]I poll the dial in my main loop and send the updated message to the lights when they change.[/I]

I decided to draw 50 squares on the OLED representing each LED and attempt to mimic the color with black and white shapes. [I]I redraw the entire thing every time the lights change. (I see much room for optimization here. with Bitmaps and buffering)[/I]

I decided to add the time and date on the OLED using the Real Time Clock.  [I]I created an RTC interrupt that occurs every 1 second and I draw the new time/date to the OLED using sprintf and a oled_writestring function from an example.  (again, much room for optimization.)[/I]

And... When I put it all together... I come up bubkis. 

Clearly, I need some optimizing in both the code and the design.

Does anyone have advice on how to set this all up?  Should I be using all timers?  No timers?  Polling?  Is it asking too much for a 120mhz processor to be able to do all of this at once? :eek:

Thanks,

IntStarFoo

Outcomes