Click here to Skip to main content
16,010,650 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Visual C++ Pointers Pin
MMansonFan2529-Mar-05 23:10
MMansonFan2529-Mar-05 23:10 
GeneralProblem with ActiveX control's initial size(Please read this , i need this for my final year project) Pin
Faisal Sajjad26-Mar-05 1:13
Faisal Sajjad26-Mar-05 1:13 
GeneralLogic Question Pin
RedDragon2k26-Mar-05 1:12
RedDragon2k26-Mar-05 1:12 
GeneralRe: Logic Question Pin
toxcct26-Mar-05 4:13
toxcct26-Mar-05 4:13 
GeneralRe: Logic Question Pin
RedDragon2k26-Mar-05 5:54
RedDragon2k26-Mar-05 5:54 
GeneralRe: Logic Question Pin
Roger Wright26-Mar-05 6:43
professionalRoger Wright26-Mar-05 6:43 
GeneralRe: Logic Question Pin
RedDragon2k26-Mar-05 8:59
RedDragon2k26-Mar-05 8:59 
GeneralRe: Logic Question Pin
Roger Wright26-Mar-05 20:46
professionalRoger Wright26-Mar-05 20:46 
Okay, that's clear. Now, what are you using to monitor it? Do you have a digital input card or analog? Are you digitizing samples into a file, or simply ones and zeroes? In either case the method is similar, though an analog sampling device takes a bit more work to decide when the signal state has changed.

Method 1:
Sample the signal at a fixed interval of time. How often depends on the accuracy of measurement required. Initialize a counter on the first falling edge, then increment it until the next falling edge is detected. Multiply the count by the time between samples.

Method 2:
As before, sample at regular intervals, depending on the accuracy needed. At the first falling edge, read the system clock and save the value. At the second, read the clock again, then calculate the difference between the two values.

Since it's not really clear yet what you are looking for, one efficient way to detect a state change - assuming you're looking at a stream of digital inputs, not digitized analog - is to XOR the current value with the previous value. If the result is true, and the current value is 0, you have just found a falling edge. If the result is true and the current value is 1, you've detected a rising edge. Anytime the result of the XOR is false, the values match and no state change has occurred.

Both methods will be somewhat unreliable under Windows, as you can't guarantee that some samples won't be missed or delayed because of other tasks grabbing the CPU just before a new sample is scheduled. This is an application where a hardware solution is easier and better to use. A simple gate circuit to enable or disable a fixed, accurate clock signal connected to a counter will do the trick. The only trouble with a hardware solution is that, while the actual measurement circuit is trivial, the interface required to make it readable by a PC involves a lot of overhead. Why not buy a device made for the purpose? Dataq (www.dataq.com[^]) makes a line of inexpensive modules which connect to a serial port and come with software to use them for various measurements of this sort.

Good luck!Big Grin | :-D


"If it's Snowbird season, why can't we shoot them?" - Overheard in a bar in Bullhead City
GeneralRe: Logic Question Pin
RedDragon2k27-Mar-05 1:24
RedDragon2k27-Mar-05 1:24 
GeneralRe: Logic Question Pin
Roger Wright27-Mar-05 4:20
professionalRoger Wright27-Mar-05 4:20 
GeneralRe: Logic Question Pin
RedDragon2k27-Mar-05 21:16
RedDragon2k27-Mar-05 21:16 
GeneralRe: Logic Question Pin
Roger Wright28-Mar-05 1:56
professionalRoger Wright28-Mar-05 1:56 
GeneralDCom Pin
pardis26-Mar-05 0:58
pardis26-Mar-05 0:58 
Generalconstructor and copy constructor Pin
bobi_zcl26-Mar-05 0:03
bobi_zcl26-Mar-05 0:03 
GeneralRe: constructor and copy constructor Pin
toxcct26-Mar-05 1:00
toxcct26-Mar-05 1:00 
GeneralRe: constructor and copy constructor Pin
Michael Dunn26-Mar-05 9:49
sitebuilderMichael Dunn26-Mar-05 9:49 
Generalpentium IV bug Pin
violantly happy25-Mar-05 23:08
sussviolantly happy25-Mar-05 23:08 
GeneralRe: pentium IV bug Pin
Antony M Kancidrowski26-Mar-05 14:39
Antony M Kancidrowski26-Mar-05 14:39 
GeneralRe: pentium IV bug Pin
jidelnistul26-Mar-05 22:15
jidelnistul26-Mar-05 22:15 
GeneralRe: pentium IV bug Pin
Antony M Kancidrowski27-Mar-05 6:40
Antony M Kancidrowski27-Mar-05 6:40 
GeneralGDI+ Simple Help me Pin
Anand for every one25-Mar-05 21:34
Anand for every one25-Mar-05 21:34 
Questionwhat the header file for my backpropagation program? Pin
conniepooh25-Mar-05 19:31
conniepooh25-Mar-05 19:31 
QuestionHow to copy a File to another place using C++ Pin
pubududilena25-Mar-05 17:39
pubududilena25-Mar-05 17:39 
AnswerRe: How to copy a File to another place using C++ Pin
Anthony_Yio25-Mar-05 18:21
Anthony_Yio25-Mar-05 18:21 
AnswerRe: How to copy a File to another place using C++ Pin
David Crow26-Mar-05 7:24
David Crow26-Mar-05 7:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.