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.
There are still a few bugs in the divisions and angle procedures, I am working on. A few of them got introduced when I changed the configuration data #defines which interfered with the casts between data types. I'll do a bit more checking.

Rod, You're awesome. Thanks for working so hard on this.
 
I decided to post up another version with most of the bugs sorted.
Also solved the two keystrokes to exit problem :D

Thanks for this Rod Thm:Thm:

do we still have to import the LCD library from post 20

cheers

Luc
 
Hi Rod

I hacked into my 4th axis and ran from the arduino. Power from the mill and step/direction and 5V from the arduino. This is a 6" Tormach 4th. It has a Nema 23 motor. Running at 65 volts with a current limiting resistor for 2 amps.
It ran well, I bumped the speed up to 100.
You are correct , single steps are really small , it really takes a bunch to move a degree.

I ran into a error when trying to move a specified 30 degrees. It was turning 180. I took some shaky handheld video.

www.sdmfabricating.com/upload_page/RodV4.MOD

With the exception of the math error it is very cool !

Or maybe it was remembering the previous input of 2 in # divisions ?
The screen did say "of 12" when I had it set to 30 degrees on the DMS page.

Scott
 
More info

I tried to reproduce the bug and it is reproducible. But I am not sure it is a problem if you know about it and I am not sure anyone would do this.
Step 1 boot up, set number of divisions to 2 and go, it will go to 180. hit it again it will continue on to 0
step 2 select out and select to "set angle" enter 030.00.00 and go, it will go to 180

I do not think a real world situation would have you entering data like that. It would be either all degrees or divisions.
And if you have too switch , reboot and start fresh.

I did enter 10.00.00 and it went 10 and then reentered 30 and it went another 30 to 40 so that works fine.

"Home" works good. If you do not set a home position it will go to where it was when you booted up.

Very,very nice Rod !! well done.

Scott
 
Although it compiled without error this time, I cannot get ver4 to run on my hardware. I do have all the libraries required, and changed the step and direction pins to match my setup. I reloaded Chuck F's sketch and it works so no hardware issues. The menus come up and work but the stepper, she no move!.

Chuck
 
Although it compiled without error this time, I cannot get ver4 to run on my hardware. I do have all the libraries required, and changed the step and direction pins to match my setup. I reloaded Chuck F's sketch and it works so no hardware issues. The menus come up and work but the stepper, she no move!.

Chuck

Chuck
I do not think you can change the sketch to work with your hardware. Rod moved the step pin from 3 to 1 because there was a conflict with pin 3.

Not entirely sure but that is my guess.

Scott

Edit; I just checked the LCD library and the "backlight" pin is pin 3
 
I'm not having a problem with the LCD, it displays the menu options and I can set the # of divisions. Just the stepper not working. I can hear the stepper buzz, and it kinda twitches when the movement ends.
I guess if I want it to work, I need to go through both sketches side by side and find where the settings are different for the stepper.

Chuck
 
Chuck

Pin 3 is being used already by something else. By you trying to use it as well is a "conflict" it is not going to work correctly.
You won't find the pin conflict in the sketch. It is in the LCD library and cpp file.

I do not know enough about this stuff to know if you can alter that library without major issues.

I think you would be much better off moving the step pin to pin 1.

Scott
 
More info

I tried to reproduce the bug and it is reproducible. But I am not sure it is a problem if you know about it and I am not sure anyone would do this.
Step 1 boot up, set number of divisions to 2 and go, it will go to 180. hit it again it will continue on to 0
step 2 select out and select to "set angle" enter 030.00.00 and go, it will go to 180

I do not think a real world situation would have you entering data like that. It would be either all degrees or divisions.
And if you have too switch , reboot and start fresh.

I did enter 10.00.00 and it went 10 and then reentered 30 and it went another 30 to 40 so that works fine.

"Home" works good. If you do not set a home position it will go to where it was when you booted up.

Very,very nice Rod !! well done.

Scott

Scott, thanks I'll have a look. I'm trying to keep the steps and angles remembered between the #steps and Angle functions so I don't have to write separate stepping routines for each method (to save memory). I will have missed a conversion somewhere. I thought I'd got them all.

Great to know we have one actually driving a rotary table :)
 
I'm not having a problem with the LCD, it displays the menu options and I can set the # of divisions. Just the stepper not working. I can hear the stepper buzz, and it kinda twitches when the movement ends.
I guess if I want it to work, I need to go through both sketches side by side and find where the settings are different for the stepper.

Chuck

Chuck, I think you'll have the speed/frequency configuraton in the #defines set too fast for your stepper. I've got it set for 2000 steps per stepper revolution. If you have a conventional stepper driver (like the Polou) you need to make some changes.

ie here
Code:
#define STEPPER_STEPS_REV 200 // The number of steps per stepper
#define MICRO_STEPS 10        // set to 1 if not not using a micostepper driver, otherwise set to # microsteps
#define DIVIDE_RATIO 90       // The Dividing table ratio (eg 40 or 90)

probably here, where I changed it to 1 for you
Code:
#define MICRO_STEPS 1        // set to 1 if not not using a micostepper driver, otherwise set to # microsteps#define MICRO_STEPS 10        // set to 1 if not not using a microstepper driver, otherwise set to

Once you get this right, if you still have a problem, increase this number to slow down the stepper (eg. Increase the time between stepper pulses).

Code:
long TIMER_DELAY = 80;
 
Chuck

Pin 3 is being used already by something else. By you trying to use it as well is a "conflict" it is not going to work correctly.
You won't find the pin conflict in the sketch. It is in the LCD library and cpp file.

I do not know enough about this stuff to know if you can alter that library without major issues.

I think you would be much better off moving the step pin to pin 1.

Scott

Correct, the pins used by the Freetronics board are:
3, 4, 5, 6, 7, 8, 9 and Analog 0

This meant I had to move one of the stepper signals off Pin 3
 
Thanks for this Rod Thm:Thm:

do we still have to import the LCD library from post 20

cheers

Luc

Luc, you only need to import the additional libraries once. If you've done it before, you don't need to do it otherwise, yes do it. My edited post #1 will clarify this.

PS the compiler will be very unhappy and tell you if code is missing via a stream of errors...:eek:
 
Hi Rod

I ran into a error when trying to move a specified 30 degrees. It was turning 180.
Scott


Scott, it will be a while before I can test this with a stepper but for now, try replacing enterDegrees() with this:
Code:
void enterDegrees(void)
{
  int event = LCD_BUTTON_NONE;
  float tmpSTEPS_PER_REV = (float)STEPPER_STEPS_REV * (float)MICRO_STEPS * (float)DIVIDE_RATIO;
  angleField.setValue(mAngle);
  if(mAngle){
     divisions = (long)((float) MINUTES_IN_CIRCLE / (float) mAngle); 
     stepsPerDiv = (long)(tmpSTEPS_PER_REV *((float)mAngle/(float)MINUTES_IN_CIRCLE));
  }   
  else{
     divisions = 0L;  
     stepsPerDiv = 0L;
  }
  angleForm.defaultField();
  angleForm.show();
  while(event!= LCD_BUTTON_SELECT){
    event = lcd.getButton();
    if(event == LCD_BUTTON_SELECT)
      break;
    if (angleForm.dispatch(event) == FORM_CHANGED) {
        if (angleForm.isCurrent(angleField)) {
          // set the number of divisions here
          mAngle = angleField.value();
          stepsPerDiv = (long)((float)tmpSTEPS_PER_REV *((float)mAngle/(float)MINUTES_IN_CIRCLE));
          divisions = (long)((float) MINUTES_IN_CIRCLE / (float) angleField.value()); 
        }
    }
  }
  if(mAngle)
    goDivide(angleField.value());
}

Looks like I was not initialising stepsPerDiv on entry to agree with the angle and I've also changed the code to make sure STEPS_PER_REV is a float before it it used
 
Correct, the pins used by the Freetronics board are:
3, 4, 5, 6, 7, 8, 9 and Analog 0

This meant I had to move one of the stepper signals off Pin 3

Is it the pin (red)?

// Pins in use
#define BUTTON_ADC_PIN A0 // A0 is the button ADC input
#define LCD_BACKLIGHT_PIN 3 // D3 controls LCD backlight
// ADC readings expected for the 5 buttons on the ADC input
#define RIGHT_10BIT_ADC 0 // right
#define UP_10BIT_ADC 145 // up
#define DOWN_10BIT_ADC 329 // down
#define LEFT_10BIT_ADC 505 // left
#define SELECT_10BIT_ADC 741 // right
#define BUTTONHYSTERESIS 10 // hysteresis for valid button sensing window
//return values for ReadButtons()
#define BUTTON_NONE 0 //
#define BUTTON_RIGHT 1 //
#define BUTTON_UP 2 //
#define BUTTON_DOWN 3 //
#define BUTTON_LEFT 4 //
#define BUTTON_SELECT 5 //
//some example macros with friendly labels for LCD backlight/pin control, tested and can be swapped into the example code as you like
#define LCD_BACKLIGHT_OFF() digitalWrite( LCD_BACKLIGHT_PIN, LOW )
#define LCD_BACKLIGHT_ON() digitalWrite( LCD_BACKLIGHT_PIN, HIGH )
#define LCD_BACKLIGHT(state) { if( state ){digitalWrite( LCD_BACKLIGHT_PIN, HIGH );}else{digitalWrite( LCD_BACKLIGHT_PIN, LOW );} }
/*
 
Rod
I must be real stupid can't fixe that LCD error:wall::wall::hDe::hDe::wall::wall:

can you walk me thrue this PLZ

Luc

Which LCD error?

Try this.
1. Download LCD.zip
2. Unzip
3. Manually move the folder to your Arduino Library folder.
4. Restart the Arduino IDE

In my system, the library is in
\Documents\Arduino\libraries
 
Is it the pin (red)?

// Pins in use
#define BUTTON_ADC_PIN A0 // A0 is the button ADC input
#define LCD_BACKLIGHT_PIN 3 // D3 controls LCD backlight
// ADC readings expected for the 5 buttons on the ADC input
#define RIGHT_10BIT_ADC 0 // right
#define UP_10BIT_ADC 145 // up
#define DOWN_10BIT_ADC 329 // down
#define LEFT_10BIT_ADC 505 // left
#define SELECT_10BIT_ADC 741 // right
#define BUTTONHYSTERESIS 10 // hysteresis for valid button sensing window
//return values for ReadButtons()
#define BUTTON_NONE 0 //
#define BUTTON_RIGHT 1 //
#define BUTTON_UP 2 //
#define BUTTON_DOWN 3 //
#define BUTTON_LEFT 4 //
#define BUTTON_SELECT 5 //
//some example macros with friendly labels for LCD backlight/pin control, tested and can be swapped into the example code as you like
#define LCD_BACKLIGHT_OFF() digitalWrite( LCD_BACKLIGHT_PIN, LOW )
#define LCD_BACKLIGHT_ON() digitalWrite( LCD_BACKLIGHT_PIN, HIGH )
#define LCD_BACKLIGHT(state) { if( state ){digitalWrite( LCD_BACKLIGHT_PIN, HIGH );}else{digitalWrite( LCD_BACKLIGHT_PIN, LOW );} }
/*

Yes, I started using pins 2&3 like Chuck when I first started with steppers but as soon as I added the LCD shield, I had a conflict so moved the signal on pin 3 to pin 1 and my code will always reflect that change.

If your backlight is on a different pin, change the #define you've highlighted.
 

Latest posts

Back
Top