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 ...

Switches are TTL driven? Relays? Buffers?

I assume that this string is software generated, and is sent to the printer port or the serial port. Correct?

This is not an example

So your device consists of 5 switches/gates, and it also has to drive 5 gates?

Does 1 step mean one clock cycle? If so, who's clock cycle, the computer's or your device's?

This doesn't sound like a difficult problem, however you haven't done a very good job of describing what you are trying to accomplish. If you take the time to clarify your project, I will try to help you.

flank

Reply to
flank

Hi, Laura. Your description of your homework problem is kind of careless. If you want a good answer, you have to take care to describe your question precisely.

I'm going to make some assumptions based on your vague description. Your class assignment says you have a state machine which can set one and only one output at a time. However, your problem is that you want all of the outputs to be asserted simulataneously.

Given this brief but succinct description, it's possible to give a solution. If that's what you want, you need a serial-to-parallel shift register with data latch output.

These ICs are actually fairly common. For instance, the 74HC595 performs just this function. It costs less than $1 USD in single quantities, can give you 8 output bits per IC, and you can daisy chain many of these ICs together to make one shift register of almost any reasonable length.

(Note: there are rise- and fall-time considerations for the shift register clock and the latch clock. The capacitance of these inputs would realistically limit you to somewhere around 12 ICs in the chain or 96 discrete outputs, unless you locally buffer the clock signals.)

To use the HC595 as a basic SIPO (Serial-In-Parallel-Out) shift register, you need your state machine data output, as well as independent signals for the shift clock and latch clock. You may also want to use the reset signal and the output enable signal, if you want to reset the outputs on power up and you need to tri-state the outputs.

The data sheet makes this pretty clear if you have any background in electronics:

formatting link

If you're not aware of what a shift register or data latch is, please go back a few chapters and refresh.

Good luck Chris

Reply to
Chris

Hi flank,

Sorry for the bad description of the problem. I'm a computer scientist which doesn't know too much about circuits design.

Please read below my answers:

flank wrote:

I dont know what this means. I have to turn on/off some sources of light. This is what I have to do with them. No other constrain ...

Yes. The string is software generated ... and I have to send it to some port.

My device needs to be connected to computer (which sends it that binary string of length N) and it (the device) must set those N switches.

No. O(1) is from the complexity theory. It means that setting the state of the switches should be done in such way that is independent of value N. So, even if I have 4 switches or 20 switches the time to set them should be the same. I mean I have to do this operation in parallel for all switches. The number of clock cycles is not important. However, it should be the smallest possible :)

Thanks for your help. Laura

Reply to
laura

Hi Chris,

Your idea is good.

The point is that I'm a computer scientist which does not know too many about circuits.

Could you please explain me again how this device can handle more switches? How it scales up? For 8 switches I think that I got the idea, but I didn't understand how do you link them to obtain a bigger solution.

I also have a question: what means Serial-In-Parallel-Out ? Why it's serial at input? Should not be parallel too? I mean I have that binary string generated somehow (it can be generated into a register). I dont want to send it bit by bit to that shift register. All operations must be performed in parallel for all bits.

Thanks, Laura

Chris wrote:

Reply to
laura

Hi, Laura. First, please bottom post. On Google, click "show options", then "reply". Put your response to the post below the previous post -- that gives greater continuity, and makes it easier to answer the previous post with minimum scolling. Also, it helps for continuity -- most newsreaders don't act like Google Groups.

You'll need data latches to have all the digital outputs asserted simultaneously, of course. Two sets of latchess, actually -- one for latching in from the data bus, and another to latch from the intermediate latches to the output. But there's a basic problem I'm not too sure about. If you're transferring data from the state machine to the output data latches, you will be limited by the size of your data bus. For instance, if you've got an IBM PC with a 16-bit wide data bus, you will be limited to sending out 16 bits at a time. That means you'll need N clock cycles per every 16 bits. If you want it to be the same for 32, 48, or 64 bits, and you've only got 16 bits to change, you can delay loop while waiting. Is this what you're looking for?

I'm not sure this is being responsive. I'm also not sure if this is actually an electronics question, or a theoretical computer science homework puzzle problem. Possibly another newsgroup might be better able to give you a hand?

Chris

Reply to
Chris

Laura, I think this problem will be easy. You can use the computer's printer port to send the string. The "lights" you will be turning on and off will each be tied to a relay. A relay is an electric switch which is controlled by an electric signal. The electric signal from the computer port will be the activating signal. This will tell the relay to turn on or off your lights. How big your lights are depends on what type of relay you will use. I would guess that this project has been done many times over and is available on the internet somewhere.

flank

laura wrote:

Reply to
flank

The chips contain a row of flip flops that copy one bit each when a latch input changes from a 1 to a 0 (or vive versa, depending on the particular latch) To add more bits, you parallel on more flip flops.

The terms "serial" and "Parallel" refer to how the flip flops pass data between then, and between an external signal source and an external signal receiver. "Serial in: means that the external data passes from one flip flop to the next as a bucket brigade, as it is received from the external source and shifted along in response to a serial clock. "Parallel out" means that, on a different command signal, all flip flops send their outputs, in parallel (through separate lines) to as many signal receivers. The opposite is also possible (and more like what you need), where many parallel signal sources have their data latched into many parallel flip flops on command, and then pass that data along the row of flip flops, in response to a serial clock, so that all the input bits exit through a single line, one after the other and one per serial clock. This would be parallel in, serial out.

As I said, parallel in, serial out may be more like what you need, if you have time between loads to clock those bits out.

Go to:

formatting link
select "logic by function" (along the left side), Then in the top search box enter [parallel-in].

Lots of useful links will appear, including one to a data sheet for the MM74HC165 parallel in/serial out shift register.

Reply to
John Popelish

This may not be of much use to you, but it shows a methode of transferring groups of 8 bits from the PC to a number of shift registers. So, if you send 3 characters from the PC you can set 24 switches. But the only way to clear the outputs is to shift in 24 zeros and the outputs will be changing while this is done. However, if it's done at high speed, the changes will occur in a short period of time which may, or may not be a problem.

formatting link

-Bill

Reply to
Bill Bowden

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

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

--
In a word, no.
Reply to
John Fields

That's because the choice between serial & parallel input to your shift register or latch is extremely architecture & implementation dependent, & we know nothing about either your existing architecture or the implementation constraints.

Okay, that's some help.

Yes, but there are still a lot of implementation details that affect the /practicality/ of doing it in parallel.

For the sake of argument, let's assume that your architecture (eg; a development board with a typical 8 bit CPU) has at least one 8 bit I/O ports you can use to implement your solution to this problem, & you can wire that 8 bit port to 8 LEDs. In this case; if the range of N is from 1 to 8 (ie; you only need to consider 1 to 8 'switches'), you can indeed set them in a single operation, & that is a complete answer to your question.

OTOH, if 'N' (number of switches) can be /more/ than 8, the problem is harder, in that you need to load latches (or shift registers, etc) in blocks of 8 bits (or fewer, depending on your clocking options), & the number of operations required will be proportional to N/8.

Please note that this is a separate problem to the question of whether

- after loading all the 8 bit groups - you can enable them all in one operation. As previous posters have explained, the answer is 'yes', & there are several standard designs that will achieve that result.

The serial vs parallel question only becomes relevent when you know the range of values permitted for N, which you have not yet stated.

And BTW, if this actually is a homework problem, the person you should really be asking questions of is your teacher or their teaching assistant.

--
   W          
 . | ,. w ,   "Some people are alive only because
  \\|/  \\|/     it is illegal to kill them."    Perna condita delenda est
---^----^---------------------------------------------------------------
Reply to
Lionel

Hi John,

Why do you say NO? The other people on the list say that I could do this operation purely in parallel for 8 bits.

Thanks, Laura

Reply to
laura

--- If your array of lamps is only 8 bits wide, (if you only have 8 lamps) then yes, you could drive them in parallel using the parallel port.

If you have more than 8 lamps and you can only access the computer's external data ports then you won't be able to drive them in parallel. Do you understand why?

-- John Fields Professional Circuit Designer

Reply to
John Fields

If you want an unusual idea, here it is. You can send your data as digital audio data with 2*24bits to the soundcard with SP/DIF optical output, and receive it with normal audio receiver like the Cirrus CS8415A. The receiver decodes the signal and gives out a serial data stream, Clk and Frame, which can be easily parallelized without a uP. Minimal data rate is 8kHz, maximal

96kHz. You could even dimm the lights with PWM. The timing is 100% secure and could even be synchronized with some music signal. AES3 allows non-audio data to be send. Very little strain on the CPU, since the soundcard does all the processing, platform independent, you could even record a sequence on DVD and play it into the receiver box.
--
ciao Ban
Apricale, Italy
Reply to
Ban

if you always send 20 bits you'd get that effect, but if you needed to upgrade to 1000000 switches that wouldn't work.

if it's serial there must be a bit clock to determine where the bits start and end, and it will take order N time to send the data.

what do you mean by check?

Bye. Jasen

Reply to
Jasen Betts

Dear Ban,

Could you give me more details about your idea, because I didn't understand it very well.

Thanks, Laura

Reply to
laura

Yes John,

I understand.

Thanks, Laura

Reply to
laura

Well, if you have a soundcard with a digital output you can usually send a data stream there with some editing program like Adobe Audacity, where you specify your device (Soundmax digital Audio) and the format (48kHz, 16bit, Stereo). You can produce a .wav-file where you can set each of these

2*16bits individually. I'm actually not a specialist with suitable programs, but when you are a programmer you can probably write it yourself. I know Matlab can do it. For each second you have 8000 to 96000 samples to fill, which can be automized. When you play this file it is sent to the soundcard. there are circular buffers etc. so after a known latency your card encodes this file into a S/PDIF data stream and gives it out on the digital RCA or optical output like when you play a CD. That is the easy part.

Now you have to build a small box where the cable can be plugged in and this is called a receiver. It has some electronic circuits inside which will decode the stream and have 32 outputs. Since each second all outputs are updated at the specified sample rate(48000 times), you can switch every output very fast on and off. When you connect some LEDs there it is perceived as more ore less bright, depending on the on and off percentage. This box has to be designed by some electronic specialist or engineer and will probably cost a lot for a one-off. But when you plan to sell more it can be duplicated easily and cheap. I am doing this kind of things, that's my job. You can simultaneously also interleave some music files which can be synchronized with the lightshow. heck you can record everything together on a DVD and plug the receiverbox into any DVD-player and play it anywhere. Lightshow and Music! Good Idea?

--
ciao Ban
Apricale, Italy
Reply to
Ban

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.