From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Need Help in converting the Matlab Code into G Code

I have written my MATLAB Code for my simulation in which I am calculating the Velocity for the Motor. I have LabVIEW code for motor in which it takes motor speed as an input. I need help in writing the G code for the profile which I have already done in MATLAB.

Message 1 of 8
(484 Views)
Solution
Accepted by topic author rishab_kr

## Re: Need Help in converting the Matlab Code into G Code

Hi rishab,

I already showed you the conversion to G code for the first lines of your m code.

Could you please cleanup your (m) code and remove all parts dedicated to plotting graphs? I guess this is not needed for "Velocity" calculation…

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 8
(480 Views)
Solution
Accepted by topic author rishab_kr

## Re: Need Help in converting the Matlab Code into G Code

Yes, I understand you let me understand how to write the first part. But my concern is how I will make sure writing the matrix part and differentiation part in the g code, I don' t understand how to increament the time values in the g code.

Also, My major conern before dewlling into the g code programming is do we have some other way to integrate or use the matlab code result directly in the Labview. Because for building further logic I need to use Matlab and again writing it into labview will consume time ?

Message 3 of 8
(466 Views)

## Re: Need Help in converting the Matlab Code into G Code

@rishab_kr wrote:

Yes, I understand you let me understand how to write the first part. But my concern is how I will make sure writing the matrix part and differentiation part in the g code, I don' t understand how to increament the time values in the g code.

Also, My major conern before dewlling into the g code programming is do we have some other way to integrate or use the matlab code result directly in the Labview. Because for building further logic I need to use Matlab and again writing it into labview will consume time ?

If it works in MATLAB, then why port it to LV? if you want to use LV in the end, why develop in MATLAB?

Yes, there are ways to use MATLAB code in LV. https://www.ni.com/docs/en-US/bundle/labview/page/calling-the-matlab-software-from-labview.html

Santhosh
Soliton Technologies

Finding it hard to source NI hardware? Try NI Trading Post
Message 4 of 8
(452 Views)

## Re: Need Help in converting the Matlab Code into G Code

Hi rishab,

@rishab_kr wrote:

Also, My major conern before dewlling into the g code programming is do we have some other way to integrate or use the matlab code result directly in the Labview. Because for building further logic I need to use Matlab and again writing it into labview will consume time ?

Why don't you stick with Matlab?

Why do you need to use LabVIEW anyway?

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 8
(362 Views)

## Re: Need Help in converting the Matlab Code into G Code

So basically I need to operate the Hardware using NI SbRio 9627 for my developed simulation in Matlab.

Message 6 of 8
(335 Views)
Solution
Accepted by topic author rishab_kr

## Re: Need Help in converting the Matlab Code into G Code

Hi rishab,

@rishab_kr wrote:

So basically I need to operate the Hardware using NI SbRio 9627 for my developed simulation in Matlab.

Do you want to use the sbRIO only as "semi-smart DAQ device" or do you want to use it as (it's main purpose) "embedded controller"?

When you need the "embedded controller" then I would implement the control algorithm in LabVIEW (with Realtime behaviour in mind!) for the sbRIO. And I would even try to utilize the FPGA inside the sbRIO...

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 8
(327 Views)

## Re: Need Help in converting the Matlab Code into G Code

Yes, So basically I have developed my hardware and I have to write the labview code by using the Realtime behaviour in mind as well as utilizing the FPGA board on the NI SbRIO 9627.

Also, Can you check once the flow of my G coding (please suggest if there is any improvement) ? there are text based codes I have written for your reference.

2. Basically I am not from electronic background so can you give brief / share any reference link to follow up regarding Real time and FPGA.

Message 8 of 8
(311 Views)