It must be a timing problem.....
Well, as you will probably soon see I am pretty new to SX programming, and have run into a problem I have just not been able to figure out. I am working on a DMX-512 controlled 6 channel light dimmer. The DMX receive functions and light dimmer code are based on the work of Jon Williams, and work well. However, I have some ancillary functions that are not working. I have a bicolor LED wired across two pins of an SX 28, that should allow me to control the color of the LED as a status indicator. On the hardware side, the logic is powered by a "wall wart" to isolate the mains, and the line AC side is fuse protected (the wall wart feed is before the fuse), isolated by triacs, with an optoisolator to sense the zero crossing point. The functions I am trying to implement are as follows:
1) AC power (fuse good), no DMX - LED solid green
2) AC power (fuse good), DMX receive - blinking green LED
3) No AC power (fuse blown), DMX - blinking red LED
4) No AC power (fuse blown), no DMX - solid red LED
The problem is, I figured out how to blink the LED, but I have not been able to figure out how to change the LED color based on either the incoming DMX stream or the ac zero crossings. I have tried all kinds of algorithms, mostly variations of ideas like counting the zero crossings for a known period of time, and if there aren't any then clear a "fuse good" bit. In all cases, using an IF statement to get the color causes the dimming feature to fail (lights start flickering). In the attached code, I have commented out a couple of test cases trying to get this to work. I just do not see the connection between the dimming function and an if statement for selecting the state of a pin controlling the LED. Sigh... I am sure it's something obvious, but I have just run out of ideas.
One last note, given the short duration of the interrupt for the DMX receive and dimming, there is only room for one addition one word command in the available timing, so the LED functions need to be in the foreground.
Any help on this would be greatly appreciated!
Skip
1) AC power (fuse good), no DMX - LED solid green
2) AC power (fuse good), DMX receive - blinking green LED
3) No AC power (fuse blown), DMX - blinking red LED
4) No AC power (fuse blown), no DMX - solid red LED
The problem is, I figured out how to blink the LED, but I have not been able to figure out how to change the LED color based on either the incoming DMX stream or the ac zero crossings. I have tried all kinds of algorithms, mostly variations of ideas like counting the zero crossings for a known period of time, and if there aren't any then clear a "fuse good" bit. In all cases, using an IF statement to get the color causes the dimming feature to fail (lights start flickering). In the attached code, I have commented out a couple of test cases trying to get this to work. I just do not see the connection between the dimming function and an if statement for selecting the state of a pin controlling the LED. Sigh... I am sure it's something obvious, but I have just run out of ideas.
One last note, given the short duration of the interrupt for the DMX receive and dimming, there is only room for one addition one word command in the available timing, so the LED functions need to be in the foreground.
Any help on this would be greatly appreciated!
Skip
Comments
Thanks
Have you worked on this code anymore? Are you seeing a flicker?
Post Edited (JonnyMac) : 8/16/2008 11:06:17 PM GMT
I then·compared the zero cross input to a channel output and noticed that the output pulse seemed to be starting correctly at the trailing edge of the zero cross but was being restarted on the leading edge of the same zero cross.
Basically can only·set a channel output at a percentage of the low zero cross. This·because the way zero cross is being polled. What we want is state change (or edge detect), and clear all the outputs and counters when the low going edge is detected.
Let me see if there is an simple way to get around this. We need to see it go low to reset everying, then ignore it long enough for it to go high and then start checking it again.
Post Edited (DynamoBen) : 8/17/2008 3:37:30 AM GMT
Once I get the zero cross thing sorted I will post my version.
BTW I think you could·control up to sixteen channels if each interrupt set two outputs, instead of one.
JNB ZC, Update_Ch1····'(2/4) At zero cross?
When the zero cross line is tied high the actual zero cross is a low pulse. With the above code when the zero cross line is low it updates the channel instead of clearing the channel. Basically channel update and zero cross are backwards.
Try the following instead:
JB ZC, Update_Ch1····'(2/4)·Not zero cross?
Post Edited (DynamoBen) : 8/17/2008 5:40:07 AM GMT
Not sure at the moment what I'm over looking...if anything. Maybe it has to do with my 13V AC supply I'm using to zero cross.
Post Edited (DynamoBen) : 8/17/2008 3:46:23 PM GMT