09-17-2021 07:19 AM
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
And this, with my functions, doesn't work
09-17-2021 08:35 AM
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:
@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!"…
09-17-2021 08:46 AM
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.
09-17-2021 08:49 AM
What did you wrong?
Two main errors:
- attaching just images of part of your code instead of attaching (real) code!
Here you are!
09-17-2021 08:53 AM - edited 09-17-2021 09:09 AM
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!)
09-20-2021 05:21 AM - edited 09-20-2021 05:23 AM
Ok, thank you, now I understand what I have done wrong.
09-22-2021 08:30 AM
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.
Maybe I should make a queue?
12-16-2021 01:18 PM - edited 12-16-2021 01:29 PM
Hi Jean,
@jeandebrem wrote:
What is wrong? It's strange that program is working good and after few minutes is not working for rest of a day.
…Maybe I should make a queue?
There is so much wrong:
See this:
Many, but not all problems are solved: