Rotary Encoder Missing Steps on fast or slow RPM

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
User avatar
Dutchie_World_Wide
Posts: 31
Joined: Thu Jul 08, 2010 8:52 am
Location: The Netherlands, or Thailand, or Gabon West Africa
Has thanked: 4 times
Been thanked: 3 times
Contact:

Rotary Encoder Missing Steps on fast or slow RPM

Post by Dutchie_World_Wide »

Hey Guys,

I need to read an 256 step encoder.
I've been reading the forum as I was having problems with steps missing on slow turns of the encoder.
The forum said that the checkforchange should be checked more often.
So I did, and now the opposite happens. It is missing steps on higher RPM's.
The sole purpose of the ECIO40P will be to send encoder readings and the state of limit switches over RS485 Modbus.
The RPM range will be 15 to 3000 RPM

Now i have it set up to send it to another ECIO40P over RS232 for testing.

what am I doing wrong?

Jeroen
Attachments
VFD.zip
Compressed
(284.32 KiB) Downloaded 226 times
Dutchie

"This is not a bug, this is a feature!"

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Rotary Encoder Missing Steps on fast or slow RPM

Post by medelec35 »

Hi Jeroen,
First of all not 100% if I have got my facts correct but it should show you the issue.

If Maximum speed is 3000RPM and each RPM = 256 steps then at 3000 RPM steps will be 3000*256 = 768000.
So every second the encoder has to count 12800 steps = 1 step every 78us
Interrupt for cheking state is 6000Hz = 166us

Not only is capture time too low, the step could easily be missed at the time of interrupt.

If it was me, I would not use timer interrupt, i would use pin detection interrupt.
There are loads of choices.
You could use external interrupts: INT0,INT1, INT2, IOC,or T0CKI
Reset time & inrerrupt count.
Time for a set period eg 1 second
After 1 second has elapsed read interrupt count.
Convert to RPM.
Perhaps you could look on the forum for frequency counter and use one of them to display RPM instead of frequency?

Martin
Martin

User avatar
Dutchie_World_Wide
Posts: 31
Joined: Thu Jul 08, 2010 8:52 am
Location: The Netherlands, or Thailand, or Gabon West Africa
Has thanked: 4 times
Been thanked: 3 times
Contact:

Re: Rotary Encoder Missing Steps on fast or slow RPM

Post by Dutchie_World_Wide »

Hi Martin,

Thank you for your reply.
I started from scratch again, and tried to keep it simple.

I do not really need RPM, I need to measure the distance a chain has traveled that is connected to the motor.
The motor runs between 15 and 3000 RPM.
I tried to keep it simple by using A-Channel on INT0 and then look at the status of B-Channel to determine if it is counting up or down.
I use Z on INT2 to read the amount of steps counted to see if the ECIO counted all the steps.
I tested it on 0 to 1200 RPM but the steps counted are between 256 and 247
The same happens as before. It is missing steps.
I raised the BAUD rate to the max hoping that would fix it.
But no joy.
Attachments
L15-optical-incremental-encoder.pdf
Encoder PDF
(232.69 KiB) Downloaded 213 times
VFD.zip
(213.91 KiB) Downloaded 232 times
Dutchie

"This is not a bug, this is a feature!"

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Rotary Encoder Missing Steps on fast or slow RPM

Post by medelec35 »

Hi Dutchie,
Not sure if this will help or not?


Martin
Martin

User avatar
Dutchie_World_Wide
Posts: 31
Joined: Thu Jul 08, 2010 8:52 am
Location: The Netherlands, or Thailand, or Gabon West Africa
Has thanked: 4 times
Been thanked: 3 times
Contact:

Re: Rotary Encoder Missing Steps on fast or slow RPM

Post by Dutchie_World_Wide »

Thanks Medelec,

I noticed that my interrupt on Z_Wire caused the missing counts.
I stayed with the Int on A-Wire.

Thank you
Dutchie

"This is not a bug, this is a feature!"

Post Reply