Hello Guest it is April 18, 2021, 11:22:35 AM

Author Topic: Resetting Encoder Count Via a BRAIN  (Read 6940 times)

0 Members and 1 Guest are viewing this topic.

Resetting Encoder Count Via a BRAIN
« on: May 27, 2009, 04:25:07 PM »
I am trying to write a brain that will compare the counts on encoders on each screw of a two screw gantry and issue an e-stop if they differ by more than a certain number of counts. This is used as a control to keep from racking the gantry if a motor starts skipping steps on one of the lead screws. I believe I know how to do this, except for establishing the initial count for the encoders. I would like to zero the encoder counts when the system is in an e-stop condition. There is a "zero" button on the Settings screen (one zero button for each X, Y, and Z encoders), bi I cannot find a brain button to do that. I believe EncoderCnt 0 corresponds to the x-encoder in the brain. I am also a bit confused by the fact that you can configure 4 encoders in the Pins and Configuration screen, but there are only 3 (X,Y, and Z) encoders shown on the Settings screen.

Any help will be greatly appreciated.

Offline Hood

*
  •  25,838 25,838
  • Carnoustie, Scotland
    • View Profile
Re: Resetting Encoder Count Via a BRAIN
« Reply #1 on: May 27, 2009, 05:05:27 PM »
There are OEM codes for zero X Y and Z DRO, cant see any for A unfortunately :(
In the Brain you can have the terminator as a button press then manually type the OEM number into the box in place of the OEM that is there.
Hood
Re: Resetting Encoder Count Via a BRAIN
« Reply #2 on: May 27, 2009, 05:20:21 PM »
There are OEM codes for zero X Y and Z DRO, cant see any for A unfortunately :(
In the Brain you can have the terminator as a button press then manually type the OEM number into the box in place of the OEM that is there.
Hood

Thanks for the quick reply. Is the last sentence in your reply a solution? If so, can you further explain. If it is not a solution, do you know of a way to write an encoder count to Encoder0? That way I could write 0 to it as opposed to activating a zero button. If that won't work, do you know of a way to write the Encoder reading to a variable while the system is in e-stop. I could then use that value in a formula once it is out of e-stop. Surely there is a way to accomplish this.

Thanks again for your help.
Kent

Offline Hood

*
  •  25,838 25,838
  • Carnoustie, Scotland
    • View Profile
Re: Resetting Encoder Count Via a BRAIN
« Reply #3 on: May 27, 2009, 05:29:04 PM »
If you terminate the Brain and choose Button Press you will see like pic 1, if you click in the box you caan then type in the OEM code followed by a description and it will do that function. The OEM for Zero X encoder is 133, Y is 134 and Z is 135, you can find a list of OEM codes on the WIKI or you can download a xls with them from the post at the top of this forum.
Hood
Re: Resetting Encoder Count Via a BRAIN
« Reply #4 on: May 27, 2009, 05:33:44 PM »
Since there is not an OEM code to zero Encoder0, does that mean you know of no solution?

Offline Hood

*
  •  25,838 25,838
  • Carnoustie, Scotland
    • View Profile
Re: Resetting Encoder Count Via a BRAIN
« Reply #5 on: May 27, 2009, 05:37:53 PM »
Not sure I follow what you mean by Encoder0, are you meaning the fourth encoder (Encoder4)?

Hood
Re: Resetting Encoder Count Via a BRAIN
« Reply #6 on: May 27, 2009, 05:52:22 PM »
In the Ports and Pins screen I have set up Encoder1. Then in the Brain editor I tried to find Encoder1, but could not. I found Encoder0 in the DRO listing. When I turn the encoder, I see the count for Encoder0 change in the Brain.

I am a newb to Mach. Perhaps there is a better way to assign things. I would be glad to assign the encoder to X, Y, or Z so long as it did not affect the machine with respect to the X, Y, or Z axis. I'm very open to any suggestions you have.

Offline Hood

*
  •  25,838 25,838
  • Carnoustie, Scotland
    • View Profile
Re: Resetting Encoder Count Via a BRAIN
« Reply #7 on: May 27, 2009, 06:06:26 PM »
Ok I thought you were wanting to have the Brain press the Zero X Encoder button when it sees some input trigger. Is that what you are wanting to do or are you wanting to enter numbers directly into the DRO from a formula in  the Brain? If that is what you want to do then the DRO you want to write to I think are  MPG0 MPG1 and MPG3.

Hood
Re: Resetting Encoder Count Via a BRAIN
« Reply #8 on: May 27, 2009, 08:25:31 PM »
I apologize for not communicating clearly. My ultimate goal is to detect racking of the gantry and stop the machine before damage can be done. The gantry is moved by a lead screw on each side. My plan is to have a rotary encoder at the end of each screw. When I detect that one screw is not keeping up with the other, then issue a stop command. My problem is establishing the inital conditions for each encoder. I am sure there are many ways to solve this problem. My first thought was to detect when the machine is in an e-stop state and then zero each encoder count via a brain. When the machine is taken out of the e-stop state, then have the brain compare the two counts and stop he machine if they differ by more than a few counts.

If there is no way to zero the counts, then my next thought was to read the counts into a variable when the machin is in an e-stop condition. Call these the initial count variables (a variable for each encoder). Once the machine is out of the e-stop condition, subtract the initial count variables from the encoder readings. Again, if these readings differ by more than a few counts, stop the machine.

I am open to a completely different approach. Perhaps I need to assign the encoder to an MPG or axis DRO. Perhaps my newness to Mach is making this a much more difficult problem than it should be.

vmax549

*
Re: Resetting Encoder Count Via a BRAIN
« Reply #9 on: May 27, 2009, 09:15:57 PM »
You will want to stick with brains unless you do a plugin to handle the chore. The brains run as fast as it gets besides a plugin.

Yes you want to use the encoder input that what they are for.

The codes for the zero encoder function are

x = 133   
y = 134
z = 135

ART did NOT encluded every function in the brains so you will have to add it  as you need it.

Might be wise to spend some time to learn to use the brains I believe there is a help file in the users docs section .

OR request help and wait for it to show up it usally does. Someone who knows the brains usally see the request and shows up. Sometimes it takes a couple of days for the news to travel around the globe.

Patience (;-) TP