Using optical encoder on Arduino Mega on pin 53,15,14,10

65 views
Skip to first unread message

Giorgio Campiotti

unread,
Jul 11, 2014, 11:16:28 AM7/11/14
to arduino-pincha...@googlegroups.com
Hello,
I need to use an optical encoder with 2 output with an Arduino 2560, but I can use as inputs only PIN 53, 15,14, 10. I need only two pin for my encoder.
No one of these PIN are directly interrupts, so my sensor reading are very bad.
If for testing only I use pin 2 and 3, or 20 and 21, my sensor reading are perfect.

I've already done a very complex PCB, so I can use only PIN 53, 15,14 and 10.

Can I configure two of these pins as interrupts using pinchangeint on my Mega 2560?


Thanks in advance
Giorgio

Alan Yorinks

unread,
Jul 11, 2014, 2:08:02 PM7/11/14
to arduino-pincha...@googlegroups.com
Hi Giorgio,
    Have you tried using pins 53 and pin 10 connected to the encoder? They are both on port B and according to the author of the library, should work. Pins 14 and 15 are on Port J, and the library author was not able to get pin 14 to function. You can check out the library author's discussion on the 2560.

   Please let me know if using 10 and 53 worked for you.

Thanks,
Alan

  

  So that eliminates
--
You received this message because you are subscribed to the Google Groups "arduino-pinchangeint-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arduino-pinchangeint...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Giorgio Campiotti

unread,
Jul 14, 2014, 4:47:56 AM7/14/14
to arduino-pincha...@googlegroups.com
My previous sketch is compiled on arduino IDE 1.05 (presume is the latest) but I can't compile the PinChangeInt Library on this version. Many compiling errors.
To unsubscribe from this group and stop receiving emails from it, send an email to arduino-pinchangeint-discuss+unsub...@googlegroups.com.

Giorgio Campiotti

unread,
Jul 14, 2014, 5:20:36 AM7/14/14
to arduino-pincha...@googlegroups.com
Ok, sorry, I've compiled the PinChangeInt Library.

Using the EXAMPLE Sketch, seem that the only working pin is the 10. Nothing happen using PIN 14,15,53.
Any idea about this?

thanks!
Giorgio

Giorgio Campiotti

unread,
Jul 14, 2014, 5:26:45 AM7/14/14
to arduino-pincha...@googlegroups.com
Ok,  :)
Seem that PIN 10 and 15 work with example sketch. Sorry for previous post.

Now, I need to user this Encoder Library: http://www.pjrc.com/teensy/td_libs_Encoder.html

Can someone help me to do this please?

many thanks

Giorgio

Michael Schwager

unread,
Jul 14, 2014, 11:43:07 AM7/14/14
to arduino-pincha...@googlegroups.com
Sorry, that Encoder library has no relationship to PinChangeInt. Probably you should go to the pjrc.com forums and ask for help there. Good luck!


--
You received this message because you are subscribed to the Google Groups "arduino-pinchangeint-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arduino-pinchangeint...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
-Mike Schwager

Alan Yorinks

unread,
Jul 14, 2014, 11:55:28 AM7/14/14
to arduino-pincha...@googlegroups.com
Hi Giorgio,
    Using the library is very straight forward and I have an old sketch that uses it.

    If you know ahead of time what pins you wish to use and how many encoders you need, the library is very nice, but if you need to dynamically create new encoder objects within the sketch, this library is difficult to use.
The library is oddly written in that all of the executable code is in a header file, which makes dynamic instantiation a nightmare.


Alan Yorinks

unread,
Jul 14, 2014, 11:59:52 AM7/14/14
to arduino-pincha...@googlegroups.com
I just realized I wasn't clear about what library I was referring to - I was talking about the pjrc.com library.

Michael Schwager

unread,
Jul 14, 2014, 12:20:44 PM7/14/14
to arduino-pincha...@googlegroups.com
On Mon, Jul 14, 2014 at 10:55 AM, Alan Yorinks <yor...@gmail.com> wrote:
The library is oddly written in that all of the executable code is in a header file, which makes dynamic instantiation a nightmare.

This library is odd in that way, as well. This is because of the way the Arduino IDE works; from the RELEASE_NOTES of the PinChangeInt library:

"All the code has been moved into this .h file, so as to allow #define's to work from the user's sketch."

...I actually got that idea from Paul at pjrc.com.
--
-Mike Schwager

Alan Yorinks

unread,
Jul 14, 2014, 12:41:56 PM7/14/14
to arduino-pincha...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "arduino-pinchangeint-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arduino-pinchangeint...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Michael,
    Using the adaencoder library which uses your library, I was able to incorporate encoder support into my StandardFirmata derivative sketch called FirmataPlus. The sketch allows for dynamic creation of encoder objects. Since adaencoder #includes your library, and the library itself has a separate header and implementation file, dynamic object creation is not an issue. With the pjrc library, everything is in the header making dynamic object creation (nearly) impossible.

Unfortunately, due to the inconsistencies across arduino processors in relation to interrupts, the only board that I can reliably provide encoder support  for is the Uno :-(.
   
Alan

Michael Schwager

unread,
Jul 14, 2014, 12:52:28 PM7/14/14
to arduino-pincha...@googlegroups.com
You might have an older version of the library. Nowadays, everything is in the .h file. But I don't understand why dynamic object creation is affected by the kinds of files used. Ultimately, it's all compiled. It's just a matter of how...

I have a #define that I use to keep everything in order, maybe that's the secret, I'm not sure.
--
-Mike Schwager

Giorgio Campiotti

unread,
Jul 16, 2014, 3:44:24 AM7/16/14
to arduino-pincha...@googlegroups.com
Hello,

Using PIN 53 and 10 it work!
Many thank to all!

Giorgio


Il giorno lunedì 14 luglio 2014 18:52:28 UTC+2, GreyGnome ha scritto:
You might have an older version of the library. Nowadays, everything is in the .h file. But I don't understand why dynamic object creation is affected by the kinds of files used. Ultimately, it's all compiled. It's just a matter of how...

I have a #define that I use to keep everything in order, maybe that's the secret, I'm not sure.
On Mon, Jul 14, 2014 at 11:41 AM, Alan Yorinks <yor...@gmail.com> wrote:
On 07/14/2014 12:20 PM, Michael Schwager wrote:
On Mon, Jul 14, 2014 at 10:55 AM, Alan Yorinks <yor...@gmail.com> wrote:
The library is oddly written in that all of the executable code is in a header file, which makes dynamic instantiation a nightmare.

This library is odd in that way, as well. This is because of the way the Arduino IDE works; from the RELEASE_NOTES of the PinChangeInt library:

"All the code has been moved into this .h file, so as to allow #define's to work from the user's sketch."

...I actually got that idea from Paul at pjrc.com.
--
-Mike Schwager
--
You received this message because you are subscribed to the Google Groups "arduino-pinchangeint-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arduino-pinchangeint-discuss+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Michael,
    Using the adaencoder library which uses your library, I was able to incorporate encoder support into my StandardFirmata derivative sketch called FirmataPlus. The sketch allows for dynamic creation of encoder objects. Since adaencoder #includes your library, and the library itself has a separate header and implementation file, dynamic object creation is not an issue. With the pjrc library, everything is in the header making dynamic object creation (nearly) impossible.

Unfortunately, due to the inconsistencies across arduino processors in relation to interrupts, the only board that I can reliably provide encoder support  for is the Uno :-(.
   
Alan

--
You received this message because you are subscribed to the Google Groups "arduino-pinchangeint-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arduino-pinchangeint-discuss+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
-Mike Schwager
Reply all
Reply to author
Forward
0 new messages