Skip to content

Add QDec library based on AVR1600 app note #8

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jolting
Copy link

@jolting jolting commented Nov 6, 2017

The code was obtained from here:
http://www.atmel.com/Images/AVR1600.zip

The code was obtained from here:
http://www.atmel.com/Images/AVR1600.zip

* TC_EVACT_FRQ_gc was misspelled as TC_EVACT_FRW_gc
https://lists.nongnu.org/archive/html/avr-libc-commit/2015-01/msg00001.html

* .c files renamed to .cpp for arduino compilation.
@bombasticbob
Copy link
Contributor

what does this library do, exactly? Is it a quadrature decoder for one of those rotating quadrature encoder thingies?

I need to make sure these things have no licensing encumberance before including them. The licenses for the ATMel code might not include putting it (modified or as-is) into an open source project.

@jolting
Copy link
Author

jolting commented Nov 21, 2017

That's the new BSD(3-clause) license, so it should be good on the license. Please check the original source from Atmel. The link is in the PR.

I was thinking about using one of these things for motor control. I admit, I haven't tried it on real XMega hardware yet. I was just about to get around it it.

@bombasticbob
Copy link
Contributor

@jolting

Just took a closer look, and it seems that it's (for the most part) "not in conformance with" the way I've set everything else up already, from wiring.c to interrupt handling. Also, the way it seems to set up ISRs for both timers C and E (is it really necessary to use BOTH for the QDEC hardware?), and other similar kinds of things, could be problematic. Or not. It needs further analysis. And, maybe API support in the 'core'.

I'm also not sure what kind effect it would have on everything else to use it 'as-is' so I'm putting off looking at this in depth for a while. It's the lack of time, mostly.

Thanks for the idea, though. A QDEC library is a good idea.

I downloaded doc8109 so I can study it more, later, though it doesn't say much. I also found section 5.7.2 in the 'D' manual as an example of how to set it up via the event system. I'm not 100% convinced that dedicating both timers C and E is necessary for this (as it would appear in the code). Instead, it should be possible to select which timers to use, particularly on systems that have many timers [and you might be using them for PWM at the same time, let's say].

So there's a lot to think about when considering how to properly implement such a library.

I've also seen this done before, with a pair of arbitrary interrupt pins (on an Arduino MEGA). That option should be available as well, i.e. "pick any 2 pins" and then have the input controller's readout in an arbitrary 8 or 16-bit integer.

Anyway, I probably spent way too much time on this but I understand why you'd want to submit it, since it's present on the device(s). So thanks. I'm leaving this open as a reminder to me.

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

Successfully merging this pull request may close these issues.

2 participants