reanimator01 Posted February 4, 2019 Report Posted February 4, 2019 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........
panic mode Posted February 5, 2019 Report Posted February 5, 2019 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?
reanimator01 Posted February 6, 2019 Author Report Posted February 6, 2019 (edited) 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. Edited February 6, 2019 by reanimator01
panic mode Posted February 6, 2019 Report Posted February 6, 2019 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
reanimator01 Posted February 11, 2019 Author Report Posted February 11, 2019 hi again! what did you mean by FF???
b_carlton Posted February 12, 2019 Report Posted February 12, 2019 He's using hexadecimal. The '0x' prefix also indicates this.
panic mode Posted February 12, 2019 Report Posted February 12, 2019 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now