Go Down

Topic: Optimization of code for maximum speed, very specific project. (Read 3 times) previous topic - next topic

zparticle


If speed is very critical, I imagine moving the part that does the interrupt handling and turning on specific lights at specific times off to an outboard processor that does not do interrupts, instead it is dedicated, and just reads the status constantly in the loop.  It should do nothing but just a busy poll, and turn on/off lights.  It would need some way of getting control updates from the brain processor (another pin perhaps).  Otherwise you are going to be spending a lot of time having the interrupt set up the call stack and then undo it.  And if that is not fast enough, consider getting a faster processor like an ARM embedded board.

Perhaps you could use a standard 555 type circuit to do the timing, perhaps not.


I guessing that is beyond my current skill level, lol.  Maybe that will be Version 3 of the controller.

zparticle

#21
Apr 04, 2013, 06:58 pm Last Edit: Apr 04, 2013, 07:00 pm by zparticle Reason: 1
Given that the powerDelay array is only assigned values inside one of the ISRs and only read from the other ISR and the ISRs are not nested:  Can I remove the volatile attribute from the declaration?  That should give me a few extra cycles in speed shouldn't it?

Coding Badly

Given that the powerDelay array is only assigned values inside one of the ISRs and only read from the other ISR and the ISRs are not nested:  Can I remove the volatile attribute from the declaration?


You can.  You shouldn't.  It won't make any difference...

Quote
That should give me a few extra cycles in speed shouldn't it?


No.  In each ISR each element of powerDelay is accessed just once (read in one ISR; written in the other).  Removing volatile only helps when there are multiple accesses.  Removing volatile eliminates redundant loads from memory but there aren't any.

Coding Badly

Quote
I'm trying to get 256 levels of brightness, but frankly I'm not sure that level is needed.


Very unlikely.  In my opinion, what works best are fewer levels with levels that reflect how a human perceives brightness.  I typically use 100 levels with each level such that a person would say there is about a 1% difference in brightness between each level.

zparticle


Quote
I'm trying to get 256 levels of brightness, but frankly I'm not sure that level is needed.


Very unlikely.  In my opinion, what works best are fewer levels with levels that reflect how a human perceives brightness.  I typically use 100 levels with each level such that a person would say there is about a 1% difference in brightness between each level.



That makes a lot of sense.  I guess I'll see how the 256 works out and then maybe back off and give 100 a try.  I'm betting you are right.

Go Up