Counting TTL Input signals

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2006
Posts: 7
Reputation: jennifer911 is an unknown quantity at this point 
Solved Threads: 0
jennifer911 jennifer911 is offline Offline
Newbie Poster

Counting TTL Input signals

 
0
  #1
Nov 6th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Counting TTL Input signals

 
0
  #2
Nov 6th, 2006
Originally Posted by jennifer911 View Post
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.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 7
Reputation: jennifer911 is an unknown quantity at this point 
Solved Threads: 0
jennifer911 jennifer911 is offline Offline
Newbie Poster

Re: Counting TTL Input signals

 
0
  #3
Nov 6th, 2006
Originally Posted by iamthwee View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,378
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1466
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Counting TTL Input signals

 
0
  #4
Nov 6th, 2006
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.
Last edited by Ancient Dragon; Nov 6th, 2006 at 3:36 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 486
Reputation: Bench has a spectacular aura about Bench has a spectacular aura about Bench has a spectacular aura about 
Solved Threads: 48
Bench's Avatar
Bench Bench is offline Offline
Posting Pro in Training

Re: Counting TTL Input signals

 
0
  #5
Nov 6th, 2006
Originally Posted by jennifer911 View Post
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.
Last edited by Bench; Nov 6th, 2006 at 3:44 pm.
¿umop apisdn upside down?
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 7
Reputation: jennifer911 is an unknown quantity at this point 
Solved Threads: 0
jennifer911 jennifer911 is offline Offline
Newbie Poster

Re: Counting TTL Input signals

 
0
  #6
Nov 6th, 2006
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?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,378
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1466
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Counting TTL Input signals

 
0
  #7
Nov 6th, 2006
how is the pulse generator connected to the computer?
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 7
Reputation: jennifer911 is an unknown quantity at this point 
Solved Threads: 0
jennifer911 jennifer911 is offline Offline
Newbie Poster

Re: Counting TTL Input signals

 
0
  #8
Nov 6th, 2006
using an RS 485 cable i think
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,378
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1466
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Counting TTL Input signals

 
0
  #9
Nov 6th, 2006
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
Last edited by Ancient Dragon; Nov 6th, 2006 at 6:42 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 7
Reputation: jennifer911 is an unknown quantity at this point 
Solved Threads: 0
jennifer911 jennifer911 is offline Offline
Newbie Poster

Re: Counting TTL Input signals

 
0
  #10
Nov 6th, 2006
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?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC