device for converting binary strings into states for switches

Hi,

I need to buid a device connected to a computer. The computer will generate binary strings (each position will be either 0 or 1) of length N. Based on this string my device has to set the state (on/off) of N switches.

Example:

The computer generates the string 00110. I also have 5 switches which must be set by my device as follows: first

2 switches and the last switch must be turned OFF and the 3rd and the 4th must be turned ON.

I have a hard constrain for this problem: the operation described above must be performed in O(1) steps. This means that it should be INDEPENDENT of the value of N. All switches must be set in the same moment.

I DONT want to check the value of each position and to set the state of the corresponding switch accordingly. This will means O(N) steps and I want only O(1) steps.

How can I make such device? I should use some properties of the computer ports, but I dont know how.

Even some small values for N (16 or 32) are of interest for me.

Thanks. Laura

Reply to
laura
Loading thread data ...

If N=8, you are looking at a parallel port.

If N = some multiple of 8, you can use a serial port and UART, sending N/8 bytes each time.

Without saying what computer port you want to use or what the switches are going to be controlling, it's hard to say more.

How fast does it need to be?

Reply to
mc

I dont know which port should I use ... please give me the best suggestion.

I use the switches for turning some light source on/off.

The device must be really fast... This is a priority.

laura

mc wrote:

Reply to
laura

I dont know which port should I use ... please give me the best suggestion.

I use the switches for turning some light source on/off.

The device must be really fast... This is a priority.

laura

mc wrote:

Reply to
laura

Is this a homework assignment?

I ask because most kinds of light sources inherently don't turn on and off all that fast. Incandescent bulbs, for instance, can take as much as 0.25 second to reach full brightness. To a computer, that is a very, very long time, and anything you do on the computer will be much faster than that. LEDs can turn on much faster (order of 0.1 millisecond, I think, maybe faster yet).

If this is not a homework assignment, could you give us some concrete details such as type of computer, type of light sources, and speed requirement?

Reply to
mc

If you have 3 digital port pins on your computer you could use some shift registers with latch, e.g. 4094. Use one pin for data, one for the shift clock and the 3rd for the latch enable. To transmit the pattern '00110' simply shift '0','0','1','1','0' and finally latch the data.

--
Dipl.-Inform(FH) Peter Heitzer, peter.heitzer@rz.uni-regensburg.de
HTML mails will be forwarded to /dev/null.
Reply to
Peter Heitzer

"laura" a écrit dans le message de news: snipped-for-privacy@i40g2000cwc.googlegroups.com...

If this is a theoritical question then the answer is I guess "you can't". Imagine that N=10000000000000000000, then there is no doubt that a computer will take some time to send the switch values to the outside world, whatever port and mechanisms are used.

If this is a practical question then we would need to know what are the order of magnitude of N and maximum switch time to give you good engineering advices...

Cheers, Robert

Reply to
Robert Lacoste

This problem has to be divided into several parts. First is to communicate with the computer. What protocall, what software, serial, parallel all must be defined before you attack the problem. Secondly what are the switches? how many, 16?, 32?, more? What current must they switch? , AC?, DC?, What voltage? All of these questions must be answered before a design is attempted.

I designed a MIDI (Musical Instrument Digital Interface) interface which is similar to this for driving a pipe organ. It uses a PIC processor with a built in USART to communicate with the computer using the MIDI protocall. It opererates at 31Kbaud, serial. The processor uses the various MIDI commands to decode and process the information sent to it. The processor drives a group of 8, 8bit latches (74HC259) to provide 64 channels of output that latch on and off with the MIDI note commands. There are high current drivers connected to the latches for operating the organ magnets. It operates on any MIDI sequencing software. If you'd like more information please e-mail me: montassocatyahoodotcom. Bob

Reply to
Bob Eld

On Tue, 16 May 2006 07:06:46 -0700, laura top-posted:

With a parallel port, you can switch 8 outputs simultaneously.

If you only have a serial data stream, then you'll need N clocks to load a shift register, and one more bit time to transfer the shift register contents to a latch, to make all the outputs switch simultaneously.

This can be done in microseconds.

Good Luck! Rich

Reply to
Rich Grise

Hi Rich

Is there any possibility to load the shift register in 1 clock? What kind of data stream do I have in my computer? How can I put a parallel one?

thanks, Laura

Reply to
laura

Hi all,

I have received several posts and I've got confused. I mean I'm not very sure if I can do this operation purely in parallel.

I mean: I have that binary string generated into a variable of type int (max 32 bits from C language). Or, imagine that I have it into the processor registry AX. Or, in a smaller registry/variable (that has only 8 bits).

Can I map this string into states of the switches doing only operations in parallel? I need NO serial operations (I mean I DON'T want to have an operation which traverse that string bit by bit - for shift purposes, etc). The serial operations means O(N) complexity, and I want to avoid that. I want to make only O(1) operations. This means that everything should be performed in parallel - from that binary string which is stored in the bits of AX registry .... to the states of the switches that I want to turn ON/OFF.

Is this possible?

Thanks, Laura

Reply to
laura

Yes, if N is less than the width of your processor's external bus - 8 for some old or small systems, probably for most current desktops 32, or 64 in some cases. If N is greater than that, you will have to traverse the word in chunks however many physical bits are available.

If N is 8 you can use a parallel port. For larger values of N, you need to purchase a digital I/O card, probably PCI based. National insturments has them

formatting link
you might also find something at a pc parts vendor like JDR Microdevices.

You should really consider if you need true parallelism, or if something that might be electronically serial at a many-MHz rate would be fast enough. Particularly if the bits are loaded up serially internal to bunch of I/O registers, and then the changed released to the outside world all at once. For practical bit widths you may find no difference between a device of this sort connected to the computer via a USB port (or in more extreme cases, firewire port), and a parallel device sitting on the PCI bus.

For values of N over 32, another possibility is to consider building a custom wide-word processor in a field programmable gate array chip (FPGA). You could build such a device so that an "AX register" a few hundred bits wide would directly drive I/O pins. When you want to do parallel computations wider than available processor words, especially if you want to then output those parallel words, an FPGA may be the way to go.

Reply to
cs_posting

Any old shift register should do this.

--
Many thanks,

Don Lancaster                          voice phone: (928)428-4073
Synergetics   3860 West First Street   Box 809 Thatcher, AZ 85552
rss: http://www.tinaja.com/whtnu.xml   email: don@tinaja.com

Please visit my GURU\'s LAIR web site at http://www.tinaja.com
Reply to
Don Lancaster

Absolutely. It's almost trivial. First, look up how to control the PC printer port:

formatting link

Then just send a byte at a time. Since you're talking about the AX register, you apparently have access to the hardware. Say you've got a 32-bit value in DX/AX; you can send that to the printer port with a little trickery, if you have some smarts on the output side. Just output AL, move or copy AH to AL, output it, move DL to AL, output it, and move DH to AL and output it. Your device will need to know to distinguish the four bytes, but you could use the control lines to define up to 32 separate ports, with a little clever programming.

And, if you _really_ want to get fancy-schmancy, you could use one control line for strobe, and another for address/data, and have 256 ports; with one for strobe, one for "low address", and one for "high address", you could do 65536 x 8-bit ports, with suitable decoding and latching.

Good Luck! Rich

Reply to
Rich Grise

Yes. Read up on what a byte is and logical operations on it, in whatever programming language you'll be using. If you'll be using only

8 bits or less send them directly to the parallel port through a latch, enabled by one of the control lines. If there are more than 8 you'll need a bunch of shift registers, one control for shifting and another for setting final output states.

Read up on parallel port, shift registers and latches. A good starting point is

formatting link
and some googling.

Don't do this in Windows, it's too slow and unstable. Set up a dedicated box with Linux, MS-DOS, FreeDOS or whatever OS you fancy.

I've done something similar to what you're after for running a couple of stepper motors.

- YD.

--
Remove HAT if replying by mail.
Reply to
YD

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.