Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to have index zero counter and have count loop based on encoder resolution #6

Open
kenbo017 opened this issue Oct 9, 2017 · 0 comments

Comments

@kenbo017
Copy link

kenbo017 commented Oct 9, 2017

I have two issues I'm trying to figure out.

  1. I am using the encoder to read revolutions based on the encoder resolution. As an example, I have an encoder with 1000 ppr. This gives me 4000 "ticks" per revolution with my quadrature encoder with an index signal. So, I will want the encoder to count from zero to 3999 and then start back at zero so I will have a total of 4000 pulses. It would be good to have this as a variable in case I change resolution on the encoder. Ultimately I'll be mapping from zero to 359 but I need the high resolution and feedback as to the direction more accurately so it is great that on every tick I'm getting a direction value.

  2. I will use the index signal to reset the counter each revolution. At a basic level I can set to zero. In fact, for my purpose, I will want to use it to know the "offset" from zero. So, for example, when the arduino powers up I can put the arm that my encoder is attached to in the exact correct zero position. At that point I want to be able to send a "reset counter to zero" command. Then I can rotate the arm a full circle and read where the index is in reference to the zero position. I can then save that difference between zero and the index signal as an "offset". I'm not exactly sure how I would save that offset value but as long as I can read/request/set that value I can go from there. Then, whenever the arduino power cycles all I have to do is pull the offset number from where it is saved (external database or SD card) and write it to the arduino program. Then I rotate the arm around once. When it hits the index the counter should then automatically be set to that offset value. As a result the zero position will always be exactly where it should be and it won't have to be calibrated on every startup.

  3. In the .ino file I'll want to send out the position every time it changes via serial/ethernet along with some other data that I'm reading from other sensors so I'll need to have the header file give the .ino file the information on each tick so I can send it out. I would think this should be in the .ino file as opposed to the header file but, as I'm sure you can tell, I'm not an expert. I only know enough to get into trouble.

I have tried to add another interrupt to do this function but I'm not advanced enough to make it work within your templates, etc. I appreciate any help you could offer!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant