Eureka! A big problem solved, maybe…

Since switching to the 128-cpr encoder I’ve been having a slightly peculiar problem and I think I may have found the cause: serial buffer overflow.

What’s happening is that during program operation, when the DRO is receiving updates, if I spin the encoder very fast, the LCD display would lock up and refuse to display any values. Originally, the only way to recover was to reset the Arduino, but I made some improvements that allowed for a softer recovery. Basically, if it froze, you had to wait a second, then jiggle the encoder a little, and the display would come back. It still wasn’t robust, though, and I couldn’t see what was going on.

Well, it turns out that the Arduino’s serial buffer is a whopping 128 bytes, which isn’t very much. With 6-byte messages streaming in and 3-byte messages going out, it seems very possible that I’m getting buffer overruns. If this is in fact the problem, there are a bunch of different possible solutions, but they all basically come down to reducing the amount of data moving over the wire, particularly the update rate of the encoder.

On the incoming side, I’ve already made a major change in ditching the DRO display during program operation. Instead, I created a different page which displays the spindle and feed rate override percentage values, which are what you’d actually control in that setting. Next, I’m changing the way updates are sent so that only the “hot” parameter gets updated more than twice per second. In other words, if you’re manually jogging the X axis, then the X axis DRO will update ten times a second, but everything else will only update twice. Likewise, in program operation, if you’re tweaking the FRO, then the FRO% and velocity will update fast, but the spindle RPM will go in the slow lane. Taken together, this will reduce the number of updates without, I think, reducing any utility.

On the encoder side, there are a few possibilities. I didn’t have this problem with my old encoder, which was I think due to (1) it being only 32 CPR, so you’d have to spin it 4x faster to get the same amount of data output; and (2), it had detents, which slowed down the spin rate even further. All told, I think I liked the feel of the old encoder better. I *really* like the detents, because they allow for precise positioning. The lower pulse rate does make it less nice to use for long jogs, but since the pendant has continuous-jog buttons for both X and Y, I think the main use of the handwheel is primarily for nudging, where 32 CPR is plenty.

A true CNC MPG wheel like this one might be the best of both worlds, but it adds a lot of expense ($60-$80 vs $20-$30). I also picked up some really basic encoders of the type used in consumer audio/video equipment which I’m interested to try. They’re 24-count, detent type, and cost under $5 each. I previously tried some Panasonic encoders like this and they failed, because the output was unreliable for steady rotation, but maybe these will work better. If they do, it could trim $30 or more from the price of a finished pendant.

About these ads

6 responses to “Eureka! A big problem solved, maybe…

  1. Ross February 13, 2011 at 1:39 pm

    Man I hope those 5$ encoders work :)

    Ross

  2. Michael Jones March 10, 2011 at 4:14 pm

    I’ve been watching your project and it looks VERY interesting. I’m interested in adapting something like this into the front of my mini mill .. maybe with a button panel like yours, or something else – not sure yet.

    What was the verdict on the $5 encoders? Do you have a source for them, or are you going to be a source?

    Thanks for all the great work! :D

    Michael

    • Colin March 10, 2011 at 4:56 pm

      Thanks! I haven’t tried the $5 encoders yet, but they’re just a regular stock item at Digi-key. It’d be nice if they work.

      • Michael Jones March 12, 2011 at 8:35 pm

        Do you know if they have any kind of detents?

      • Michael Jones March 12, 2011 at 8:39 pm

        Ok.. might help if I read your description more carefully… detens and everything VERY nice. I’ll have to go hunt through digikey and see what I can find. Do you know the part number off hand?

        Thanks,

        Michael

  3. Colin March 12, 2011 at 11:07 pm

    Here’s a link to the part on Digi-key:

    http://parts.digikey.com/1/parts/1567257-encoder-rotary-16mm-vert-24ppr-acz16nbr1e-15fd1-24c.html

    Don’t get too excited yet, though, I still haven’t tested them to see if they’re any better than the Panasonic ones that were unusable.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: