CCL, LUTS and Encoders

Go To Last Post
17 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Guys,

 

I'm trying to figure out if I can drive more than one encoder (plan on using ATmega4809) 

 

I've had a look at app note  AN2434 but I'm not up to speed enough as to how I might have multiple encoders going via the LUT or even if that make sense at all

 

Currently I use an ATmega324PB with PCINTS and it works well, but this seems a more efficient way of doing this. (plus there are more I/O pins on the 4809)

 

regard

 

** Title should have been CCL not CPL but I can't change it 

 

Changed!! No Charge - JGM

 

 

Last Edited: Wed. Aug 21, 2019 - 05:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Each encoder needs 2 LUTs, each LUT detects one direction.

Since the mega4809 has 4 LUTs, it can decode the signals from 2 encoders.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, I knew it was too good to be true

 

regards

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

nikm wrote:
I'm trying to figure out if I can drive more than one encoder (plan on using ATmega4809) 

 

Answer:

El Tangas wrote:

Each encoder needs 2 LUTs, each LUT detects one direction.

Since the mega4809 has 4 LUTs, it can decode the signals from 2 encoders.

 

Meaning you can drive more than one encoder...

 

So why the long face:

nikm wrote:

Thanks, I knew it was too good to be true

 

regards

 

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Because I need more than 2, ie 16.  My bad for not making it clear.blush

 

regards

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ahhhhhhhhhhh!

 

What about using some sort of external encoder interface?  There are a lot of them out there from what I saw in a google search.

 

seems like there are some software PCINT projects out there that you could look at as well.

 

16 encoders?  What is that for if I may ask?

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have 16 encoders working with PCINT using an ATmega324PB built with the arduino IDE.  Problem is I don't have enough spare pins if I want to convert using Studio7 and JTAG.  Hence me looking at the 4809.

 

I haven't  found out what's the equivalent of PCINT in the 4809 as yet though.

 

The card is an input card for an application where the user can configure the ports to be simple interrupt driven inputs or assign pairs as encoders.  That's why external encoders won't do I'm afraid

 

My fallback is using MCP23S17's but I'd rather not.

 

regards

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Then jump UP to a Mega 2560.  Or in the case of the 324PB disable the JTAG and program the device through ISP.

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sadly the 2560 only has 24 PCINTS, but I think if I go with an external oscillator on the 324PB I'll get back a pin and should be ok.

 

regards

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What type of encoder are we talking about here?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mechanical concentric ones, such as Elma E37 as well as regular quad ones.  Movement is human generated, not some other mechanical device.  Are you thinking polling will suffice?  My experiments suggest some movements will be missed if turned fast

 

 

regards

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For cheap encoders, you need two I/O pins for each encoder.  One pin per encoder needs to be connected to a PCINT pin.  When the PCINT goes low, check the other pin.  If low, then encoder was turned one way and if high it was turned the other way.   For eight encoders you need 16 pins with eight being PCINT.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

nikm wrote:
I have 16 encoders working with PCINT using an ATmega324PB built with the arduino IDE.  Problem is I don't have enough spare pins if I want to convert using Studio7 and JTAG.

 

You mean, because the Arduino IDE uploads code using the bootloader? AS7 can do that too, if you configure it to use avrdude as an external tool. Granted, it requires some work.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you believe that is the case for all 2 pin encoders? It's been a while since I looked at the code, but some encoders send multiple pulses per detent (4) and others 2

 

regards

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I dare say you could multiplex and poll a number of them via a timer interrupt. What is the maximum pulses per second you expect?

Using multiplexing, you could read 16 encoders using 12 pins.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The speed won't be that fast.  5 detents/second, so 20?

 

regards

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think multiplexing will work for you then.