Project of the Month built by driller1432

Help Support Home Model Engine Machinist by donating using the link above or becoming a Supporting Member.
Home Model Engine Machinist > CNC and 3-D Printers > Software and Programming > Interrupt Driven Rotary Table controller

Reply
 
Thread Tools
Old 02-14-2017, 11:14 PM   #11
Johno1958
HMEM_SUPPORTER.png
 
Johno1958's Avatar
 
Join Date: Sep 2015
Location: Bendigo Australia
Posts: 62
Liked 24 Times on 13 Posts
Likes Given: 239

Default

Hi Rodw.
First of all thank you for all the time and effort documenting a great program.
That said I can't for the life of me get it to work lol. I am using Saintsmart uno and 1602 lcd six button shield and a tb6560 driver. I can load the sketch no worries but I dont seem to be able to get the driver part working. I have the liming sketch up and running ok. My question is I can't seem to find a wiring diagram .Is there one posted?
Cheers
john


Johno1958 is offline  
 
Reply With Quote
Old 02-15-2017, 09:35 AM   #12
rodw
 
Join Date: Dec 2012
Posts: 1,046
Liked 311 Times on 242 Posts
Likes Given: 161

Default

Quote:
Originally Posted by Johno1958 View Post
Hi Rodw.
First of all thank you for all the time and effort documenting a great program.
That said I can't for the life of me get it to work lol. I am using Saintsmart uno and 1602 lcd six button shield and a tb6560 driver. I can load the sketch no worries but I dont seem to be able to get the driver part working. I have the liming sketch up and running ok. My question is I can't seem to find a wiring diagram .Is there one posted?
Cheers
john
John, first of all, I have never used the Sainsmart but a few people have used it with this sketch. I think that you may need to modify the LCD library in the keyboard sensing code and its been documented bys others in my other thread linked to in the first post. However by the sounds of it you have got this part working. If the displays and menus work, it will be fine!

So its always best to start with basics in the Arduino core library before you use a complex program. Maybe this one. https://www.arduino.cc/en/Reference/Stepper

So once you know you have a working stepper driver, install my sketch and configure the settings including the step and direction pins in the setup menu. If you have not done that, it probably is the reason why nothing moves.

There is not much to the wiring. step+ and dir+ go to the relevant digital pins and step- and dir- go to the Arduino ground. Attach the high voltage for the stepper to your controllers stepper power terminals. I'm not sure of the TB6660
but in some cases you need active low wiring so check your documentation. I've never had to do that with the Arduino though.


__________________
RodW
Brisbane, Australia
vehiclemods.net.au
rodw is offline  
 
Reply With Quote
Old 02-15-2017, 07:41 PM   #13
Johno1958
HMEM_SUPPORTER.png
 
Johno1958's Avatar
 
Join Date: Sep 2015
Location: Bendigo Australia
Posts: 62
Liked 24 Times on 13 Posts
Likes Given: 239

Default

Hi Rod
Yes you are right .I never configured the step and dir pins. I will read through your thread again as I glossed over a lot of parts which were flying well over my head.
I do find this project very interesting.
Thanks
John

Last edited by Johno1958; 02-15-2017 at 07:45 PM.
Johno1958 is offline  
 
Reply With Quote
Old 02-15-2017, 08:53 PM   #14
rodw
 
Join Date: Dec 2012
Posts: 1,046
Liked 311 Times on 242 Posts
Likes Given: 161

Default

Quote:
Originally Posted by Johno1958 View Post
Hi Rod
Yes you are right .I never configured the step and dir pins. I will read through your thread again as I glossed over a lot of parts which were flying well over my head.
I do find this project very interesting.
Thanks
John
Glad you got it going.
__________________
RodW
Brisbane, Australia
vehiclemods.net.au
rodw is offline  
 
Reply With Quote
Old 06-29-2017, 10:03 AM   #15
rodw
 
Join Date: Dec 2012
Posts: 1,046
Liked 311 Times on 242 Posts
Likes Given: 161

Default

Hmm Captain_Obvious reported a not so obvious bug in my software that bit where a rotary table has a coarse resolution. Where say a division required say 100.333 steps per division, the number was rounded to 100.0. This meant on say 36 divisions around a complete circle, the final division could end up being 12 steps short.

I don't currently have any working hardware to test this on but I know it compiles.

Here is a replacement GoDivide procedure. Can those using this sketch cut and paste this into your config to replace the existing goDivide procedure and see if it is working correctly?

Code:
void goDivide(long gAngle)
{
   long thisDiv = 1; 
   int event = LCD_BUTTON_NONE;
   int flag = 0;
   float tmpSTEPS_PER_REV = (float)globals.stepsPerRev;
   float remainder;
   float divLeftOver = 0.0;
   long adjustSteps = 0;
   
   stepsPerDiv = (long)(tmpSTEPS_PER_REV *((float)gAngle/(float)MINUTES_IN_CIRCLE));
   remainder = (float) (tmpSTEPS_PER_REV *((float)gAngle/(float)MINUTES_IN_CIRCLE));
   remainder -= (float)stepsPerDiv;
   divisions = (long)((float) MINUTES_IN_CIRCLE / (float) gAngle);
   printDivideVals(thisDiv,gAngle);
   while(event != LCD_BUTTON_SELECT){
      event = lcd.getButton();
      switch(event){
        case LCD_BUTTON_LEFT:
          flag++;
          thisDiv--;
          divLeftOver -= remainder;
          if(thisDiv < 1)
            thisDiv = divisions;
          digitalWrite( globals.DirPin, ANTICLOCKWISE );
          break;
        case LCD_BUTTON_RIGHT:
          flag++;
          thisDiv++;
          divLeftOver += remainder; 
          if(thisDiv > divisions)
            thisDiv = 1;          
          digitalWrite( globals.DirPin, CLOCKWISE );
          break;       
    }
    if(flag){ 
      if(abs(divLeftOver) >= 1.0){
        adjustSteps = 1;
        if(abs(divLeftOver) == divLeftOver)  
          divLeftOver -= 1.0;    // Positive value >= 1.0
        else
            divLeftOver += 1.0;  // Negative Value <= 1.0
      } else
          adjustSteps = 0;
    }   
    setSteps((stepsPerDiv + adjustSteps) * 2, 1);
    printDivideVals(thisDiv,gAngle);
    flag = 0;
  }
}
So what the code attempts to do is to now is to save the fractional steps in a variable called remainder (say 0.33 in our 100.33 example). This is accumulated in each step in the variable divLeftOver every time a division is made. If this variable is <= 1.0 or >=1.0, it is adjusted by 1.0 closer to zero and the number of steps in the current division is incremented by 1. That way, we should end up back on track when we complete a complete circle.

Please provide your feedback.
__________________
RodW
Brisbane, Australia
vehiclemods.net.au
rodw is offline  
 
Reply With Quote
Old 06-29-2017, 12:34 PM   #16
Captain_Obvious
 
Join Date: Jun 2017
Posts: 29
Liked 9 Times on 8 Posts
Likes Given: 12

Default

Hello again,

I tried the new script but I don't know what went wrong. As soon as I start the division or the angle program, the stepper motor just runs continuously, briefly stopping at the given number of divisions. None of the buttons do anything except for the reset button. I'm not anywhere near advanced enough to analyze to script myself. All the other functions work just like they did before.

Attached is the misbehaving script.
Attached Files
File Type: zip rotaryscript.zip (8.8 KB, 64 views)
Captain_Obvious is offline  
 
Reply With Quote
Old 06-30-2017, 03:27 AM   #17
Cogsy
 
Cogsy's Avatar
 
Join Date: Jul 2012
Location: Perth, Western Australia
Posts: 1,747
Liked 450 Times on 349 Posts
Likes Given: 441

Default

Hi Rod,
I don't have the hardware to test either, nor do I have a lot of experience programming in C but looking at the code in your if(flag) I saw this line: if(abs(divLeftOver) == divLeftOver) , which is comparing floats for equality. I realise it's the same variable and you're just taking the absolute value, but because of the abs function return I think you still run the normal risks of float equalities here. I've been stung by it before so it just sort of jumped out at me, so I thought I'd mention it.
__________________
Al.
______________________
I'd like to be a perfectionist, but I lack the patience...not to mention the skill...
Cogsy is offline  
 
Reply With Quote
Old 06-30-2017, 06:59 AM   #18
Foozer
HMEM_LIFETIMESUPPORTER.png
 
Join Date: Nov 2008
Location: Camano Island, WA
Posts: 1,102
Liked 74 Times on 66 Posts
Likes Given: 2

Default

Freetronics shield is ordered so can test it as you wrote it . . .
__________________
"Nothing is more irritating than that which exposes the pedigree of ideas"----Lord Acton----
Foozer is offline  
 
Reply With Quote
Old 06-30-2017, 08:31 AM   #19
rodw
 
Join Date: Dec 2012
Posts: 1,046
Liked 311 Times on 242 Posts
Likes Given: 161

Default

Guys, I'm not sure what I got wrong. I'll have another look at this. Cogsy, yes I hate working with floats too. What I wanted to do is to determine if divLeftOver is a positive or negative number and there are other ways to do that.

Before I started, I modified the code to eliminate a couple of lines of duplicated code so I might have then stuffed up the working code...
__________________
RodW
Brisbane, Australia
vehiclemods.net.au
rodw is offline  
 
Reply With Quote
Old 06-30-2017, 08:55 AM   #20
Captain_Obvious
 
Join Date: Jun 2017
Posts: 29
Liked 9 Times on 8 Posts
Likes Given: 12

Default

OK, no worries. I appreciate you taking the time to do this in the first place.


Captain_Obvious is offline  
 
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
My Second Rotary Table,80 mm table. gus Introduction 75 07-29-2014 08:36 PM
Kwackers CNC Rotary Table Controller chucketn Software and Programming 7 12-17-2012 01:51 PM
Help on a rotary table. Hilmar General Engine Discussion 11 08-03-2011 02:32 AM
Rotary Table Mutley General Engine Discussion 4 11-25-2009 09:16 PM
rotary table baldrocker Buy / Sell / Trade / eBay 3 12-17-2008 09:29 AM



Newest Threads






- Top - Member List