Shaft Encoders for drive in Easy C

For as long as I’ve been in vex, I’ve done nearly all of our autonomous programming off timing alone. As I’m sure you all know, this tends to be extremely inconsistent. So I want to know how to have all of the “drive” parts of our code using shaft encoders. I have absolutely no idea where to start. We have an encoder on each side of the drive. We are using easy c v4. Any help is appreciated. Thanks

I believe you can use a function called wait Until for your purpose.

So the pseudo code would look something like this:


Also, the encoder registers one click per degree rotated, so if you have 4 inch wheels, 360 encoder ticks = 12.56 (4pi) inches travelled. You can use that simple math to get a rough estimate of what to set your encoder to. You will have to test a few times.

I will give this a try. What do I use for the variables? And what do I do with the encoder block (where you can set up “start”, “get”, and I forget what else)

Does anyone have a sample code of how they use encoders on their base on easy c?

Try to search the forum a little bit. If you can’t find anything, I will post some code later tonight


QUOTE=Robo-Sumant;372870]Try to search the forum a little bit. If you can’t find anything, I will post some code later tonight

I have been looking for quite a while and can’t seem to find anything that helps

I haven’t used any of the smart blocks so I have no clue how waituntil works but this is how you can do it in easyC

startencoder blocks
get encoder set to variable named encoder
start motors
while loop (encoder<2000){
get encoder set to variable named encoder}
stop motors

Remember to update the variable every time the loop runs or you will only look at the encoder value back in the beginning.

I just tried this, and it didn’t work. The wheels never stopped

This didn’t work

What happened? Could you send a screenshot of the code blocks because I don’t have easyC in front of me.

I’ve tried it a few different ways. [ATTACH]8987[/ATTACH][ATTACH]8988[/ATTACH] nothing seems to be working.

[ATTACH]8989[/ATTACH] I also tried it this way