## Custom Waveform generation

30 noviembre 2013

After the blog entry about “Testing Waveform Generation Functions”, we will see now in more detail how to generate arbitrary shaped waveforms using openDAQ, which we think it is a very useful feature of the device.

First of all, there should be a certain waveform which we want to generate. If that waveform can be described by mathematical equations, we could use a specialized software, e.g. Matlab, to generate a graphical representation of that signal.

In our case, the signal is defined by four different equations, covering a total period of 4 seconds: To generate a plot of this particular signal with Matlab, in order to export it to a text file, we could use the following script:

>>x=linspace(0,4,50)
>>y=(x.^2).*(x<1)+2.*((1<=x)&(x<2))+(x.*sin(x)).*((2<=x)&(x<3))+ (-x+4).*(3<=x)
>>plot(x,y,’r-‘)
>>csvwrite(‘filename.csv’,y) Once this is done, we will get a text archive in Matlab format: comma separated each point in a new line.

To import the data from EasyDAQ, text files must be formatted in a particular way:

• Each point must be in a new line.
• No X points are needed (because they will be calculated automatically from the period).
• Y points must be written in millivolts, with no decimals (no decimal separator).
• File extension must be changed to: .odq

If you follow those rules, it is not difficult to get a file that EasyDAQ can understand.

Then, we can make the appropriate connections in the device, and open the EasyDAQ software to load the file. We enable the ‘Waveform Generator’ utility and click on ‘Configure’.

In the menu that opens up we can modify the total period of the waveform, to fit our needs. In this case, we have talked of a signal with a total period of 4s, and we defined a total of 50 points to represent the shape, so the time between representation points will be 80ms.

We click on ‘Import CSV’ and then select the correct file. We finally click on ‘Submit’ and so the instrument will be ready to begin generating the desired waveform: NOTE: Be sure to get updated to the last versions of firmware and, specially, software, to run the proceedings related in this article.