Sign in to follow this  
Followers 0
reanimator01

I dont know how to express a value (a position on direct mode on a Drive)

7 posts in this topic

Hi!

 

Im an electrical engineer, and nowadays Im working as a programing engineer, Its been almost two years since I started, I got a doubt, I dont know even  how to express it or ask for it, but well here we go, 

Usually we use function blocks on codesys to make things easier when programming a servo, a sensor, etc, But sometimes I have to do the things witout that, not al the devices has that kind of help.

I´ll give you an example, And I hope you could tell me what is the topic, what do I have to study and learn, I really want to improve, 

 

Here is the example:

In Recrod mode on these servo, With the drive enabled, I ussualy activate a bit and these bit First Indicates the drive the record you want to activate, 10ms later, I activate the Start.task bit, later the drive activates an output, (Acknoleged start) and these output deactivates my start task bit. and the motor, activates its movement.

 In direct  mode on these servo, With the drive enabled,First you activate a bit on OPM(operating mode) and these bit means you'll work on direct mode, Iater  activate a bit and these bit and a MOVE function to  first give the drive the POSITION, and the VELOCITY  and 10ms later, I activate the Start.task bit, later the drive activates an output, (Acknoleged start) and these output deactivates my start task bit. on DIRECT MODE and the motor moves. With the function block help, I only have to Use a variable  Dint on the position, and a usint for the velocity.

 

But when I have to to these task witout the block I dotn know how to make it, cause on the mapping on plc you have to fill the bytes 5 trhought 8 to give a poisition, on the byte number 5  i give 1 throght 255 value,(activating its 8 bits)  and there  is no problem, the motor moves the axis throuhg 1 milimiter to 255 milimiters, (2.55 centimiters) but when I activates the following byte, It does not move as I expect.... I dont know how to mke it,  I attach  a picture for helping to undestand my cuestion...

ONe time a friend of mine help mw whith taht, HE used a SHR function and a INT-USINT transformation, I know he used it but I dont Know why........

Sin título1.jpg

Share this post


Link to post
Share on other sites

what does the datasheet tell about the format? clearly you have 4-byte value (32-bit value) but what is the exact format , signed or not, REAL or INT,  what is the byte order? 

 

 

 

Share this post


Link to post
Share on other sites

Hi!

In the manual  you can find the same information as the last picturem you can use de last 4 or 2 bytes for that position, I'll show you the mapping and the part of the program as he (my  coworker) solve it. As I said  In the mapping you would see the 2 bytes assinged in the plc to solve the posiiton, And in the program, I use  an integer (that I thing that was split ) in two bytes called "i position byLow" and i position by high and in that way  we could get the position on the servo.

Program.jpg

Bytes.jpg

Edited by reanimator01

Share this post


Link to post
Share on other sites

if he really solved it , result would be 4 bytes. he only got two. but if that works, he showed you the way and you need to finish it....

Byte4 = Position AND 0x000000FF

Byte5 = (Position AND 0x0000FF00) SHR 8

Byte6 = (Position AND 0x00FF0000) SHR 16

Byte7= (Position AND 0xFF000000) SHR 24

Share this post


Link to post
Share on other sites

He's using hexadecimal. The '0x' prefix also indicates this.

Share this post


Link to post
Share on other sites

you cannot tell computers to do something for you if:
a) you don't speak their language or
b) they don't speak your language
 

first option is used by programmers, second by users.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0