ELS Project - spindle position read-out

That's pretty cool. I looked at your info just for kicks and grins. It wasn't exactly Greek but pretty dam near it. Years ago, I used to play around on an Apple IIe writing some programs. It was just for the fun of it and well girls and motorcycles took presidents and computer programing didn't only take the back burner, but it completely fell off the stove.

Welcome to the site! I'm pretty new here also and I don't even have any equipment yet. Although it is on the way, currently on a ship somewhere between Tiawan and the USA.

Looking forward to seeing your setup up and running!

Tim
 
OK I have rewritten the code and uploaded it to Github, now merged to the master branch here:

This compiled just fine on the latest version of CCS.

Good job, code works. I'm still using CSS 9.3 and made changes in my source. I might not ever use it but nice to know it's there if I need to. One thing was I had to change back to Encoder_Max_Count 0x00ffffff or my servo got very jumpy as I was turning spindle.

Original
#define _ENCODER_MAX_COUNT 0x00ffffff
Your code
#define _ENCODER_MAX_COUNT 0xffffffff
 
Good job, code works. I'm still using CSS 9.3 and made changes in my source. I might not ever use it but nice to know it's there if I need to. One thing was I had to change back to Encoder_Max_Count 0x00ffffff or my servo got very jumpy as I was turning spindle.

Original
#define _ENCODER_MAX_COUNT 0x00ffffff
Your code
#define _ENCODER_MAX_COUNT 0xffffffff

Thanks - I wondered why James' original code used a value lower than a full 32 bit uint. Honestly I don't understand why this causes an issue, but the only reason I extended it to 0xfffffff was so I didn't have to manage under/overflows lol. No problem, I'll revert that to its original value and introduce some under-overflow management to the spindle position.
 
That's pretty cool. I looked at your info just for kicks and grins. It wasn't exactly Greek but pretty dam near it. Years ago, I used to play around on an Apple IIe writing some programs. It was just for the fun of it and well girls and motorcycles took presidents and computer programing didn't only take the back burner, but it completely fell off the stove.

Welcome to the site! I'm pretty new here also and I don't even have any equipment yet. Although it is on the way, currently on a ship somewhere between Tiawan and the USA.

Looking forward to seeing your setup up and running!

Tim
Cheers, I'm definitely not a coder by any stretch but I have a pretty big advantage - my brother is a software engineer so I've got help whenever I need it. I learned BASIC when I was 7 or 8, and still use it to this day writing macros in excel for my work. That's the extent of my programming experience.
 
Thanks - I wondered why James' original code used a value lower than a full 32 bit uint. Honestly I don't understand why this causes an issue, but the only reason I extended it to 0xfffffff was so I didn't have to manage under/overflows lol. No problem, I'll revert that to its original value and introduce some under-overflow management to the spindle position.

I don't see why it would cause an issue either but changing it back to original, definitely calmed the servo down to where it was. There must be something overflowing but I don't see it as I was running lathe for an hour and cutting an external thread. I pushed the set button and it displayed position but then had a value of 567.2 (might not be exact number but definitely bigger than 360) and would not update any longer turning spindle until I powered down and reset. RPM was still working as normal.
 
I have updated my code with better overflow/underflow handing and cleaner, smarter arithmetic. I won't have time to properly test it until next weekend, but feel free to download it off my github and give it a go.
 
I downloaded and it definitely looks like it fixed the overflowing issue. I ran the lathe for 30 minutes or more and position still worked. It does start dropping a few degrees the longer it runs. For instance, you start out with spindle at 0 degrees and after running at 1000 rpm for a while, same spot might be 357 degrees, then later, 354 degrees. For intended purpose of making index marks on a part, not a big deal. I haven't dug too deep into code but I would have thought there would have been a fairly repeatable position coming in from the encoder. The encoder can't really lose position, unless the belt slips.

Another useful feature might be to power up and initialize spindle position as 0 degrees on startup. Mine will read 0 after code flash, but reads 225.2 on power up any other time. Maybe even place spindle where you want to be 0 degrees, then pressing "Set" and going into position mode, sets it to 0.
 
Loving the feedback mate, really helpful. I've got a busy household with 2 kids under 5, and a garage attached to the house, so my time in front of the lathe is limited. Having someone else doing the testing is working well for me!

I suspect I know the source of the creeping - the encoder has (in my case) 8,192 positions, counting 0 to 8,191. I don't ahve my code in front of me, but I suspect I've got it set up to wrap around at 8,192 instead of 8,191, so it's probably out by 1/8192 per rotation (which adds up if you spin the lathe).

Regarding the zeroing, my plan is still to incorporate a second clough42 board with a second breakout display, because I want to include some new functionality. I planned on having a zero button on that second display. However, it would be straight forward enough to have it reset to zero when each time Position is selected.

Interesting bug with it initialising to 225.2, no idea off the top of my head why this would be. I'll check it out.

Thanks!
 
I love someone adding value added features. Beats having a 100 tooth saw blade and metal pointer hanging off back of lathe for indexing. My encoder resolution = 4096.
 
Back
Top