Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial generation in multiple channels

Solved!
Go to solution

@Kyle_A. wrote:

Hi Yan,

 

1) Sounds about right, I'm not used to seeing a sine wave generated serially with a single boolean toggle, but if that is what your application calls for, you seem to have it down.

2) Yes.

3) What I mean is a waveform with 7 samples throws an error, stating that it needs to be a multiple of 2.  So then you would have to increase the waveform size to 8 samples, or 10, 12, etc.  Not sure why you had to use 500k samples.

4) I searched that error code and tried to find an explaination for it, but it seems the code you posted is not a valid code. I can only guess that considering it says something about your script that you are either trying to generate 0 samples or there is an invalid function being used. It's hard to say.

5) Not sure what you mean.

6) Step 7 writes N blocks of memory to memory before initiating the generation.  Then during the generation, when the amount of available space is greater than a single block, it will load another block into memory to keep up with the generation.

7) Yes.


Hi Kyle,

Yes, I need to generate sinewave through one singe channel in serial form. Thats why I need to know, how many sinewave cycles can I load into device memory, before generate them in output channel.

What I meant with number 5 was; 30secs generation of 1kHz sinewave means 30k cycles generation, equals 30kx40k booleans elements. How can I effectively generate this 30secs sinewave.

 

 

 

regards,

Yan.

0 Kudos
Message 11 of 20
(3,331 Views)

Hey Yan,

 

Thanks for clarifying that. Technically, if you are not changing the sine wave, you can load just a single cycle and repeat that waveform forever, thus only using a small amount of memory.  There is functionality in the API to load the waveform into memory, name the waveform, and use scripting to perform the repeat.  Or there is also a continuous mode that can be used to generate the waveform.

 

Going along the same path as your clarified #5 question, effectively you just need one cycle and not the full waveform loaded for the full time you want to generate.  Try using some of the looping features, either scripting or continuous generation, and see how that works out for you.  There should be a few examples in Example Finder to help you see what I mean, namely Dynamic Generation with Repeat Mode or Dynamic Generation Software Script Trigger (or any Script examples, based on what you need).

Kyle A.
National Instruments
Senior Applications Engineer
0 Kudos
Message 12 of 20
(3,322 Views)

Hi Kyle,

 

I'm asking this because my supervisor told me about FFT of the generated sinewave. He said, if we use only one cycle of sinewave to repeat forever, we would get too many noises in low frquency range in FFT analysis. We can avoid this by generating more cycles instead of one cycle as a "template" to repeat forever. Thats why I keep asking and trying to know the "maximal capacity" of the buffer load. I've tested, that 6544 device can generate either 4bytes or 2bytes but not supported with 1byte, and this buffer sizes from my test was:

524288 for 4bytes or

1048576 for 2bytes.

 

I was asking about which method is better, because I need to generate either sinewave or ramp with 6544 in serial way. And I found, to generate a ramp in serial form, using script method is easier to control the time of each step of ramp.

 

A little bit out of topic, I tried today to generate my digital serial sinewave with 6544 and feed the digital data into a DAC, and trying to acquire the analog signal output of DAC with pxi 5105 mounted in the same pxi backplane. I got error saying about "property of hsdio cant keep up... bla bla bla... ". I forgot the exact error code number, but it says, I should reduce the generation rate, bla bla bla... If you might have a tip about how should I build my app, it would be very great. In attachment I have the VIs included. (*nvm, somehow cant upload file)

 

regards,

Yan.

 

0 Kudos
Message 13 of 20
(3,317 Views)

Hi Yan,

 

If your cycle-to-cycle data changes, that makes sense.  From your numbers, it looks like you have the 8 MB per channel memory option, so yes the 2 bytes data width will give you maximum amount of data for completely onboard data generation.  If you are generating less than 400 MB/s, you can also stream data to your memory which would make a theoretical limitless waveform size (depending on your hard drive).

 

I would visit ni.com/streaming and see if the HSDIO streaming examples help you with the data not keeping up problem.  At least I assume data cannot keep up with the generation and you are streaming.  Beside that, I don't have any other recommendations without an error code.

Kyle A.
National Instruments
Senior Applications Engineer
0 Kudos
Message 14 of 20
(3,311 Views)

Hi Kyle, thank you very much for all your suggestions to my problem. Now I understand a little bit more about my device PXIe-6544, and what does 8MB/channel means.

 

I couldnt find an example in ni.com/streaming about continuous digital generation-analog acquisition.

 

Without the analog acquisition part, can you perhaps teach me how should I generate two clocks 10MHz with 1/2 phase difference and one serial digital signal? I have 6544 and time module 6674T. Clock rate should be 40MHz.

 

I noticed, with this 1048576 samples I could build a "template" to repeat forever which has 40000 samples. Each sample is a packet of 20bit boolean. Which means, I have 800k samples on my "template". Is that true?

 

regards,

Yan.    

 

0 Kudos
Message 15 of 20
(3,295 Views)

Hi Yan,

 

Glad I can help! 8MB/channel is your memory option on the board, which means that you have 8 megabytes of memory storage per channel on your device, for both acquisition and generation on the digital side.  You might have 64 MB per channel as well, but I was just going off of your 1M Samples at 2 bytes, which is 2 MB of data.

 

The ni.com/streaming would get you to stream on the digital side, you can add the analog to the code if need be.  What device is doing analog acquisition? You could copy/paste an analog example into the digital streaming code if you wanted, or if you don't need digital streaming anymore you can combine a simple digital example with an analog example.

 

Generating the clocks will be based on one sample rate.  For instance, if you want 1/2 phase difference, at 40 MHz, your patter look like this:

 

00

10

11

01

00

10

etc.

 

Transposing it:

011001

001100

 

So you see how the high side generated values are 1/2 phase out of alignment, and there are 4 samples per period (40 MHz/4 = 10 MHz clocks).

 

The serial signal is actually the trickier, harder signal to create. You can't have more than one generation session, so you would have to generate both the constant clocks and the serial signal at the same time.  

 

I think the best idea you can use is to put together two waveforms, wfmA and wfmB, one that has the clock without serial signal, and one that has the clocks with serial signal, and use scripting to switch between the two.  So wfmA would have the 00X 01X 11X 10X data, where X is the don't care state of the sine wave (I assume X can equal 0 in this waveform) ending on a 00.  WfmB would have 01S 11S 10S 00S, where S is the serial sine wave signal, and ending on a 10S (since the start of wfmA is 00X).

 

In this way, you can script trigger switch to the other waveform and back based on your scripting method.  It will finish out the current waveform before generating the next waveform, so there will be some latency, but it will give you the results you need.  You'll need to account for how much space you have in your memory to load the sine wave/clocks data.  The downside is you won't have asynchronous control over which phase of the 10 MHz clocks are on when the sine wave starts.  That will always be preset by the data.  This is just one idea, something to think about.

 

For your last question, yes that is true.

Kyle A.
National Instruments
Senior Applications Engineer
0 Kudos
Message 16 of 20
(3,289 Views)

Hi Kyle,

 

regarding to your post, if I want to generate 1Hz sinewave with 1MHz sampling-rate at 40MHz clockrate, I would need to have 1million samples (or 40 millions booleans) for one single cycle, right? I believe the on board memory of HSDIO dont have that much space. Hmm, which means, I should split my generation, correct?

 

What about using static generation to generate the 2 clocks (with different phase), is it possible? I saw the examples, but mostly static generation doesnt care about time, thus I think it would be hard to tell if static and dynamic generation are well synchronized.

 

regards,

Yan.

0 Kudos
Message 17 of 20
(3,279 Views)

Hi Yan,

 

Correct.

 

Static generation is using software timing instead of hardware timing.  The maximum rate you can achieve is variable but around 1kHz (500 Hz toggle).  It is very slow and non-deterministic in Windows environments.

Kyle A.
National Instruments
Senior Applications Engineer
0 Kudos
Message 18 of 20
(3,274 Views)

hey Kyle,

 

if I want to generate dynamic and static signal and acquire dynamic signal at the same time from the same device, where do I find a good example for it? Here is a simple example to generate static and dynamic, but I need to be able to turn ON/OFF static and dynamic independent from each other. 

Which program structure should I use for that? (maybe event structure, state machine or producer consumer??)

 

Since my pxie 6544 doesnt support 1byte data, means I need at least 2byte (16channels) for dynamic and perhaps 16 other channels are free and I can use for static signal.

Can I use like 4 channels from the 16 generation channels for generation, and 4 of them for acquisition. I've read in the manuals, the channels can read and write simultaneously on the same channels.

 

regards

Yan

0 Kudos
Message 19 of 20
(3,235 Views)

I tried to split the static generation and dynamic generation in two different event loops. It doesnt work.

 

0 Kudos
Message 20 of 20
(3,068 Views)