GammageATX Posted March 27, 2009 Report Posted March 27, 2009 I am trying to generate two square waves continuously. This in itself has cause me problems. But I also need to vary the duty cycle of one of the pulses during run time, varying the frequency on the other would be nice but isn't necessary. One way I have found to do this causes a lot of software jitter in the signal. I have found two examples; one for each of the things I want to do and have tried to merge the logic. The result is included. This hasn't proved successful. Any help would be appreciated. THanks Using Labview 8.5 Quote
Neville D Posted March 27, 2009 Report Posted March 27, 2009 Do you need to poll the frequency and duty cycle changes so rapidly? Try using an event structure in a loop. If there is a value change event, write to the required property node. See below: There are additional Stop2 and Freq2 value change events that are dealt with similarly. The boolean Shift-reg stores whether either of the stop buttons has been depressed. If both have been pressed, then it exits. N. Quote
jg69 Posted March 27, 2009 Report Posted March 27, 2009 My experience is that you have to write both properties (Duty Cycle & Frequency) within the same property node, also you want to change only one. For reasons unknown to me, the duty cycle will not change, if you do not write frequency at the same time. Jens Quote
GammageATX Posted March 30, 2009 Author Report Posted March 30, 2009 I am trying to understand the simplest case first and I haven't been able to get it going. This is what I have so far for running two signals and having one that allows for a change of the duty cycle. I can't seem to get the duty cycle to change though. Am I missing something? Quote
Neville D Posted March 31, 2009 Report Posted March 31, 2009 QUOTE (GammageATX @ Mar 29 2009, 02:44 PM) Am I missing something? Yes, quite a lot..! The stop case doesn't seem to actually stop the tasks, just the loop. The DutyCycle2 etc.. stuff doesn't seem to be going anywhere after the initial setup and run. Why don't you just simplify and try with a single counter and then add the next one later. Add changing freq+Duty cycle as another has posted. Put the Stop button INSIDE the event structure and feed the result out to the loop stop icon. Add a timeout event to stop the loop (instead of freezing it) in case there is a DAQ error. Look at my screen shots posted earlier about how to stop the code gracefully. N. Quote
GammageATX Posted April 1, 2009 Author Report Posted April 1, 2009 Ok, I see what your saying now. I've made changes and if you wouldn't mind looking at them again, it would help me out a lot. Thanks again. QUOTE (Neville D @ Mar 30 2009, 12:51 PM) Yes, quite a lot..! The stop case doesn't seem to actually stop the tasks, just the loop. The DutyCycle2 etc.. stuff doesn't seem to be going anywhere after the initial setup and run.Why don't you just simplify and try with a single counter and then add the next one later. Add changing freq+Duty cycle as another has posted. Put the Stop button INSIDE the event structure and feed the result out to the loop stop icon. Add a timeout event to stop the loop (instead of freezing it) in case there is a DAQ error. Look at my screen shots posted earlier about how to stop the code gracefully. N. Quote
jg69 Posted April 1, 2009 Report Posted April 1, 2009 I would include the following changes. 1. As already said, update Frequency AND duty cycle at the same time. From my experience, it won't work, if you only write one property... 2. I'd stop both tasks in Stop-Case. 3. I included a case-structure which tests if you can already write a new dutycycle value. You can only set a new parameter if at least one cycle with the previous values has been generated. Download File:post-8741-1238518481.vi Perhaps still not perfect, but it should work. Jens Quote
Justin Reina Posted April 1, 2009 Report Posted April 1, 2009 Hey All, Been following this thread, and had a few ideas for code org. However they contribute 'nada' to the task at hand, but maybe they may be of interest. Also, what hardware are you using? Best of Luck, Justin Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.