08-06-2009 10:06 AM
I am working on a project which require both measure and generate PWM signals.
Currently I have some issues with both of these.
I use PXI NI 6624 card.
1. Issue with measure PWM.
I connect the signal to Gate + and GND to Gate -. I expect I can read the width of the high pulse, casue the gate will start the counter.
I use the code as in example of measure the duty cycle (in picture 1). The problem I have is the values in the array also include the low pulse, and these two values will be shifted in the array. So if I index from the array I cannot get a stable number (in picture 2).
I want to know the reason and how to fix it.
2. Issue with generate PWM.
I use another counter to generate the PWM.
I connect Vdd and Vss with a 13.8V DC Power Supply. I use a 10 KOhm resister connect between Vss and Out. I got a right signal with 13.8 V.
a> My first problem is the frequency is not stable. I set it to 122 Hz, and I saw it jump from 119Hz to 125Hz.
b> My second problem is when I connect this to the measure PWM I did above the voltage will down to 2.5 V. I tried with 1 KOhm resister and it downs to 6V. When I connect a real controller with a 12V PWM, this signal is stable after I connect with measure PWM channel above.
I would like to know if I did anything wrong. Cause this PWM will be use to simulate a sensor value and it must be stable.
I highly appreciate reading and answering my questions.
Best regards,
Thang Nguyen
Solved! Go to Solution.
08-10-2009 01:57 PM
Hey Thang,
Try changing timebase and also remove the wait from the while loop and add samples to read terminal. Attached is the BD for that try this, it should help you.
Lab
08-12-2009 05:10 PM
Thank you so much,
I tried with your diagram and it work.
Best regards,
08-13-2009 05:26 PM
As I understand the DAQmx will read both high pulse and low pulse. I tried to divide the time of high pulse by the total as below instruction,
so I can get both duty cycle and frequency.
http://decibel.ni.com/content/docs/DOC-3424
But some how when I increase the duty cycle to more thang 70% it start changing. I have only half of frequency and the duty cycle is 50%. I don't know why. I use the meter indicator and the knit swing back and forth.
Still don't know why.
If I use an express VI I can get the high pulse really stable but I cannot get the frequency.
08-14-2009 09:37 AM
This is my test program. When the duty cycle go more than 70% the low pulse time starts fluctuate between the low pulse time and high pulse time => change the frequency and duty cycle.
Am I right or I should use this solution?
Best regards,