Sign in to follow this  
Followers 0
Winall

Absolute encoder to CPM2A & trigo functions

12 posts in this topic

Hi I need to connect a E6CP-AG5C absolute encoder (gray code) to a CPM2A to get the rotation angle of a crane arm and then compute the displacement distance of the arm using trigonometric function (sine, cosine) on the angle. I plan to use a lookup table to convert from gray code to actual angle, then use another table to compute the displacement distance (because CPM2A does not support sin, cos functions). Any better idea will be appreciated. Thanks.

Share this post


Link to post
Share on other sites
Instead of using tables you could use the following formula to calculate approximately sine of an angle: sin(x) = (x) - (x^3)/3! + (x^5)/5! - ... where x is in radians Adding more members to the equation will decrease the error. The error increases with the increase of the angle. As well the following formula could come in handy if you want to calculate cosine: sin(PI/2+x) = cos(x)

Share this post


Link to post
Share on other sites
yep, that's taylor series. there are many ways to emulate or approximate sin/cos or any other function (see CORDIC too or just use google). conversion to and from gray code is also straight forward (http://www.encoder.com/techbulletins/TB-120.pdf) although many plcs will have function to do it.

Share this post


Link to post
Share on other sites
Hi Using the series approximation is easy with PC code, but PLC code can be troublesome due to the lack of loop functions in CPM2A. Do you have ladder code for this computation? Thanks.

Share this post


Link to post
Share on other sites
Pity u can;t use a small CPM1H or CPM1,....OR could you ???

Share this post


Link to post
Share on other sites
Hi Sleepy CPM1 is not more advanced than CPM2A, and CP1H is more costly. It's pity all of us as we cant afford to use CS1D or so for all projects due to finantial constraints.

Share this post


Link to post
Share on other sites
A further possibility is to use a precalculated lookup table, and do linear (or better, but that will be hard to program) interpolation in between (ie a straight line between two table points). I have used a custom lookup table, with 16 vertically (ie, by the function value and not the parameter) sized intervals, and linear interpolation to approximate a square root function, which worked pretty well in my application. For such a solution, APR is teh instruction to use. Unfortunately, neither the CPM2C I had nor the CPM2A you have has that instruction... In the trig case, taylor approximation probably is easier. Just find out your needed accuracy before, and calculate how many terms you need to use at the worst side (the sine and cosine approximations are always worst far from origo). Then just hardcode that number of multiplications in the PLC code...

Share this post


Link to post
Share on other sites
Sorry, Fat fingers sleepy.... Meanr CP1H and CJ1 PLC.... Frankly I would use a CJ on 98% of Omron jobs if possible. The pricing of the CP1H is a sore point with me as well, look at AB's latest offerings with built in Ethernet port for less then $1000 AUS. Come on OMRON sharpen your pencils.....

Share this post


Link to post
Share on other sites
Problems with engineering works are that work must be completed with limited resource and on budget. When I take on this project, I have thought of the possible solutions, so in any case, I dont have to resort to higher end PLCs to keep the project from over-budget

Share this post


Link to post
Share on other sites
The CJ1M is really cheap and not much more than the CPM2A - if it is more expensive. I do not price jobs on the cheap if it will make life difficult - would rather lose the job. My time is far more valuable than a lousy bit of hardware.

Share this post


Link to post
Share on other sites
Yeah, time is valuable. But considering that cheapest Cj1M price is 30% higher than CPM2A for this function, and I took only 30 mins to code the Cosine function purely in ladder, then it's worth the job. The gain here is not money, but the something more than that. There's always a tradeoff to gain smt.

Share this post


Link to post
Share on other sites
I have similar reasons for choosing the CPM2C, although it gave me headaches when programming the square root approximation calculation: 1) It was the "biggest" PLC type available (special type 3G3RV-P10ST8, mounts in an F7 inverter). The only alternative would be using an external PLC (a lot more space-consuming in addition to being more expensive). 2) The finished control cabinet will be a standardized part - we'll be using (hopefully) hundreds of them, with identical programs. So, even though I had to think the ladder program through for a couple of extra hours, in the long run, it will probably be a totally acceptable solution, and will save my company money. Edited by TERdON

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