Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Encoder programming help needed. (http://www.chiefdelphi.com/forums/showthread.php?t=137687)

burde1jb 06-07-2015 19:52

Encoder programming help needed.
 
2 Attachment(s)
Hey CD! So our lead programmer graduated and his understudy moved back to Germany...

So working on a summer bot left us with very little LabView know-how. I'm coming to you as I have exhausted other sources and I will lay them out as we go.

Here's what we would like to do. We have the AndyMark Hall Effect Encoder on the back of a PG71 with RS775 motor attached. This is then attached to a 16 tooth gear which runs an 84 tooth gear (5.25:1 gear reduction). That 84 tooth gear spins our turret on our t-shirt cannon robot. Yes, this is basically our version of Shockwave. Mad props to Team 254.

Okay, we would like to use the encoder to enable us to push a button, have the motor spin just enough to move to the next barrel to help us get to the next shot. So the disc is 14 inches in diameter. There are 10 barrels all together, so we want the disc to move 14 * pi / 10 inches.

I've attached pictures of our Begin.VI and Teleop.VI

When this code was deployed, the motor would only spin on holding the button down and would not stop when it got to the next barrel. In fact, when the button was suppressed, the turret just kept spinning until we let go of the button. We checked the PWMs to be sure we were not mixing up which button did what.

So here is what we modeled the code and our work after:
Wiring
Block Diagram
Other sources

TL;DR Want a 14 in diameter plate to be moved 1/10th of the way on the press of a button. 84:16 and 71:1 gear reduction with 7 pulses per revolution. Robot runs motor while holding down button and does not stop until we let go of the button.

I'm thinking we did something wrong with the DistancePerCount in Begin.VI or Distance in the Teleop.VI. I'm just not sure where we went wrong.

Any help would be appreciated. Many thanks from Team 4327. Please take a look.

Mark McLeod 06-07-2015 20:06

Re: Encoder programming help needed.
 
Doesn't the Encoder Get always read zero because of the Encoder Reset just before the Get?
You might want to run this in Debug and probe the wires to see what values you are getting.

It looks like the logic of when to Reset needs a little work.
The Reset can be moved into the True case, but you also need to add an interlock that doesn't do the Reset unless the button is False.

burde1jb 06-07-2015 20:45

Re: Encoder programming help needed.
 
Full disclosure: I added that Reset after we tested the code. I thought maybe pressing the button twice would have done something funky.

So the code failed without the Reset.

PS: Thanks for the quick response. And thanks for your website. It has helped soooooo many times.

Mark McLeod 06-07-2015 23:07

Re: Encoder programming help needed.
 
I'd suggest checking the values coming out of the Encoder Get to see if they are what you expect when the encoder is turning.

Verify:
1) That the encoder is working
2) The encoder is counting up instead of down (not -4.398...)
3) The calculation is giving the values you expected

You will need the Reset to get it to work more than once, but it can be dropped inside the True case in an additional case of it's own wired to the button (False).

burde1jb 07-07-2015 21:41

Re: Encoder programming help needed.
 
1 Attachment(s)
Mark,

Please let me know if the attached image reflects what you suggest.

We've never utilized the Dashboard before so I'm hoping adding the indicator will automatically place an indicator on the Dashboard so we can read the information from the encoder. Is that right?

I'll be able to give you information tomorrow as the students will meet again and can test the code.

Thanks again for your help.

Mark McLeod 07-07-2015 22:14

Re: Encoder programming help needed.
 
The Reset is almost there.
The inside Case ? should use an inverted Button 3 wire instead of using the same ? feed as the outer Case (or non-inverted, but with the Reset in the False case).
The extra wire for the zero constant isn't necessary.
Essentially, the logic is
  • Keep turning if the encoder hasn't reached the target yet and button 3 continues to be held
  • Stop Turning when the encoder gets there even while button 3 is still held (also stop turning if button 3 is released before the encoder reaches the target)
  • Reset the encoder only after the driver has released button 3 and the target has been reached (if reset earlier the whole thing just immediately starts over and it never stops more than momentarily)
  • Start turning again when the button 3 is held down a second time
The Distance indicator you've put on the Front Panel will do fine.
Just run the code from Robot Main using the white run arrow at the top left of the window, and open up the front panel of Teleop to watch the distance indicator.
You can also use probes in the Teleop Block Diagram while it's running in this debug mode. Just hover over the wire you want to watch and right-click to choose Probe. It'll give a running display of the wire value. The advantage to this is you can probe lots of wires if you want without having to stop and restart the code.

burde1jb 08-07-2015 08:28

Re: Encoder programming help needed.
 
1 Attachment(s)
Mark,

Let me know if this is what you intended to communicate. The yellow arrow points to what I believe is your comment: "The inside Case ? should use an inverted Button 3 wire instead of using the same ? feed as the outer Case (or non-inverted, but with the Reset in the False case)."

The green arrow points to the comment: "The extra wire for the zero constant isn't necessary." When I deleted this constant, I got big red X marks on the line leading to the Reset case structure.

I also changed the case structure to false for the reset function.

Please let me know. Thanks!

Mark McLeod 08-07-2015 09:33

Re: Encoder programming help needed.
 
That's it for the Case.
It should do what you want now.

The yellow wire, not the constant, just the one wire leading to the Case gets deleted.
Then remove the red X's by hitting control-B, which removes broken wires.

burde1jb 08-07-2015 12:43

Re: Encoder programming help needed.
 
You're right! That worked. We will need to fine tune the DistanceperCount number, but the button operates the motor as described!

Thank you so much for your help!

Mark McLeod 08-07-2015 12:56

Re: Encoder programming help needed.
 
It's been a pleasure, good luck!


All times are GMT -5. The time now is 10:23.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi