954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Counting TTL Input signals

Hi,

I need to write a counter code to count the number of spikes in the TTL logic input signal... What should I take as an input... Can i write it normally by putting the count in an infinite loop like

while(1)
// increment count

exit(1)

something like this... or is there a different way of doing this.

J

jennifer911
Newbie Poster
7 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 
Hi, I need to write a counter code to count the number of spikes in the TTL logic input signal... What should I take as an input... Can i write it normally by putting the count in an infinite loop like while(1) // increment count exit(1) something like this... or is there a different way of doing this. J


What has your instructor or teacher advised you to do? Do you have any notes.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 
What has your instructor or teacher advised you to do? Do you have any notes.


I don't have any notes. I am free to do what i please. But I was just baffled about how to program the whole thing.

Suppose a pulse generator gives out signals as a stream and we need to count the numberr of pulses... then how do we do that.

jennifer911
Newbie Poster
7 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

I would suppose it depends on how the pulse generator is sending the signals -- out its RS232 serial port ? If that is the case you will have to attach an rs232 serial cable to your com1 or com2 port and listen for incoming data on the computer side. Most likely it will be just a change in state of one of the pins instead of incoming data. Its been over 10 years since the last time I have done that so I would have to research some very old code, if I still have it, to see how that is done. One thing for certain, you will need a 16-bit compiler such as Turbo C that will allow direct access to ports. You might also need to do a little assembly language.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 
Suppose a pulse generator gives out signals as a stream and we need to count the numberr of pulses... then how do we do that.

Are you actually capturing data from this device? or is it a make-believe example where you have to simulate the data capture?

simulating data capture should be easy - just read some data of your choice from the keyboard, and process it bit by bit as the pulses are read (the usual choice for representing digital input such as electromagnetic pulses is 1 and 0, but you could use anything)

A loop would be useful for determining when data capture is finished. You could use selection (eg - if/else) to determine whether the input is "on" or "off".

If there is a real device which you're reading from, then it still may be a good idea to start your program with simulated keyboard input where you are controlling the input - this means you can get that part right before you attempt to combine it with your real data capture code.

Bench
Posting Pro
577 posts since Feb 2006
Reputation Points: 307
Solved Threads: 63
 

I am simulating the input using the Pulse Generator. The actual input will be from some other source. When I fix the pulse generator the computer has to start counting the number of pulses. How do I do this? Firstlyy the system has to detect the start of the pulse and then it has to count until the stream is stopped. The number of pulses has to be given as the output. What is a way to doing this. Can this be done usng a count program or is there any other way?

jennifer911
Newbie Poster
7 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

how is the pulse generator connected to the computer?

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

using an RS 485 cable i think

jennifer911
Newbie Poster
7 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

is the pulse generator going to actually send data to the computer or just change the state of one of its 32 pins to on and off ?

Please read this site

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

TTl signals will be amplified and sent to the computer and it would have to count them. We are not connecting the source of signals just yet and will be testing it using a pulse generator to test the code.... how do i write a code to count the number of pulses issued?

jennifer911
Newbie Poster
7 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

You keep asking the same question over and over. Unfortunately, without knowing what the data looks like (as all responses have tried to ascertain) there's not much we can suggest. Figure out what the data looks like to the program, then the way to count the pulses will become apparent.

WaltP
Posting Sage w/ dash of thyme
Moderator
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 

i'm sorry for coming in with inadequate information. I need to code the MSXB 036 counter timer board from Microstar. The inputs will be from the ion multiplier. The counter will have to count the TTL voltage inputs that are input from the ion multiplier. Can I code this in C or C++?

jennifer911
Newbie Poster
7 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

It's best if you just ask the manufacturer of that board. Not very likely anyone around here knows the answer.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Hey thanks for your reply. I shall do that.

jennifer911
Newbie Poster
7 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 
you will need a 16-bit compiler such as Turbo C



You could better use your own compiler and look for inpout32 .dll which gives you direct acces to ports in XP.

using an RS 485 cable
So a 2-wire protocol? You could use one of the five input on the parrallel cable (like the error bit) and test on that

Nick Evan
Not a Llama
Moderator
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You