You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old January 21st, 2020, 01:21 PM   #1
lesmar96
Lifetime Supporting Member
United States

lesmar96 is offline
 
Join Date: May 2017
Location: PA
Posts: 403
Codesys variable incrementer

SoMachine v.4.3.

I have an interesting question, hoping someone here as some advice.

My customer has a Lexium 32 servo drive. We are reading the absolute position of the motor encoder into a variable in codesys, using the MC_ReadActualPosition_LXM function block.

All that aside, the customer is asking for another variable that works independently from the current_absolute_position. For example, he wants to be able to zero this 2nd variable at any given place and get a readout position readout +/- of the place he zeroed it. This variable is okay to zero when we HOME, but we must be able to zero it whenever we want without homing the servo.

I was thinking of implementing some logic that would increment/decrement the 2nd value when the current_absolute_position goes up or down, but I wasn't sure that was the best way.

Any thoughts on the best way to do this?
__________________
Whatever you are, be a good one.
  Reply With Quote
Old January 21st, 2020, 01:49 PM   #2
bjh
Member
United States

bjh is offline
 
Join Date: Jul 2010
Location: Madison, WI
Posts: 254
I would do it this way:


current_absolute_position = the real position reported from MC_ReadActualPosition_LXM.


relative_zero_position = whatever current_absolute_position was when the "zero button" is hit


relative_absolute_position = current_absolute_position - relative_zero_position


In ST:
Quote:

IF zeroButtonOneShot.Q THEN
relative_zero_position := current_absolute_position;
END_IF

relative_absolute_position := current_absolute_position - relative_zero_position;

Last edited by bjh; January 21st, 2020 at 01:56 PM.
  Reply With Quote
Old January 21st, 2020, 02:02 PM   #3
lesmar96
Lifetime Supporting Member
United States

lesmar96 is offline
 
Join Date: May 2017
Location: PA
Posts: 403
Clever. I knew some one would think of something better. I'm still learning! Thanks!
__________________
Whatever you are, be a good one.
  Reply With Quote
Old January 21st, 2020, 06:45 PM   #4
drbitboy
Lifetime Supporting Member
United States

drbitboy is online now
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 814
Question

Quote:
Originally Posted by bjh View Post
relative_absolute_position = current_absolute_position - relative_zero_position
Sweet; I have to wonder about the variable names though ...

relative_absolute_position? Isn't it simply the relative_position?

not that anything is really absolute in the first place...

just sayin'
  Reply With Quote
Old January 23rd, 2020, 08:22 AM   #5
bjh
Member
United States

bjh is offline
 
Join Date: Jul 2010
Location: Madison, WI
Posts: 254
Quote:
Originally Posted by drbitboy View Post
relative_absolute_position? Isn't it simply the relative_position?
Yep! And I thought about changing it but didn't bother as the idea was communicated well enough.



Don't name your variables dumb things like this, kids.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Codesys network Variable comunication thebest1004 LIVE PLC Questions And Answers 3 August 5th, 2016 01:36 AM
CoDeSys 3.5 SP4 and J1939 CAN Bus jkcaldwe LIVE PLC Questions And Answers 2 July 24th, 2014 06:59 AM
Codesys sample program converting word variable into 2 byte variables InstrumentationUK LIVE PLC Questions And Answers 9 March 19th, 2014 07:51 PM
HC900 register and memory question juzeko LIVE PLC Questions And Answers 1 September 8th, 2008 02:19 PM
s7 200 and printer SHYAMAL LIVE PLC Questions And Answers 6 August 12th, 2008 02:47 AM


All times are GMT -4. The time now is 11:14 AM.


.