Sign in to follow this  
Followers 0
Madmax

High speed functions

13 posts in this topic

I'm working on a program with an FX1N PLC that requires some of the high-speed instructions. I would like to determine the rotational velocity of two DC motors, using incremental encoders. The encoders are being read by high-speed inputs X0 and X1. I used the SPD instruction to determine the amount of input-pulses in a certain time limit. Since I'm using two motors on two inputs, I used the SPD command twice. So far, so good; everything worked just fine! Now here is where the problem starts: When the rotational speed of both motors is equal, I would like to know the angle between both motor axis. I planned to do this with incrementing two dataregisters and resetting them when they have reached the value of 500 (because my encoder generates 500 pulses / rotation). After that I want to compare the value of the registers to see how many pulses they are from eachother. Maybe the resetting isn't even necessary, maybe I can let the registers "overflow"? Anyway, I tried to do this with the high speed counter function HSCS using C235 (wich reads X0 according to the manual), but then my SPD instructions failed to work properly. After trying that, I used the normal counter function with C235. That also didn't work out. So I looked for some Interrupt functions in the Mitsubishi manual until I found the FEND and IRET functions, wich seemed to be very usefull. So I put my SPD functions, along with the counter function between the FEND and the IRET line. When I uploaded the program to my P.L.C., it went in alarm. I'm not so familiar with Mitsubishi and its high-speed instructions, but I hoped someone could help me out with this. Thanks in advance! Wouter Verscheure

Share this post


Link to post
Share on other sites
hmmm...., i would like to ask few questions: why would you like to know angle between axes? what is the application and what can you do with this information? can they turn more than one revolution (sound like they do)? why not use quadrature encoders and keep track of position? you can always convert position to speed but not the other way around because of error accumulation. also if you have quadrature encoder you won't get drifts when motor is stopped or idling. then you can tell with precision of one count accuracy position or angle difference. also why do you want to reset encoder after each revolution? lot's of guys do it and i can see this work for cases where you only care about speed and all you have is single channel from encoder (that's what you have) or if it is continuous process running always in same dirrection. but reseting is not very good idea with positioning in mind specially when reset interval is shorter than possible difference. i like to reset position counter only once (if ever..!) and that's only when homing axis on powerup. if you reset it after one revolution, 0 could mean any number of revolutions (1, 2, 3...) and if your motor stops or changes direction, good bye position. ...or maybe i didn't understand the question?

Share this post


Link to post
Share on other sites
Panic Mode, I have two DC-motors in opposite of eachother that I would like to "connect" to eachother. And, yes, they turn more than one revolution, they turn at 2700rpm in only one direction. Each motor has a "coupling-disc" that fits in only one way. If you don't understand what I mean, I've attached a drawing of the coupling discs to this reply. When the rpm of motor 1 equals the rpm of motor 2, then the PLC has to check the angle between the two discs. I would do this by resetting two dataregisters before I start the motors. When the motors start, on each pulse they increment a dataregister. Once the rpm of the motors is equal and one dataregister has for example: value 26200, and the other has value 26380, that means that one motor is 180 pulses or +/-126° ahead of the other, since the encoders generate 500pulses/rev. Now that I think of it, I don't even have to reset the dataregister after 500 pulses, I also can let the registers "overflow", it's only the value difference that I need, even if the values are negative. Do you know how I could possibly do this? I'm affraid that I only have incremental encoders available... Anyway, thanks for your help! *** Update: It didn't work to upload a bmp file? It's only 38kb but it doesn't work.

Share this post


Link to post
Share on other sites
Madmax, you did not specify the most important thing- what is the top frequency from the encoders?

Share this post


Link to post
Share on other sites
You're absolutely right, Sergei. The maximum outputfrequency is 23kHz. The SPD comand works fine at this frequency, two SPD commands work also fine. From what I read, I think I can use up to 6 high-speed functions in one program but I'm not 100% sure of that. The things I want to do are the following: 1) Count the number of pulses on X0 in a certain time-limit, write that number to D0 AND increment D10 each time X0 reads a pulse. 2) Count the number of pulses on X1 in a certain time-limit, write that number to D1 AND increment D11 each time X1 reads a pulse. 3) Compare D10 and D11 and write the result to D12 If the value of D10 = 24513 If the value of D11 = 11326 Then the value of D12 = 13187 Now if I do 13187 MOD 500, it results in that one motor is 187 pulses (= 134°) ahead of the other This is how I would like to measure the axis angles Thanks!

Share this post


Link to post
Share on other sites
I would measure the angle between motors as follows: Supply Motor 1 with a rotary encoder, reset the high-speed counter by the encoder zero pulse. The counter may be quadrature or single-phase. Motor 2 will need only a cam with a sensor (one pulse per revolution). An interrupt assigned to this sensor pulse writes the Motor 1 encoder value to a data register. This value is a directly measured angle between the motors, updated on each revolution of the Motor 2 (assuming that both are rotating with close speeds). You will still have 2 or 3 high-sped inputs unused. They can be used for SPD or anything else. Concerning your statement about FEND and IRET. It must be a valid interrupt pointer prior to IRET, since IRET means return from interrupt. Also, I am not sure that SPD will work correctly in interrupt. Edited by Sergei Troizky

Share this post


Link to post
Share on other sites
Whoa :) You are making a classic mistake with HSC They are 32 bit and therefore use 2 consecutive D registers Use dmov for moving the values from the counter and remember dmov c235 d1 will actually use d1 + d2

Share this post


Link to post
Share on other sites
Sergei, I don't have an index-pulse on my encoders and I only have 2 high-speed inputs in total. The high-speed inputs are already taken by the 2 SPD commands (they are used to determine the rotational speed). If I use a cam and a sensor, then the input frequency will be max. 50Hz. Can a normal input read this or do I need a high-speed input for that? Thx!

Share this post


Link to post
Share on other sites
But you must have total of 6 high-speed inputs on FX1N. Insted of missing encoder zero pulse you can use another cam with sensor. Concerning measurement by a cam on a regular input. Your input reaction time may be up to one full PLC scan. Assuming 10ms scantime and 20kHz from encoder, your measurement error will be about 200 encoder units and random (not repeatable).

Share this post


Link to post
Share on other sites
Sergei, The PLC I use is FX1N-24MR: 14 inputs, 10 outputs. Only 2 of the inputs are high-speed and that's the problem. I use the 2 high-speed inputs to read my encoders with the SPD function. I also want to measure the angle of the motors but I don't have any high-speed inputs left. If I use a cam and a sensor on each motor, I will have an input-frequency of 50Hz. Will a regular input read 50Hz?

Share this post


Link to post
Share on other sites
Madmax, Get and read the manual. It is available online. FX1N has 6 high-speed inputs. They may be assigned to any of the following: - high speed counter, - interrupt, - SPD instruction. Yes, regular input will read 50Hz but will not measure precisely. Edited by Sergei Troizky

Share this post


Link to post
Share on other sites
I've connected 2 inductive sensors to my PLC and it works to read one pulse / rev, but do youknow how I should assign an interrupt to an input? I don't understand that part in the manual, they don't really go in detail. Thanks!

Share this post


Link to post
Share on other sites
All subroutines and interrupts must be written, in any order, between the FEND and END instructions. An interrupt starts with an interrupt header. It may look as I000, or I301, etc. The first digit (0 to 5) identifies the physical input to which this interrupt is assigned. The last digit defines the signal edge to activate the interrupt. 1 means the front edge, 0- the rear one. The middle digit is always zero. An interupt must end with the IRET instruction. Edited by Sergei Troizky

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