Tips for Arduno software for Rotary Table Controllers

Home Model Engine Machinist Forum

Help Support Home Model Engine Machinist Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
Hmm, I think I'm going to be able to squeeze this all in... Just! I keep making the text prompts shorter to do it though. :)

I was never sure I would make it!

So I have got all of the framework done and just have to convert a distance into the number of steps and the one Arduino will be able to control rotary and linear devices and swap between them at will. In fact thinking about it, because the step and direction ports are stored in EEPROM for each device, you could add more than one stepper controller.
 
Hi Rod

Sorry I have been absent. Just finished a big job and have been out of town with delivery and installation.

Your " Rotary Table Controller" has grown to be quite a monster , doing much more than originally planned. Funny how projects grow , isn't it ?
I too will be ordering a 48 V supply and trying to get this wrapped up.

Question, I will want to add an external switch to control "Next" or a right button press. We will be adding a proximity switch so my buddies old 3 axis mill can move over to the prox switch and advance the rotary table to the next position.
Should I try to set it up as "that button" or add another on an open analog input calling the same function ?

Thoughts ?


Scott
 
Hi Rod

Sorry I have been absent. Just finished a big job and have been out of town with delivery and installation.

Your " Rotary Table Controller" has grown to be quite a monster , doing much more than originally planned. Funny how projects grow , isn't it ?
I too will be ordering a 48 V supply and trying to get this wrapped up.

Question, I will want to add an external switch to control "Next" or a right button press. We will be adding a proximity switch so my buddies old 3 axis mill can move over to the prox switch and advance the rotary table to the next position.
Should I try to set it up as "that button" or add another on an open analog input calling the same function ?

Thoughts ?


Scott
Scott glad you are back, I wondered where you got to. Yes, I'll get the monster done! I'm not coming at this from a CNC background but I think what you want to add another switch that functions as the right button.

I've thought about this in terms of adding a rotary encoder to enter data. If you only want one button recognised, I think I'd use a digital port for the new switch.

Throughout the sketch you will see a loop with code like this:
Code:
      event = lcd.getButton();
      switch(event){
        case LCD_BUTTON_RIGHT:
...

I'd either edit the lcd.getButton() function in the LCD class to test our new port and return LCD_BUTTON_RIGHT if it sensed your button was pressed.

Alternatively, if its only one procedure you want this to work in, maybe you could modify the piece of code above to look for the extra input. Something like this:

Code:
      event = lcd.getButton();
      if(myButtonIsPressed())
         event = LCD_BUTTON_RIGHT;
      switch(event){
        case LCD_BUTTON_RIGHT:
...

Just remember your input must be 5 volts max and to debounce the button.

So as a progress update, I got the linear version in the shed last night and gave it a run. I have a few bugs.

  1. table direction appears reversed and can't be fixed in the config menu
  2. Linear home goes the wrong way. (Probably because of above)
  3. Rotary Home broken
  4. Can't test the distance is correct until I fit a power feed stepper but did check the steps were being calculated correctly.

The home functionality is a bit complex because in rotary mode, it needs to be reset when it passes the 0 degree mark but this is not the case in the linear mode.... and it involves the low level ISR routine.

Nothing I can't sort out when I get a bit of time. TorontoBuilder has been reviewing his hardware design so it will support multiple steppers. Check his thread too.
 
Hi Rod

Thanks !
Code:
     event = lcd.getButton();
      if(myButtonIsPressed())
         event = LCD_BUTTON_RIGHT;
      switch(event){
        case LCD_BUTTON_RIGHT:
...

I think this will do nicely, I will give it a try.

Scott
 
So as a progress update, I got the linear version in the shed last night and gave it a run. I have a few bugs.

  1. table direction appears reversed and can't be fixed in the config menu
  2. Linear home goes the wrong way. (Probably because of above)
  3. Rotary Home broken
  4. Can't test the distance is correct until I fit a power feed stepper but did check the steps were being calculated correctly.


Well, I solved a couple of issues so just have this one to go.
  1. table direction appears reversed and can't be fixed in the config menu

I've got a bit of rework to do here as I don't think my direction code was ever written properly. Ideally, we just need to be able to go into the device setup and "swap direction". eg, if it is going the wrong way, make it swap the direction and forget about clockwise and anticlockwise as if using a linear device, it is meaningless. Still need to think it through.
 
Hi Rod

Could you make the "Swap" swap button assignments ? Like , left becomes right and right becomes left ?

Scott
Thats what I had in mind. Its currently able to be changed by swapping the #defines for CLOCKWISE and ANTICLOCKWISE So I have to do that without hard coding. Its not hard, I just needed to think out the best way that links the swapping to the globals.dir field.
 
Well, Here is version 10 which has almost 1000 lines of code more than V1. I have one problem though and it comes from not putting my electronics in a safe enclosure. I shorted out my Gecko stepper controller and it looks like it has been fried so I could not give this a final test. I tested against an earlier known good verson and the stepper does not operate. :fan:

Therefore, it may be a while before I make much more progress but maybe you guys can test this for me in the mean time.

New features are:
New device type to a linear drive.
Note there is a new ratio for this controller type. In my case my drive cogs are going to be 32 teeth and 25 teeth so I can enter a ratio of 1.28 to suit.

Swap direction in Setup menu
This is the bit I did not get to test. Go to <Config><Setup> and there is a prompt that says "SwapD" (eg Swap Direction) that asks for a yes or no answer. If you answer "yes" the direction of travel when pressing the left and right buttons should change. to make permanent, make sure you save the setup. If you find problems, please explain issue clearly and I'll try and fix it.

New really cryptic menu options
Sorry about this guys but I was really pushed for RAM because the LCD class uses the String type for all of the prompts. If anybody wants to make a really valuable contribution, edit the Form and field classes in the LCD library library to eliminate use of the String type and use PROGMEM variables instead. Don't bother working with this script when you do that, just get the example form.ino sketch working with PROGMEM variables. and I' can fold it into this sketch.

I'm pretty sure it will all work as expected. I took my time and had it error free before I worked on the change direction code. If you search for CLOCKWISE and ANTICLOCKWISE, you will see the changes I made to enable this. If it isn't working, I can post up the prior version as V 9.5. and you can try that.

View attachment RotaryTableChuck10.zip
 
Hi Rod
I tried to compile V 10 and got an error.
It appears that I do not have the GetMicroField.h library and under that in the include list is another new library avr/pgmspace.h That was not there before. I do not know if this one will throw an error as well.
I goggled around and could not find either.

Scott
 
Hi Rod
I tried to compile V 10 and got an error.
It appears that I do not have the GetMicroField.h library and under that in the include list is another new library avr/pgmspace.h That was not there before. I do not know if this one will throw an error as well.
I goggled around and could not find either.

Scott

Ooops, sorry about that!. Here is an updated LCD library with the missing field type. Basically, this is a number in microns that specifies the distance to move in a linear environment. eg in units of 0.001mm. But when entering data, it puts a decimal point in.

You can comment out or delete
Code:
#include <avr/pgmspace.h>
That is when I was trying to implement PROGMEM strings but I gave up.
This header file should be buried in the Arduino environment as its part of the underlying Atmel AVR environment that the Arduino is built on.

View attachment LCD (2).zip
 
Thanks Rod !
That did it. Compiled fine and I played with it a little bit. It all seems to work. I will give it a more in depth review tomorrow.

Scott

Awesome! I am not very happy sitting here on the sidelines :(

Post up the bugs If you find any. Pretty sure it all works. I just wanted to check the swap direction feature worked.
 
Hi Rod
I was just playing with it hooked up to my 40 turn dividing head.
Everything works ! Swap works just fine. Home works as well. I messed with it for about an hour and only had one strange thing happen that I could not reproduce.
One time after the screensaver came on, I could not wake it. The screen showed all kinds of weird characters just random segments of all of the top row of characters. I had to unplug it to get it to reset.

That happened early and only once. Not sure what it was all about but , it has not reappeared.

Otherwise......AWESOME !!

I am going to see if I can get my external proximity switch working as a button today.

Again, many thanks for all your hard work.


Scott
 
Well I guess I'm not as clever as I thought had hoped. :confused:
I first tested my switch with the onboard LED and a basic button sketch. It works on the input selected. I am using D12, I think that is free ?

I first defined my switch and pins here
Code:
const int proxPin = 12;      // the number of the proximity switch pin
int proxState = HIGH;             // the current reading from the input pin
int lastproxState = LOW;   // the previous reading from the input pin
long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time
 
void setup() 
{
   pinMode(proxPin, INPUT);
 
   const char welcome1[] PROGMEM = "VMN Ctrl";
   const char welcome2[] PROGMEM = "V:";
   const char welcome3[] PROGMEM = "D=";

And only added the call code to the 2 events I am concerned about, which are Divide # and Divide angle . I added this to both of those fields right after the "getButton" call

I added this

Code:
      proxState = digitalRead(proxPin);
            if(proxState=LOW)
         event = LCD_BUTTON_RIGHT;


Like this

Code:
void goDivide(long gAngle)
{
   long thisDiv = 1; 
   int event = LCD_BUTTON_NONE;
   float tmpSTEPS_PER_REV = (float)globals.stepsPerRev;
 
   stepsPerDiv = (long)(tmpSTEPS_PER_REV *((float)gAngle/(float)MINUTES_IN_CIRCLE));
   divisions = (long)((float) MINUTES_IN_CIRCLE / (float) gAngle);
   printDivideVals(thisDiv,gAngle);
   while(event != LCD_BUTTON_SELECT){
      event = lcd.getButton();
      proxState = digitalRead(proxPin);
            if(proxState=LOW)
         event = LCD_BUTTON_RIGHT;
      switch(event){
        case LCD_BUTTON_LEFT:
          thisDiv--;
          if(thisDiv < 1)
            thisDiv = divisions;          
          digitalWrite( globals.DirPin, ANTICLOCKWISE );
          setSteps(stepsPerDiv * 2, 1);
          printDivideVals(thisDiv,gAngle);
          break;
        case LCD_BUTTON_RIGHT:
          thisDiv++;
          if(thisDiv > divisions)
            thisDiv = 1;          
          digitalWrite( globals.DirPin, CLOCKWISE );
          setSteps(stepsPerDiv * 2,1); 
          printDivideVals(thisDiv, gAngle);
          break;

I am also pretty sure I don't have the debounce code right either.

Any help that you code wizards may have would be appreciated :)

Many Thanks


Scott
 
Scott,

Great feedback thanks

I think you've made a simple mistake here
Code:
if(proxState=LOW)

C needs 2 equal signs when testing for equality so it should be
Code:
if(proxState==LOW)

If you have trouble with debouncing, try this http://playground.arduino.cc/Code/Bounce
but there are some other simple examples on the Arduino site
 
Hi Rod
I was just playing with it hooked up to my 40 turn dividing head.
Everything works ! Swap works just fine. Home works as well. I messed with it for about an hour and only had one strange thing happen that I could not reproduce.
One time after the screensaver came on, I could not wake it. The screen showed all kinds of weird characters just random segments of all of the top row of characters. I had to unplug it to get it to reset.

That happened early and only once. Not sure what it was all about but , it has not reappeared.

Otherwise......AWESOME !!

I am going to see if I can get my external proximity switch working as a button today.

Again, many thanks for all your hard work.


Scott
FANTASTIC!

It sounds like it could have been a loose connection or something. Other than that, it could be a memory leak in the LCD class somewhere which is not my code. I did put some explicit remove field statements in the main functions to try and stop this because at one stage on long sessions I had some similar problems very early on. You'll see this at the end of
the enterDivisions function as an example.

Oh and be disciplined with indenting your code. It makes it so much easier to debug when something goes wrong. eg
Code:
   proxState = digitalRead(proxPin);
   if(proxState==LOW)
       event = LCD_BUTTON_RIGHT;
 
Damn Rod....Your good, you fixed it from half way around the world!!!!!


I still had it powered up on the bench, and that indeed fixed it.

Thanks again.

Scott

Scott, I must have cross posted this morning and missed this. Have you any idea how many times I've been caught since I taught myself C back in 1990?

It is rare I get caught anymore, but I did do the same thing once in this project. :eek:
 
Hi Rod. I read you lost your driver, well, I did the same thing. Now I am looking for some one to blame. Like you I can't leave well enough alone. Rebuilt my old controller and had every thing working great, but, I run it on only 12 volts and tried it with 24 volts. BIG cloud of smoke and the 4988 driver was fried. It should have worked fine on only 24 volts but smoked anyway. Then I had 5 8825 drivers show up in the mail only minutes later. Stuck in new 8825 and pow, another cloud of smoke. All I could do is laugh. Couldn't find the short so I took the wire cutters to every thing. Then I loaded up Eagle Cad and milled out a new board. Didn't like the first one so went back and Eagle cam,ed a new board. It's all back together and working fine. I have to put it away before I do more to it. Now I have to figure out who to blame. Any ideas? Carl
 
Hi Rod. I read you lost your driver, well, I did the same thing. Now I am looking for some one to blame. Like you I can't leave well enough alone. Rebuilt my old controller and had every thing working great, but, I run it on only 12 volts and tried it with 24 volts. BIG cloud of smoke and the 4988 driver was fried. It should have worked fine on only 24 volts but smoked anyway. Then I had 5 8825 drivers show up in the mail only minutes later. Stuck in new 8825 and pow, another cloud of smoke. All I could do is laugh. Couldn't find the short so I took the wire cutters to every thing. Then I loaded up Eagle Cad and milled out a new board. Didn't like the first one so went back and Eagle cam,ed a new board. It's all back together and working fine. I have to put it away before I do more to it. Now I have to figure out who to blame. Any ideas? Carl

I wondered why you were so quiet. I know the feeling. But I bought a 48 volt power supply so I can't really pull out my little Pololu. I've been sitting back thinking about the next step.

Clearly a hardware issue, definitely not a software problem so don't blame me! :)
 
Back
Top