0

Trinket M0 & digital encoder
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Trinket M0 & digital encoder

by thefwguy on Tue Jun 15, 2021 12:09 am

Hi all !

I'm trying to use a Trinket M0 to read a digital rotary encoder (like Alps) using Arduino IDE.
I wonder if somebody can suggest a library for that.
Initially I was using a Trinket 5V but I did run out of working I/O for the task so I did try with the Trinket M0 but of course the library used on the Trinket 5V is not working on the M0.
Any suggestion ?
Thanks
Steve

thefwguy
 
Posts: 10
Joined: Wed Apr 25, 2018 12:24 pm

Re: Trinket M0 & digital encoder

by mdkling on Tue Jun 15, 2021 9:39 am

Just to be clear:
You were using this 5V Trinket: https://www.adafruit.com/product/1501
And now you're trying to use this Trinket M0: https://www.adafruit.com/product/3500
Correct?

It looks like there are a number of rotary encoder libraries in the Arduino Library Manager. Which one were you using on the Trinket 5V?

mdkling
 
Posts: 9
Joined: Sun Jun 13, 2021 9:02 pm

Re: Trinket M0 & digital encoder

by thefwguy on Tue Jun 15, 2021 10:57 am

Hi !
Yes correct.
I originally started to use the old Trinket 5V (had some around) but then I needed at least an extra input.
Because the sharing with USB and LED I was out of look so I did try the M0, not mentioning the fact that extra space for code is not hurting :) nor the possibility to have USB debugging.

The library I used on the old Trinket is this one and it was working nice.
https://www.pjrc.com/teensy/td_libs_Encoder.html

However seems not ported for M0 and lot of errors about interrupt management and I/O Pins.
This why I was wondering if somebody can suggest something somebody tested on the Trinket M0, just to avoid to spend hours testing all the possible libs out there.
Thanks

thefwguy
 
Posts: 10
Joined: Wed Apr 25, 2018 12:24 pm

Re: Trinket M0 & digital encoder

by franklin97355 on Tue Jun 15, 2021 11:38 am

You might want to look at the instructions for Trinket (although not the M0) https://learn.adafruit.com/pro-trinket-rotary-encoder I don't know how they will address you issue though.

franklin97355
 
Posts: 21971
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Trinket M0 & digital encoder

by mdkling on Tue Jun 15, 2021 12:32 pm

For Arduino it looks like there's some working code for an Trinket M0 here (though not broken out into a library): https://github.com/vincentmakes/Infinit ... ob_0.9.ino
https://hackaday.io/project/164043-the- ... y-usb-knob

If you're willing/able to make the jump to Circuit Python there are some guides using the Trinket M0 here:
https://learn.adafruit.com/media-dial/code
https://learn.adafruit.com/rotary-encoder

mdkling
 
Posts: 9
Joined: Sun Jun 13, 2021 9:02 pm

Re: Trinket M0 & digital encoder

by thefwguy on Tue Jun 15, 2021 3:50 pm

Thanks for the link, I'll surely take a look.
I was considering CircuitPython too but so far I have to say I'm quite disappointed by it.
I did try it on a couple of boards much bigger than the Trinket M0 and I noticed the huge footprint and is quite unstable, not to mention the hoops I had to do to have the darn editor running on my Linux box and the problems with Python itself (I'm an old school developer who still dream to be able to go back to design in C : ) ).
I mean, already Arduino code has a huge footprint, having time I would write code "old fashion" to really use better the micro resources but I don't have time :(, this why I'm looking for a library tested on that micro.
I mean, having time I would write it, I did many times such thing for other micro/architecture (like MSP430).
But right now, no time ...
Steve

thefwguy
 
Posts: 10
Joined: Wed Apr 25, 2018 12:24 pm

Re: Trinket M0 & digital encoder

by mdkling on Tue Jun 15, 2021 4:28 pm

Yeah it depends on what your application is. The footprint is massive relative to bare metal, but the resources on modern microcontrollers are also comparatively massive, plus I like the immediacy of having a REPL and plaintext source resident on the device itself. But it's hard to beat C, especially in embedded applications.

I definitely get the struggle of having to choose where to spend you time. Just because someone *can* do everything in a project top to bottom, doesn't always mean they have time or interest to do so.

Good luck on you project!

mdkling
 
Posts: 9
Joined: Sun Jun 13, 2021 9:02 pm

Re: Trinket M0 & digital encoder

by thefwguy on Tue Jun 15, 2021 5:35 pm

The application is really simple, trivial I would say and thus not critical at all, I could even avoid to use the encoder and go with pushbuttons but is also to teach some basics to a person.
Thanks again for the links, at least I saw somebody else did more or less what I'm looking for and thus the M0 was the right choice.
Steve

thefwguy
 
Posts: 10
Joined: Wed Apr 25, 2018 12:24 pm

Please be positive and constructive with your questions and comments.