12-07-2007 03:02 PM
12-10-2007 04:07 PM
Hi mavric,
There doesn't seem to be an easy solution for what you would like to implement. If I understand you correctly, you would like to dynamically update the pulse width of your output waveform from one tick of the clock to the next. The first problem is that you are using the digital lines to do the waveform generation. This will update with a new output point at every tick of the clock but the pulse width, frequency and other properties would need to be configured before the task has started. I believe you have figured this out already since you said you are currently implementing it by stopping and starting the task.
This online knowledgebase has a similar concept to what you would like to do. However, this uses a Counter Output to have a continuous pulse train output. In this example, property nodes are used to update the duty cycle of the pulse train within a loop after the task has started. If you open up the attached example, you will see that the property nodes are only updated as fast as the loop can run (software timed) and therefore the duty cycle of the pulse train can only be updated due to software and not by ticks of a hardware timed clock.
Finally, in the M series user manual on page 101, it indicates that you can generate digital waveforms only on port 0 DIO lines. This is probably why your program is crashing when you try to write out a waveform to Port 1 directly after the other waveform generation.
Your best option is to either try to use a counter for your pulse train and implement the example in the linked KB, or to continue to stop and start the task with the digital output as you have previously done. Hopefully this information will be helpful!
12-10-2007 07:26 PM
12-11-2007 02:59 PM
Hi Mavric,
In order to write data to a digital output port, you have to change the entire buffer (one per port) with every write. Therefore, you cannot write to a buffer for specific lines. As you said, when you write out data, you will use 8-bit unsigned integer data which is written out with one array for all 8 lines. However, you could rewrite the buffer for the entire port (including P0.1 and P0.2) , changing only 1 line in the array and keeping the other constant. This way, you it would look like you were writing to each line individually.