Sign in to follow this  
Followers 0
niko9833

Programming math question

6 posts in this topic

Hello. Firstly, I am new to your forum, it is very well. My question. I have a problem with a mathematical equation that I have to repeat several times: X * Y = Z or X is a constant in memory and Y is a variable that uses numbers with comma. I have a CNT0001 that increments from 0 to 120, and for each PV there is a match with value (between 0.366 and 2.750) which corresponds to the Y. Ex: cnt = 1 matches in the equation with X * 0. 366 = Z Cnt = 2 matches in the equation with X * 0. 413 = Z... Whenever I use the calculation in the program, I check CNT0001 value for the match of the variable Y. I think work with IRS may be a good way to do but I've never used this feature and I am missing some information . Here's what I did: I thought to create a table for my variables Y with DIM (1; &2; &120; @ d100). I use MOVR (D100; IR0) Until that seems to work, but it is then that I blocks: how I change record in the table (for example when CNT = 2 or 51...) and how do I use the variable Y is found in IR0? I try * F (, IR0 H40; H42) and I get a response in H42 that seems good, is it the right way to do? Thank you for the information a+

Share this post


Link to post
Share on other sites
Bonjour niko, From what i understand of your question, (not sure i understand well, i dont have perfect english too) i have a suggestion: I suggest that, instead of working with a CNT, you increment a "D" word. Then use that register as pointer to others "D" where are stored your values. You then acces to them with indirect adressing.

Share this post


Link to post
Share on other sites
niko I think that you are on the correct path. One way to use your counter is by using DRx, IRx. Example: DR0,IR0 as an address. *F DR0,IR0 H40 H42. DR0 is an offset from IR0. If IR0 points to D100, and DR0 = 9, then DR0,IR0 would point to D109. Note: You do not need to use the DR and IR as numerical pairs. DR5,IR0 is OK. DR15, IR14 is OK. I normally use DRx, IRx but DRy,IRx is also OK.

Share this post


Link to post
Share on other sites
Thank you for quickly responded. The cnt are necessary because they giving me my variable reference. They represent days and the corresponding variable is an additive... I tried the way PMCR gave me and it works very well. Missing me just the use of DR Another question: my # 1 table records are double (32-bit) for the number with comma. When my cnt increases by 1, the offset will be 1: IR0 = D101, but I need D102. Is there a way to do? thank's

Share this post


Link to post
Share on other sites
niko Sorry about that. I should have caught that. Simply multiply the BCD counter value by 2 and then convert this into HEX and use in the DR.

Share this post


Link to post
Share on other sites
I should have caught that to thanks again

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