Flip flop serial interface help

Thread Starter

minisystem

Joined Dec 4, 2008
32
I'm working on a building a dim-able 8x16 AC-powered incandescent bulb matrix. I've pretty much nailed down the technique for the dimming using zero-cross detection and timed TRIAC switching: http://arduinodiy.wordpress.com/2012/10/19/dimmer-arduino/

Each bulb will have its own TRIAC controller module with the TRIAC receiving a single bit control (ON/OFF) from a microcontroller via an optocoupler. Thus, each refresh and update requires 128 bits of data, one bit for each bulb in the matrix. For ease of wiring, I want to use a board-to-board serial connection for the TRIAC control bits. My queries are related to the nature of a serial interface that allows the propagation of those 128 bits through the matrix as quickly and reliably as possible.

I've included a schematic for a single module. It consists of a dual D-type flip flop that uses a 3-wire interface to clock the data bits through the matrix and then latch them to the TRIAC. The 128 bits needed to refresh the matrix are clocked through the first flip flop in each of the 128 modules and then the whole 128 bit control word is latched to the second flip flop on each module. It's basically a giant 128 bit shift register.

I don't have any experience with DIY serial hardware and I'm specifically worried about the integrity of the CLOCK and LATCH signals as they propagate through the matrix. I've buffered both the CLOCK and LATCH on each module using a non-inverting Schmitt-trigger buffer. I figured buffering would make the system more immune to noise? The wire run between modules will be something like 4-6". I was hoping to use 6 conductor ribbon cable, so no twisted pair if possible. Finally, the modules will be on professionally fabricated PCBs. The AC power and low voltage DC control signals are separated by optocouplers with the AC portion on one half of the board and the DC portion on the other.

For the sake of simplicity and cost, I'm trying to avoid using any of the standard serial interfaces. Also, because each module only needs a single bit of data, a multi-word serial interface seems like overkill.

I was hoping the wise folks here could point out any pitfalls I might be missing. Specifically, is there a risk of problems with clock integrity using this set up due to the rapid AC switching? Anything else I should watch out for? Am I being totally naive in thinking that this will work in a noisy AC environment?
 

Attachments

MrChips

Joined Oct 2, 2009
30,701
Which 74xxx2G17 gates are you using?
Are these open-collector outputs?
What is your clock frequency?

I would consider putting some input filters on your CLOCK and LATCH inputs
and also put impedance matching driver resistances in series with the outputs.

With ribbon cables, expect to see a lot of cross-talk. I would interleave signal and ground.
Your choice of pinouts on the connector does not take this into account. Move CLOCK to pin 1 and VCC to pin 2.
Twisted pair is better.
 
Last edited:

Thread Starter

minisystem

Joined Dec 4, 2008
32
This is the buffer I was going to use: http://www.ti.com/lit/ds/symlink/sn74lvc2g17.pdf

You would suggest an open drain buffer instead? Like this: http://www.ti.com/lit/ds/symlink/sn74lvc2g07.pdf

The FF, a standard 74XX74: http://www.ti.com/lit/ds/symlink/sn74hc74.pdf

Based on the latency through the buffers I was looking at a clock speed of something like 0.5 to 1.0 MHz, possibly higher.

Regarding input filters, are you referring to a simple RC input filter designed to absorb transients from the AC switching?

And with respect to impedance matching resistors on the outputs, how would I determine the necessary resistance?

I must admit to finding noise filtering and rejection methods confusing in the case of digital circuits. I've been slogging my way through Horowitz and Hill's 'Art of Electronics' and while they devote an entire chapter to low-noise techniques, all they seem to say about digital transmission and noise is "If the signals are several volts, or large logic swings, just tie things together and forget about it" (pg 458). This is coupled with a figure that suggests that noise from AC lines would have an impact of <100mV on logic level signals.
 

ifixit

Joined Nov 20, 2008
652
Some things to consider:
  1. The MOC3021 typical trigger current is 8 mA, & the max is 15 mA. You should design for at least 15mA and higher if this device is to work in cold weather.
  2. The 74HC74 with a VCC of 5V can only drive with ~2mA. You need a VCC of 10V or more to get 15mA of drive.
  3. How much trigger current does U4 require? R3 will delay the turn on time until enough current builds up to trigger U4.
  4. Daisy chaining 128 modules as you intend is a recipe for disaster. Switching noise generated by U3 led conducting will ripple back through all the previous modules and possibly can change latch states. VCC and ground should be run as a bus. Use good decoupling.
  5. Power line voltages come in to each module and bring high frequency power line noise along with them. This noise can be coupled electrically or magnetically through to the logic side of the modules. Filtering and/or layout are important so do it right.
  6. If U4 fails to turn on then R3 could have 14 Watts being dissapated in it. Place it so that it doesn't set fire to anything.
  7. Track routing for U4, P3 & P4 need to be heavy enough to trip or blow the breaker or fuse protecting the lamp circuit. Lamps can short-circuit when they fail.
Good Luck,
Ifixit
 

Thread Starter

minisystem

Joined Dec 4, 2008
32
Ok, those are important things I haven't considered. Thank you!

With respect to daisy chaining, it had occurred to me that this could cause problems. I was inspired by the Shiftbright system which uses an A6281 LED driver with serial interface, which has buffered data, clock and latch lines between modules. I figured if they could daisy chain hundreds of modules together so could I. I suppose that was a bit naive. :)

With respect to point 4, I was thinking of using a single 8 bit port on the microcontroller to control 8 lines of 16 bulbs, thus daisy chaining only 16 modules together. Is this likely to improve reliability?

And wrt point 5, I think I've got layout covered reasonably well - the digital side of the board is well separated from the AC power side with the connections to the MOC3021 being the obvious bridge between the two. Generous ground plane on top and bottom around the digital side (boards will be 2-layer). I left ground plane off the AC side as I was worried the switching noise could couple to the digital ground. Is that the right approach? Should I make the top plane VCC instead for a more global decoupling effect?

I appreciate the advice. This is a project where I could probably easily get a single module or a small group of modules to play nicely together but then have all kinds of gremlins come into play when the entire matrix is wired up. Please keep it coming!
 
Last edited:

ifixit

Joined Nov 20, 2008
652
Your layout sounds good.

With respect to point 4, I was thinking of using a single 8 bit port on the microcontroller to control 8 lines of 16 bulbs, thus daisy chaining only 16 modules together. Is this likely to improve reliability?
This sounds like a better approch. Less daisy chaining of VCC and GND. Try to have a good ground refence that is less likely to "bounce". The worst senario is when you try to turn all the lights on at once. 15mA X 8 X 16 equals 1.92 Amps in the ribbon cable. However, the pulse duration should be short so choose a decoupling cap value that can deliver the energy from right on the modules.

This is a project where I could probably easily get a single module or a small group of modules to play nicely together but then have all kinds of gremlins come into play when the entire matrix is wired up. Please keep it coming!
This is true. It also applys when you are manufacturing many of a product. Is this string of modules a one-time build, or are you going to make 100's of them?

Regards,
Ifixit
 

Thread Starter

minisystem

Joined Dec 4, 2008
32
Your layout sounds good.

This sounds like a better approch. Less daisy chaining of VCC and GND. Try to have a good ground refence that is less likely to "bounce". The worst senario is when you try to turn all the lights on at once. 15mA X 8 X 16 equals 1.92 Amps in the ribbon cable. However, the pulse duration should be short so choose a decoupling cap value that can deliver the energy from right on the modules.
Good point. I've found other opto-TRIACs with a trigger current of 5 mA, so presumably this will be a better option. There are also 74XX74 FFs with higher drive currents available.


This is true. It also applys when you are manufacturing many of a product. Is this string of modules a one-time build, or are you going to make 100's of them?
One time build for an art installation, but I'll need to have 128 modules (or 64 if I double them up) assembled.
 

Brownout

Joined Jan 10, 2012
2,390
I don't understand the goal. You have 128 blubs in an 8x16 matrix, and you want to dim the blubs. What in the purpose of the serial shift register? Are you going to dim some blubs and not others? Are you holding off the latch signal to get the dimming? I'm not sure your scheme accomplished what you want, unless I'm just not understanding it.
 

Thread Starter

minisystem

Joined Dec 4, 2008
32
I don't understand the goal. You have 128 blubs in an 8x16 matrix, and you want to dim the blubs. What in the purpose of the serial shift register? Are you going to dim some blubs and not others? Are you holding off the latch signal to get the dimming? I'm not sure your scheme accomplished what you want, unless I'm just not understanding it.
Yes, each bulb will be under individual control. Zero-cross detection is not seen on the current schematic.

I was deliberately vague about the AC dimming method as I was worried it would stray into the 'restricted topic' territory. The dimming method is outlined here: http://arduinodiy.wordpress.com/2012/10/19/dimmer-arduino/ Briefly, a bulb is turned on during the zero crossing of the AC power and turned off again at some variable time after the zero crossing. The longer the elapsed time, the brighter the bulb will be. The refresh rate is determined by the AC signal - 120 zero crossings a second for 60 Hz. The number of brightness levels will be determined by how frequently the bulb state can be updated within the AC half wave (8.33 ms). Thus, the brightness of an individual bulb is controlled by timed switching; each bulb just needs a single bit to control its state, so 128 bits total.

I'm working on a revised schematic that takes into account the advice given here. I'll post it for feedback in the next day or two.
 

Brownout

Joined Jan 10, 2012
2,390
I'm afraid you don't understand how dimming using zero crossing is accomplished. It's not your fault, the write up you're referencing isn't very good. What he's doing is sensing the zero crossing of the AC signal, and this truning on the bulb, via the triac, after a short delay from the zero crossing point. Then the triac turns off the bulb by itself at the next zero crossing. By varying the time delay between zero crossing and when the bulb is lighted, you can vary the amount of power delivered to the bulb, and hence it's brightness.

Now, back to your system. What is the data you are sending to the light array? Does every light get a '1' or a '0', or do you send "1's" to some lights and "0's" to other lights?

PS: No problem about straying into restricted subject matter. You're fine to discuss this.
 

Thread Starter

minisystem

Joined Dec 4, 2008
32
Ah, yes - I'm confusing the TRIAC method with the reverse phase method discussed in this thread: http://www.microchip.com/forums/m390109-p2.aspx where the bulb is turned on at zero cross and off some interval afterwards. Thanks for pointing that out.

With respect to your question about how the data is sent, it is the later scenario - on each update of the matrix some modules will get a 1 and others a 0 (ie. turn on or remain off).

Come to think of it, an IGBT reverse phase method might make more sense, but I was under the impression that the component costs and complexity are higher.
 
Last edited:

Brownout

Joined Jan 10, 2012
2,390
I can't comment on which method is better. I've only used phase control, it's cheap, easy and effective. Now that I know you're truning some lights off, your shift register makes more sense. The critical part is going to be keeping your clock line clean over a long length of wire. You'll need to use a controlled signal medium such as coax, and matched drivers. Or you can make the system super slow to allow for long settling times. I'm doing someting similar where I cannot use coax, and just running slow.

As others have said, you need to watch coupling into your clock or strobe line. This can drive you crazy if you get careless. I recommend shielded wire for that connection and careful routing. Also, you need a thick and isolated gound wire to each of your flip flops. You'll be daisy chaning the gournd, usually a big no-no. But you might get it to work. Use slow logic if possible, 4000 logic instead of 74 series.
 

Thread Starter

minisystem

Joined Dec 4, 2008
32
OK, again, thank you for all the advice.

For clarity, let me try to summarize what (I think) I've learned thus far:

1. Protecting my serial interface from AC noise due to 128 TRIACs switching should be accomplished by good PCB layout and physical separation of the AC power components and DC serial components.

2. Assuming point 1 is adequately addressed, the bigger concern is the nature of the serial interface itself and problems caused by daisy chaining VCC/GND, ground bounce, etc. Techniques to deal with this include robust VCC and GND busses, decoupling capacitors, coupling CLOCK and LATCH with GND in twisted pairs, etc.

I'm hoping to minimize the daisy chaining problem by dividing my 128 modules into 8 groups of 16. With two control modules on one PCB, I'll effectively reduce the daisy chaining to 8 modules. Perhaps each group of 8 modules should have its own regulated VCC supply?
 

Thread Starter

minisystem

Joined Dec 4, 2008
32
Just wanted to post a quick update to say that I followed the good advice given here and finished the project. 128 incandescent light bulbs, each with 64 levels of brightness control. In the end, I split the 128 bulbs into 8 groups of 16, each group getting an independent data bit with common clock and latch signals. I wasn't able to get twisted pair cable, so I used flat ribbon cable with each signal paired with a ground, lots of decoupling throughout, a separate DC bus and a PCB layout that separated the AC and DC components from each other.

It worked! It definitely wouldn't have worked without the wisdom of the kind folks here, so I just wanted to say thank you!

Here's a link to a video of the result: http://www.youtube.com/watch?v=yLKNo0W-5WE
 

djsfantasi

Joined Apr 11, 2010
9,156
Interesting performance. Did you also develop the software to drive the lights based on the audio input? How many channels (frequency ranges) does it recognize and what drives the light intensity? Amplitude? I also noted that the patterns seem to be mirrored along the central axis. I'd like to see the entire project documented in the Completed Projects collection, if you have time and can do so.
 

Thread Starter

minisystem

Joined Dec 4, 2008
32
Yes. Software was written in Processing and connects to an controller board on the matrix of bulbs via USB. Processing handled audio analysis - spectrum is divided into 8 bands and amplitude of each band is outputted to each row. Will get around to documenting it I hope in the near future.
 
Top