Jump to content

cRIO Sine wave


Recommended Posts

See the attached screen shot. This crashes compilation.

 

"some of the compilation steps were not executed. refer to the Xilinx logâ€

The xilinx log is what looks like hundreds of pages. I see many warnings, but nothing that looks like a critical failure.

 

If I replace the sine wave with the square wave function, the code will run fine. 

 

I am running a cRIO-9067, with an NI-9269 module.

 

 

All I am looking for is a simple output sine wave VI. Freq and amp variable going in, and a waveform out of the RIO. 

Any help would be greatly appreciated. 

I have been using NI's examples (http://www.ni.com/white-paper/3780/en/#Example, fig2) linking to my hardware.

 

I suppose I'm looking for a few answers here:

1. Why does this fail compilation? 

2. Does anyone have a VI that will just simply output a sine wave?

 

Thanks again,

Chris

post-52576-0-85940900-1434036034.png

Link to comment

The sine wave does use some different resources for the square wave (the cordic units on the FPGAs) but these should be available on all targets.

 

I would check that it is set to run outside a single cycle timed loop if that option is available in case this is impacting something.

Link to comment

Mark,

I am not using hybrid mode, so based on that link I didn't expect this to help.

I am running 2014 SP1 and rio 14.5, so I downloaded and installed rio14.6.

 

I rebuilt the above VI and it just compiled with no issues. That is awesome, thank you.

 

Unfortunately, the sine function is outputting a square wave (or a wave that looks more like a cap charge/discharge). My assumption right now is that this may be a casting issue with fixedpoint numbers. I'm digging into it.
 

Link to comment

Hi,

 

Unfortunately, the sine function is outputting a square wave (or a wave that looks more like a cap charge/discharge).

 

  1. What frequency is your output sine wave?
  2. Do you get better results if you use lower frequencies?
  3. How are you measuring the output?
     

     

    My assumption right now is that this may be a casting issue with fixedpoint numbers. I'm digging into it.

     

  4. Do you get better results if you use RT code and the Scan Engine (instead of the FPGA) to output the waveform? (RT code can handle floating point numbers, so you're not restricted by fixed point)
Link to comment

1.       I have been trying frequencies all over the range. Ultimately I will need between 45hz, and 7.07kHz.

2.       No. I still get a sq wave.

3.       Fluke 175 RMS handheld meter, and a Tektronix TPS 2024B 200Mhz Oscope

4.       Scan mode is not apples to apples. In FPGA target I use the Sine Generator express VI, from the FPGA  pallet. That Vi is not an option from scan mode. As it stands right now, that VI is the problem. I can create a sine wave using the High throughput sine VI, in FPGA target mode. But it would be much easier to implement if the FPGA sine wave generator Express Vi would work. 

 

 

As a question on the side. Does anyone know the calculation for output frequency to phase increment (input my desired freq, get out the value that goes into the sine gen VI).  

In the sine generator example from LV, there is a PhaseIncrement.Vi. It has the equation as (Freq/FPGAClockRate)*(2**32).

Using this equation I can not get anywhere near a frequency I would expect. Should I not be using 40M for the FPGAClockRate?

Link to comment

1.       I have been trying frequencies all over the range. Ultimately I will need between 45hz, and 7.07kHz.

2.       No. I still get a sq wave.

3.       Fluke 175 RMS handheld meter, and a Tektronix TPS 2024B 200Mhz Oscope

4.       Scan mode is not apples to apples. In FPGA target I use the Sine Generator express VI, from the FPGA  pallet. That Vi is not an option from scan mode. As it stands right now, that VI is the problem. I can create a sine wave using the High throughput sine VI, in FPGA target mode. But it would be much easier to implement if the FPGA sine wave generator Express Vi would work.

  1. Ok, those are pretty low frequencies. There should be no problems there.
  2. Strange...
  3. Ok, the Tektronix is a good quality scope. There should be no problems there.
  4. You're right, but it's much easier to get things working in Scan Mode. I suggested it as a preliminary test, to ensure that your hardware is working properly. (If you can't get it to work using RT code, then you won't get it to work using FPGA code)

 

 

As a question on the side. Does anyone know the calculation for output frequency to phase increment (input my desired freq, get out the value that goes into the sine gen VI).  

In the sine generator example from LV, there is a PhaseIncrement.Vi. It has the equation as (Freq/FPGAClockRate)*(2**32).

Using this equation I can not get anywhere near a frequency I would expect. Should I not be using 40M for the FPGAClockRate?

 

I haven't used these VIs myself, but the VI in your diagram looks different from the one in the NI example. Yours is http://zone.ni.com/reference/en-XX/help/371599K-01/lvfpga/sine_generator/ which doesn't seem to have a phase increment terminal.

 

Anyway, the formula at the NI example does not give you a frequency. It is a percentage, scaled to fit an unsigned 32-bit integer. (232 = 100%, 0 = 0 %)

Edited by JKSH
Link to comment

Inside the express Vi properties for the sine, there is a check-box for additional inputs. The one input I'm using is Phase increment. An optional input is phase offset, I don't have that active since I don't need to phase shift.

what I expect the equation to do, is take my desired freq and calculate the necessary phase increment per clock tick for that freq.

Where does the 2^32 come from? Is this function forced to a 32bit integer?

 

I'm still wondering about the 40Mhz; is that the right clock freq to use? If my math is correct, dividing my frequency by 1.25Mhz for the clock should give me a phase increment very close to what I expect. I don't know why.

Is it that the FPGA clock is 40MHz, but a derived frequency is actually used for these calculations?

 

 

Again, thank you everyone for your continuous help.

Link to comment
 

 

Inside the express Vi properties for the sine, there is a check-box for additional inputs. The one input I'm using is Phase increment. An optional input is phase offset, I don't have that active since I don't need to phase shift.

 

OK, the terminal was renamed from "Phase increment" to "Frequency (periods/tick)" LabVIEW 2014. I didn't realize this before, but they mean the same thing.

 

 

Where does the 2^32 come from? Is this function forced to a 32bit integer?

 

Look at Fig 2 in the example again carefully: The example VI takes an unsigned 32-bit integer in the "Phase increment" input. This datatype cannot represent fractions, so you multiply by 232 to scale your input for maximum resolution.
 
However, your version (LabVIEW 2014) uses a fixed-point number, instead of an integer. This datatype can represent fractions, so you no longer need to multiply by 232
 
As I said before, your VI is not the same as what's shown in the example.

 

 

what I expect the equation to do, is take my desired freq and calculate the necessary phase increment per clock tick for that freq.

...

 

I'm still wondering about the 40Mhz; is that the right clock freq to use? If my math is correct, dividing my frequency by 1.25Mhz for the clock should give me a phase increment very close to what I expect. I don't know why.

Is it that the FPGA clock is 40MHz, but a derived frequency is actually used for these calculations?

 

The sine wave generator uses the top-level clock by default, which is 40 MHz. If you want, you can use a a derived clock by unchecking "Use top-level clock" and entering a custom clock frequency.

 

The "Frequency"/"Phase increment" input is the ratio of your sine wave frequency to the clock frequency used by this VI.

 

You don't divide by 1.25 MHz. Your top-level FPGA clock is 40 MHz, so:

  • If you want a 400 kHz sine wave, Phase Increment = 400k/40M = 0.01 periods/tick
  • If you want a 4 MHz sine wave, Phase Increment = 4M/40M = 0.1 periods/tick
  • If you want a 40 MHz sine wave, Phase Increment = 40M/40M = 1 period/tick (this is not possible though)

 

Edited by JKSH
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By jdeantx
      With exciting projects in oil and gas, aerospace, utilities, and other industries, Vertical AIT is looking to hire skilled LabVIEW developers and architects in the Houston area. We are an Alliance Partner, and we specialize in embedded development.
      Requirements:
      - US citizenship (required by our contracts)
      - Industry experience in production software development
      - Embedded cRIO development experience (Real-time and FPGA)
      - Certification (CLD, CLA, and/or CLED) preferred
      - Must be meticulous and detail-oriented
      We offer great benefits, and we prioritize a healthy work/life balance.
      Learn more about Vertical AIT at www.VerticalAIT.com, and please send resumes to jobs@verticalait.com.
    • By IpsoFacto
      I've got some weird stuff going on with a cRIO project I'm working on wanted to get some opinions on it. The basic architecture is a set of classes that do some process. That process registers with a server. The internal data of the process is held in a DVR and the server get's access to that DVR. Clients use TCP to ask the server to do something, the server makes a call against the classes DVR and returns a response to the client.
      To simplify the issues I'm seeing I created a class that internally just increments an integer every 500ms. The client asks the server what's the current count, the server asks the Counter class and returns the answer to the client. This works perfectly fine when running the VI in the IDE. When built it connects, will get the JSON message back, but always gets a default value from the DVR call (zero, in this case). As soon as I open a remote debug panel to the cRIO, everything is working. The count is correct, the client calls work, just like normal. As soon as I right-click, close debug, it goes back to zero. Open debug works, close debug, back to zero. I know the DVR isn't getting dropped because the count continues to increment while not in debug, the process is still running happily with no issues.
      Here's a few screenshots of the code;
      Count Class process (get the count, increment, write it back to the DVR) - Counter Class process
      You can see the DVR vi's are actually vim's using a cast. I can't imagine that's the issue.
      Server Side call - Server Side calls
      All this does is get the count from the DVR (same as above) and wraps it in JSON and passes it back to the client as a JSON string.
      I also implemented an Echo class that ignores the process and DVR's, it just takes whatever string you sent form the client to the server and passes it back with a prepended "@echo". This works when running as an executable with the debug turned off so I know the client, server, and the server/class calls are all working as expected.
      Any thoughts here would be welcome, thanks.
      edit: I added the any possible errors coming from the variant cast to the JSON reply. When the debug is open there are no errors, when the debugger is closed it throws error 91, but the in-place element structure reading the DVR does not throw any errors. How can a variant not exist until a debugger is opened and than it magically exists?
      edit: the internal data dictionary is a wrapper around a variant attribute, I wired out the "found?" terminal all the way out to the JSON reply and if the debugger is open the attribute is found, but not if the debugger is closed. Anyone have issues with Variant Attributes in Real-Time?
    • By sup93
      Hi. 
      I would like to have the digital trigger high for user input time in seconds.
      Any help is much appreciated. 
      Data Acquisition Final.zip
    • By Nala
      Hello everybody,

      I'm about to write an application that can create a complete new FPGA-Project for the cRIO-system automatically without any user Input.

      Before I ask my question directly, I will give you a few Information about the system and how it works at the moment.
      I'm working with a cRIO-system that can have different modules in different slots (max 8). That system should be universally usable which means I can replace one module with another one at the start up and create a complete new project with a different name.

      Most of the project works (I can find out in which slots which module is placed and load the right VI's correctly) but there is one point which I really dislike: the user always has to give some input Information at the beginning of the creation and mostly that is the same like "Which type of project it should be" or "Which IP address should be used to find the system and the modules for each slot".

      The goal is that I can write down some specific arguments so the program is created automatically?
      Or - if there is no way to do this - a way that a second window is shown on screen to help the user through the creation process (for example that tells the user that the system need to be turned on that the project can find every single module)?

      English isn't my mother tongue, so please apologize if there are any mistakes in my spelling.
      Thank you very much for your help
    • By Nala
      Hello everyone,
      I’m not sure which forum is the right one which is why I created two new topics with the same content (one in Embedded and one in VI Scripting) – so sorry for the spamming.
       
      I have two questions:
      How can I generate a cRIO project programmatically?
      How can I start the “Discovering Devices” tool of the Project Wizard automatically?
       
      At first I will describe a bit more what I really want to do:
      I’m about to write an auto coder which should create a complete new FPGA project on my cRIO system without any user input. In the Project Wizard I want to run the “System Setup” from NI standalone. In that mask the NI project need some input like project type which is always a cRIO Embedded System. The next step is to insert an IP address to discover an existing system.
      As those two steps are every time with the same input, I want to give them those parameters so that everything runs automatically.
       
      Is there anybody who can help?
       
      Thanks a lot!!
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.