04-09-2008 04:02 PM
04-14-2008 11:19 AM
Hi vietwave,
Certainly the task of measuring pulse width would be easier using a counter card. Right now you are trying to measure the width in software, while it would be more accurate by measuring in hardware. How long are the digital pulses you are trying to measure? If accuracy is a strong requirement in your measurement it will be better to use counters for this application, and this card PCI-DIO-96 only has digital lines. Here are some helpful links in case you want to look more into that:
- Pulse-Width Measurement with a Counter
- Measuring Period, Semi-Period, Pulse Width, and Two-Edge Separation
Regarding your actual code I see that you are taking the millisecond timer value to calculate the pulse width; however that millisecond timer is the same for the vi inside the case structure and outside the case structure that’s why the actual pulse duration is zero. If you decide that this approach is good enough for your application I suggest that you use shift registers to save the value of the tick count vi. You can save the value of the tick count the first time you read high and save it, then subtract that value with the tick count the first time you read low after reading high, and so on. I hope this is helpful,
04-17-2008 02:39 PM