Me and my team have been developing an Encoder programing since last week. Our ideia is create some sort of buttons to each level of the Grids in FRC Charged Up, like Low, Medium and High. So, there’ll be a button for put our robot intake in one of those levels based in a position of our Encoder. However, the only way I’ve made for make this happens is configuring a “Reset Button” and press it every time I press one of the levels buttons. Because, if I try to press “Low button” to “High Button” without presing the “Reset Button” first, it don’t do nothing.
I’d like to develop an code for go to Low to High, High to Medium and etc, without being obrigated to press the Reset Button. Any ideia how I can code like that? Any results so far…
1718 programs in Labview and so does my team. Do a search on CD to find out code release
We build state machines that command the robot to move to different levels with different button presses.
There is no reset requires.
Also, you have not shown how you are controlling your motors but to make this work you will need to place your motors into position follow mode and tune a PID control loop built into the motor controller.
This is a way to do it, perhaps the wording could be interpreted a bit harshly though.
OP,
On a more basic level we may need to know a few things about the system. I suspect the encoder you are using “rolls past” zero a few times over the entire travel distance, as such “absolute angle mode” doesn’t really work in this case due to the multiple rotations. I suspect you are initializing the encoder, resetting it once it reaches a target. With a new setpoint you then move the appropriate offset, reset the encoder, …
I think what you want is to have an accumulator variable that keeps track of the current encoder count outside of the case structure. Within the case structure you can read your target value from the button press, do the math from the accumulator to find the offset, then move the offset amount.
Be sure to test slowly and make sure any limit switches at the end of travel work well at slow speeds and slowly tune it up. A PID as was mentioned will help you run this system faster.
When you say “an accumulator variable” are you refering to an “accumulator funtion”? For be sincere, I have no ideia how I can make those things you mentioned. Could You give and example of this kind of code you have suggested?
It would be a numeric that has a pair of shift registers on the loop and passes thru the case structure, very similar to how the “high” case looks.
Accumulator in this case is a generic programming term for a value that in incremented/ decremented and just keeps track. Just like your bank account balance.
It’s been a while since I have used labview, but the reason it’s not working is when you are in the high state the only way to change it is to hit the reset because you don’t check the other inputs. You need to check the inputs no matter what case you are in.
I really doesn’t know how to apply this accumulator programming you mentioned and how it would be useful. However, I took what you and @kgzak saind and created a new logic like the High state which it might work if I apply on Mid and High cases too. Am I on the right way?
I’d appreciate if you could send me a screenshot in Labview a code of those things you already suggested, showing at least the block you had used. Thanks for you help so far!
I don’t have LabView installed so I can’t make it that way, but basically what is happening is the shift register saves the value of the last loop. So in this image it is setting your set point to 0 and depending on if/what button is pressed it changes the state.
If you press the button for high you will enter this state and stay there until something changes the state. In this case the reset button.
A quick fix would be to take your High Mid Low selector logic outside the case statement. That way no matter what case you are in the logic will run.