Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

4-bit binary counters 2

Status
Not open for further replies.

kennyC

Electrical
Aug 29, 2003
12
0
0
GB
This is embarressingly basic, but my brain is fried from going round in circles.

I have a set of wall sensors that all have individual binary codes that need addressed to step through each module and request the state of all the sensors on each module. The information is sent back to a computer where the info is displayed.

I`m trying to find a simple to implement (preferably hardware, but by software if necessary) a count through from 0 to 16 and loop which will deal with the sensors, but if possible to take take each pulse and use it to increment the program to cycle through each wall module on the computer, ie when the wall module addressing increments from, say, 11 to 12, the computer will increment the "data page" from 11 to 12 as well so the info being fed back is shown in the right place.

ATM, I`m looking at a 2-part binary counter with a separate crystal oscillator. Does anyone have any ideas on all-in-one packages that are cheap and easy to work with?

Any more info ya need, just ask :)

Thanks a lot,

Kenny
 
Replies continue below

Recommended for you

I think that you say that your sensors have individual codes and that you need to poll them from a computer, using one code at a time. Right? This surely means that you have to write some kind of a program to do just that. Creating a loop with a counter going from 0 to 15, using loop index for the address (perhaps via a table) and then starting from zero again seems to be the simple solution. What is the problem?

Gunnar Englund
 
Thats the "easiest" way to do it, I agree. I`ve been asked to avoid a microcontroller if possible, and I`m not the worlds greatest programmer :D At the moment, using a microcontroller looks inevitable from the way I`m seeing it, but I`m open to alternative ideas :)

Thanks!

Kenny
 
The computer that is showing the data "in the right place", should also be fully capable of banging bits to talk to the modules.

Hint: A PC's parallel port can be made to do almost anything.

 
OK, a piece of hardware that otputs a set of four bits increasing from 0 to 15? The good old binary counter 74xx93 does just that. There are also counters in other logic families. But the 74HCT93 is available and cheap. For the timing, I would use a simple RC oscilator based on a 74HCT14 and a capacitor/resistor.

Gunnar Englund
 
It seems to me that:
1.) you want to read 16 sensors, perhaps with individual
calibration factors, process the data, display,
perhaps store and perform some kind of statistics
and other operations.
2.) I don't think it is reasonable to do it with pure
hardware --you need some computer.
3.) Around 70 bucks you can get PC compatible business
card size computer which I would program in some
BASIC.
4.) Can you build the interface logic ?
==================================================
To give some real help, we need more data:
1.) Sensors make and type#
2.) a simple pseudo-program e.g.

; temp : integer array of 16
10 times
{ for address = 0 to 15
{ output adress
input t
add t to temp( address) }
}
divide the temp array by 10
display temp array (Format ??)
reset temp array

etc.
Or at least a very good description of what do
you want to do with the sensor readings ?





<nbucska@pc33peripherals.com> omit 33 Use subj: ENG-TIPS
Plesae read FAQ240-1032
 
Hi! Thanks for the replies!

The door sensors are very basic- sending a "1" or a "0" depending on the state of the sensors. No calibration, but storage and display are needed. To be able to take the data and use it in statistics, graphs etc would be nice, but is considered a luxery and not expected of what i`ve been asked. I was thinking af avoiding 0000 and 1111 as sensor readings for power-on reset and keeping 1111 just in case so 14 actual wall modules- omitting 0000 and 1111 from the cycle doesnt matter- there just wont be any wall modules with those codes.

I`ve yet to really get into the programming so cant knock together a demo code yet, sorry.

I had a quick play with the 74HC161 earlier today, but no crystal kicking around to use with it straight away unfortunately :( A bit of wire connected to the 5V rail should do though, right?

:)

Kenny
 
KennyC:
Please read the )(&*^%&(&&% FAQ !!!
and then why don't you just tell us, what are you trying to do.

It may be simpler to design the circuit than finding out
what you want.


<nbucska@pc33peripherals.com> omit 33 Use subj: ENG-TIPS
Plesae read FAQ240-1032
 
"...simpler to design the circuit than finding out what you want."

'Situation normal' for most projects. Deep inside every huge project is a ten minute design exercise.

 
Using a free running hardware counter to increment the polling address is fraught with danger, because any number of circumstances can cause the computer's internal index that should correspond to the counter's polling address to get out of synch with the hardware counter. WHEN this happens, the data coming into the computer goes into the wrong bin, and becomes the wrong data.

Remember, with a free running counter, the computer doesn't know when the counter is being incremented, so it's easy for the computer to read the data from sensor N+1 when the computer thinks it's looking at sensor N.

This can happen despite the presence of command pulses sent from computer to counter, index pulses sent from counter to computer, or even complicated handshake sequences between the two devices, because the computer's response time, thanks to Windoze, is not known, predictable, or limited.

BETTER that the computer should generate the binary address internally, use the exact same storage location as the index for the storage array, and send out the polling address as it is needed, when it is needed, using the simplest, dumbest possible hardware.

This has the further advantage that the sensors can be polled in any order, and the frequency of polling may be individually adjusted as needs change.



Mike Halloran
Pembroke Pines, FL, USA
 
I speak from experience here. I have been associated with several projects where the electronics engineers implemented auto- incremented addressing in multipoint data acquisition boards, because they could do it, and it sounded cool, and "it made the programmers' job easier".

Of course, the odd cosmic ray would auto- increment the address when it wasn't supposed to increment, or transients would make an increment pulse disappear, and pretty soon the programmer would be tasked with figuring out which channel had actually been read, using hardware that was smart enough to get in the way, not smart enough to check itself, and not dumb enough to work right.

As a former Professional Programmer (when that didn't mean Web Developer) and Hacker (when that was a good thing), I hate 'smart' hardware. And 'high level' and 'third generation' languages, but that's a different discussion.



Mike Halloran
Pembroke Pines, FL, USA
 
Star 2 Mike for being right.

In the 80-s I worked for a start-up. We had one PDP-11 with
30 terminals for engineering, inventory,payroll etc.
The two 10 Mb disk was enough for more than two years.

We had less/no bells and whistles but no virus, spam,
and seldom any bug.

My productivity as user/programmer/designer was higher.


<nbucska@pc33peripherals.com> omit 33 Use subj: ENG-TIPS
Plesae read FAQ240-1032
 
Ah yes so did we. Was the size of two refrigerators. Ours was so old it had "core" memory and we had to manaully, (using toggle switches), set in the first five instructions to boot the system.

It always worked.[infinity]

Keith Cress
Flamin Systems, Inc.- - kcress@<solve this puzzle>
 
Well, I know some places till use PDO-11 e.g. for trafic light or process control...

<nbucska@pc33peripherals.com> omit 33 Use subj: ENG-TIPS
Plesae read FAQ240-1032
 
Status
Not open for further replies.
Back
Top