LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sinusoidal motion to servo

Hello everyone!

I am absolute beginner in LabVIEW and I have to write program, that will generate sinusoidal motion in servo drive. I am using circular motion formula:

 

x(t) = A * cos(w*t)

 

where "A" is Amplitude and "w" is angular velocity w = 2*pi/T

 

"T" and "A" are my variables that I will be changing in my program.

 

My task is quite complex, but firstly I would like to start from the most basic thing. I made cosine function and connected it to VI that is contacting with servo by VISA (this VI is not mine, but is from older project and it suits also to mine). Result of function is my velocity of driver shaft, that is changing concontinuously.

 

When I am giving constant value as a velocity, it works, but when I am connecting my cosine function, from which I wolud like to gather values of velocity, it doesn't work. What am I doing wrong? I am thinking that I should discretize function, because driver cannot process this constantly changing information about velocity, but I don't know how.

This version, with constant velocity, is working

skrin2.jpg

And this, with my functions, doesn't work

skrin1.jpg

0 Kudos
Message 1 of 7
(259 Views)

Hi Piotr,

 


@jeandebrem wrote:

When I am giving constant value as a velocity, it works, but when I am connecting my cosine function, from which I wolud like to gather values of velocity, it doesn't work. What am I doing wrong? I am thinking that I should discretize function, because driver cannot process this constantly changing information about velocity, but I don't know how.


What did you wrong?

Two main errors:

  • attaching just images of part of your code instead of attaching (real) code!
  • don't obeying the basic LabVIEW mantra of "THINK DATAFLOW!"

 


@jeandebrem wrote:

I am absolute beginner in LabVIEW and I have to write program,


So you did notice those "Training resources" as offered at the top of the LabVIEW board?

You carefully took the beginner courses and learned about "THINK DATAFLOW!"?

 


@jeandebrem wrote:

And this, with my functions, doesn't work


What does "doesn't work" mean? Do you get any error messages? Do you kill LabVIEW? Or do you get a BSOD?

 

The shown code will work and does work - exactly as you programmed it! As soon as you press that "stop" button in the while loop the current cosine value will be output to your motor driver: it's all dictated by "THINK DATAFLOW!"…

Best regards,
GerdW


using LV2020 on Win8.1+cRIO
0 Kudos
Message 2 of 7
(228 Views)


What does "doesn't work" mean? Do you get any error messages? Do you kill LabVIEW? Or do you get a BSOD?


I get literally nothing. Motor is not moving. I only get function on graph.

 

 

The shown code will work and does work - exactly as you programmed it! As soon as you press that "stop" button in the while loop the current cosine value will be output to your motor driver: it's all dictated by "THINK DATAFLOW!"…


 The problem is, that when I press stop button, nothing is happening.

 

0 Kudos
Message 3 of 7
(223 Views)


What did you wrong?

Two main errors:

  • attaching just images of part of your code instead of attaching (real) code!

Here you are!

0 Kudos
Message 4 of 7
(219 Views)

Hi jean,

 


@jeandebrem wrote:
I get literally nothing. Motor is not moving. I only get function on graph.

Because that is what you have programmed! You can easily check that using highlight execution debugging!

Inside the loop you only generate a plot for your graph - nothing else: now you wonder why nothing else is happening as long as that loop is iterating???

 


@jeandebrem wrote:
The problem is, that when I press stop button, nothing is happening.

When you press the "stop" button which is located inside the loop then the loop stops and a command is sent to your motor. There has to be some kind of motor driver reaction!

Again you can easily check this behaviour using highlight execution debugging!!!

 

You also should learn to create more cleaned up code:

(It's also annoying to set frontpanel and blockdiagram to fullscreen windows!)

Best regards,
GerdW


using LV2020 on Win8.1+cRIO
0 Kudos
Message 5 of 7
(216 Views)

Ok, thank you, now I understand what I have done wrong.

0 Kudos
Message 6 of 7
(138 Views)

I've made two while loops with local variables (my subVI, which is computing and sending velocity) and later I've put all program (my VI) in loop. Effect was interesting. First time, when I was turning on motor, program was working properly and was sending appropriate movement&velocity to the motor. When I was changing something in code (i.e. amplitude of function) program didn't work. Next day story was the same. First turning on program was good, but later it didn't work at all. Sending data from subVI is blocked, as we can see by highlight execution.

What is wrong? It's strange that program is working good and after few minutes is not working for rest of a day.

SubVI.jpgVI.jpg

 

Maybe I should make a queue?

Download All
0 Kudos
Message 7 of 7
(91 Views)