parallel output sequence, use a MCU? - Page 1
Forum section: electronics / projects

author: SArepairman
author_rank: Frequent Contributor
timestamp: March 13, 2014, 05:21:02 pm
content: So for one application I have in mind I would need a device that generates a sequence of codes in binary (parallel connection) in response to a inputso it would be likeclock -> output shift to 0b01010111clock -> output shift to 0b01111101......and eventually it repeats after N clock cycles (12-16 bit, even though I used 8 bits as the demonstrator)The output is not in sequence. I would also like all the outputs to update at the same timeI would like the transition time for each of the output shifts to be the sameIs the best way to go about this? I will potentially need 16 bits, so 16 outputs. If I use a 8 bit MCU and load two ports, so 16 bits total, it will delay, meaning that it will change the first half of the binary string before it changes the second half, leading the odd outputs.Do they have MCU's that could update 16 outputs at the same time? Do I need a FPGA?

author: deephaven
author_rank: Frequent Contributor
timestamp: March 13, 2014, 05:26:18 pm
content: If your micro has 17 pins available, you could just use two external 8 bit registers fed with 16 of the pins, with the 17th pin acting as a clock to update all 16 bits simultaneously.

author: SArepairman
author_rank: Frequent Contributor
timestamp: March 13, 2014, 05:28:56 pm
content: Quote from: deephaven on March 13, 2014, 05:26:18 pmBut how do you do that?"detect change on pin 17" "port A set 0bxxxxxxxxx)" "port b set 0bxxxxxxxxx)meaning, it will adjust port A, while port B is what it was, then it will adjust port B, so it will actually generate a"glitch" type output?number > glitch number> number 2

author: granz
author_rank: Regular Contributor
timestamp: March 13, 2014, 05:33:21 pm
content: How fast do you need your setup time to be?If you consider using an 8-bit mcu, for example a small PIC with an internal oscillator of 32 MHz, your setup time may still be fast enough. Even at 8 MIPs (most low end PICs are 4 clocks per instruction), that still is only 1/8e6 = 1.25e-7 = 125 ns between the two port writes. Add to that the setup time for the second port write (first port write setup time will overlap with "in-between" time).

author: deephaven
author_rank: Frequent Contributor
timestamp: March 13, 2014, 05:36:42 pm
content: Quote from: SArepairman on March 13, 2014, 05:28:56 pmNo, the two 8 bit outputs from the micro can do whatever they like until you decide they have the correct 16 bit number set up. At that point you toggle the 17th bit which clocks all 16 bits to the output of the registers. The stimulus input would be another pin on the micro which can be handled in a number of ways, like interrupts for example, but watch out for contact bounce if it is coming from something mechanical.

author: granz
author_rank: Regular Contributor
timestamp: March 13, 2014, 05:50:35 pm
content: You could also just use a 16-bit MCU and forget about all the extra wires for external registers if you need a faster setup time.

author: SArepairman
author_rank: Frequent Contributor
timestamp: March 13, 2014, 07:23:53 pm
content: Oh, a 16bit MCU has porta = 16 and a 32bit has a 32 bit port?I could just use a 16 bit pic then, no problem.and yes, this is effectively going to control an analog property with 16 bits, so that 100ns could very well matterif I could just use a 16 bit pic then I don't care about using a 8 bit pic, its just the first thing that came to mind, i got 16 bit MCU and 32 bit MCU here but I have not used one yet.

author: ajb
author_rank: Super Contributor
timestamp: March 13, 2014, 07:46:47 pm
content: If timing REALLY matters to that degree you could also use the external clock signal to directly drive the latch on the registers. Of course "directly" in this case may mean via a suitable filter/buffer depending on the characteristics of the clock signal. The MCU then just has to detect the clock pulse and then after a suitable setup time present the data for the next clock trigger on the register inputs. That takes any processing delay out of the equation and will get you as close to zero delay from clock to data transition as possible.

author: ve7xen
author_rank: Super Contributor
timestamp: March 14, 2014, 01:34:23 am
content: Quote from: SArepairman on March 13, 2014, 07:23:53 pmGenerally yes, since that is the length of the registers. Just check the pin mapping, as it's quite common to only map 8 or 12 or whatever pins from a port, even if the micro has multiple logical ports. All 16 outputs need to be controlled by the same register, then you can write them in a single shot.The old school way of doing this, assuming the sequence can be pre-calculated, would be to put the sequence in a parallel ROM or ROMs and drive the address bus with a counter. These days you might do the same with a pair of small 8-bit parallel flash chips, but it's probably still cheaper to just use a micro, and you don't need a separate counter IC (and clock) then.

author: NiHaoMike
author_rank: Super Contributor
timestamp: March 14, 2014, 02:51:41 am
content: What sort of clock rate are you aiming for? If it's low enough, an I/O port expander and a small microcontroller might do the trick.

author: Harvs
author_rank: Super Contributor
timestamp: March 14, 2014, 03:27:35 am
content: Quote from: SArepairman on March 13, 2014, 05:21:02 pmDo you need one? No.Doesn't mean you shouldn't use one, it's up to you. The smallest Lattice xo device is only $3.48 AUD, and they're pretty easy to work with (just grab a $35 Lattice XO2 dev board so you can use the programmer on it.)It's an option...

author: SArepairman
author_rank: Frequent Contributor
timestamp: March 14, 2014, 05:05:47 am
content: Well, from cradle to grave how long would it take to learn how to implement this program on aFPGA, including setting up the software?Could I be pretty damn sure from computer simulation what the result of programming will be, which I can then somehow do with a serial port?I feel like even with a micro that I never used before I could get it running in a board with no problems.Would a FPGA be better at getting the signals being transmitted at exactly the same time? Or would the performance be equal to a MCU changing all the signals at the same time (I thought maybe you could somehow fine tune the FPGA better) but I am not sure)?

author: SL4P
author_rank: Super Contributor
timestamp: March 14, 2014, 05:17:55 am
content: Use the cheapest PIC in your drawer, tie a couple of 74595s onto the SPI port and it will be done in 30 minutes. Use the 595 output enable pin to clock the n-bits of data out to your device synchronously.Solution under $3

author: SArepairman
author_rank: Frequent Contributor
timestamp: March 14, 2014, 05:19:06 am
content: Quote from: SL4P on March 14, 2014, 05:17:55 amEh, I don't like how many parts this requires if I can just use a single chip.

author: nuhamind2
author_rank: Regular Contributor
timestamp: March 14, 2014, 07:07:42 am
content: Not all 32 bit micro has 32 bit port. STM32F1 family has 16 bit port

author: poorchava
author_rank: Super Contributor
timestamp: March 14, 2014, 08:23:58 am
content: I would use register shadowing. As long as all the bits on the output bus are on the same port, just write all the signals to some variable and than write that variable to output register. Values will change at once. For a bigger number of bits I would use hc595's and spi - as someone suggested.

author: granz
author_rank: Regular Contributor
timestamp: March 14, 2014, 03:17:00 pm
content: Quote from: SArepairman on March 14, 2014, 05:05:47 amIf you've used FPGAs or CPLDs in the past it would be just as fast as using an MCU. If you haven't, it will take you a while to get things working. You'll have to learn VHDL or Verilog, figure out the new tool chain, etc. Even with a simple task like yours and a simple part (such as the XO2 chips from lattice mentioned) you'll have to a lot of new concepts to familiarize yourself with.Quote from: SArepairman on March 14, 2014, 05:05:47 amThe FPGA won't be any better intrinsically at pushing the full set of 16 bits out. You'd have to check the datasheets for actual part specs, but as long as you a setting a single output register with your 16-bit port MCU in one cycle there won't be an difference. FPGAs are much more flexible in other ways, but it sounds like in your case the 16-bit port MCU will be the quickest option.

author: SArepairman
author_rank: Frequent Contributor
timestamp: March 14, 2014, 06:50:00 pm
content: Quote from: granz on March 14, 2014, 03:17:00 pmwell, a FPGA would allow some degree of phase tuning that a microcontroller would not allow for right? Because you could tune the signal delay to the output with gimics such as inverter delay chains, right? With a MCU you are dead set against propagation delay errors in the drive circuitry, it would require some kind of external delay tuning.I don't know how significant it is but its something that I considered. I will study some MCU datasheets to see whats up but I am left wondering.

author: granz
author_rank: Regular Contributor
timestamp: March 14, 2014, 07:18:59 pm
content: Quote from: SArepairman on March 14, 2014, 06:50:00 pmSure, I guess that is something you could do with an FPGA vs. an MCU. You'd have to build your board with your chosen part in that case, then look at each signal at the end point and add buffer delays in your FPGA. That is not a very reproducible way of do things though, and I don't believe the specs for consistent delays with that method are very tight (it will vary from individual part to part). At least with the Xilinx parts I've work with, it's not a reliable way to introduce phase delays.It sounds like maybe you should be using clocked logic if this is such a big concern. As long as the time between your output samples is fairly long you should be fine.Also, note that the PC world has gone almost completely serial (SATA, PCIe, etc), because of the issues with propagation delay in parallel lines.

author: attie
author_rank: Contributor
timestamp: March 15, 2014, 08:36:03 am
content: I'd like to pose a few questions:Is the clock coming into this FPGA/MCU, or out of it?If you're so concerned about the bits changing out-of-sync, then what exactly is the clock for? It sounds like you're not using it correctly...What are you driving? A DAC?

author: SL4P
author_rank: Super Contributor
timestamp: March 15, 2014, 12:48:23 pm
content: Eh, I don't like how many parts this requires if I can just use a single chip.Unfortunately - you want synchronous presentation across all 16 bits. All the ideas are above - just pick one !Cheers

author: Hideki
author_rank: Frequent Contributor
timestamp: March 15, 2014, 02:56:15 pm
content: With an STM32F030C6T6 you get two full 16 bit ports and some additional pins for controlling it. Costs about $1.77 @ 1pcs.It can be run without a crystal (depends on your timing requirements) and can be programmed over a serial port (UART).Also check what TI, NXP, Freescale etc has to offer. Even PIC24 or MSP430 might work.

author: David Hess
author_rank: Super Contributor
timestamp: March 16, 2014, 05:08:45 pm
content: I prefer the 74595 solution and use it regularly:1. It only takes a couple of microcontroller I/O pins most of which may be shared with other functions.2. It is expandable to any width by just cascading the shift registers.3. The parallel load command may be multiplexed with the chip select or controlled by an external source.4. The 74595 shift registers may be remotely located and galvanic isolation is simple on the control side. This also makes them handy for keeping digital noise out of sensitive analog circuits and performing level shifts.5. Discrete integrated circuits in an interface application are easier and less expensive to replace when something goes wrong.6. May be combined with 74165 shift registers to make input ports.

author: Jarrod Roberson
author_rank: Regular Contributor
timestamp: March 21, 2014, 03:52:12 pm
content: Will a serial to parallel shift register not work in this situation?

author: granz
author_rank: Regular Contributor
timestamp: March 21, 2014, 05:04:25 pm
content: Quote from: Jarrod Roberson on March 21, 2014, 03:52:12 pmYes, the 74595 is a serial in, parallel out part. There is more than one solution, it's a matter of how many chips the OP wants to deal with.

author: David Hess
author_rank: Super Contributor
timestamp: March 21, 2014, 08:50:20 pm
content: The 74595 has latched outputs also so the outputs update simultaneously and are static while the shift register is updated.

author: dannyf
author_rank: Super Contributor
timestamp: March 21, 2014, 09:07:06 pm
content: QuoteProbably not really simultaneously, especially under differing load or supply limitations.But does it update with the spec of the intended application?

author: David Hess
author_rank: Super Contributor
timestamp: March 22, 2014, 01:09:41 am
content: Well, the only way you could improve it would be to only change one output at a time like with grey code. Contrast that with the output of a ripple counter or the 74164 which lacks an output latch.