Very short programm for a rotary table

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.

reloader

Member
Joined
Mar 12, 2021
Messages
19
Reaction score
4
Location
Germany
Hello,

As I told before, I am very new to the Arduino project and I was very impressed by the high complex sketches of people that built an arduino controlled rotary table.

I decided, that it would be nice to have a short program to run my table.

Starting with accellstepper, I think, this is a very helpful program to run a stepper motor with smooth acceleration and decelleration.

Below you will find my short and cheap program, including a remote control for forward and backward steps.
The disadvantage of this program is, that you have to change the steps in the program and it has no step corrections.
Also you must calculate how many steps you need for your division.
But I am sure, that I can improve this program with some mor experience:


#include <AccelStepper.h>
#include "IRremote.h"
int receiver = 2;
/*----- Variables, Pins -----*/

#define STEPPER1_DIR_PIN 9
#define STEPPER1_STEP_PIN 8


/*-----( Declare objects )-----*/

AccelStepper stepper1 (AccelStepper::DRIVER,STEPPER1_STEP_PIN,STEPPER1_DIR_PIN);
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'

void setup()
{
irrecv.enableIRIn(); // Start the receiver
stepper1.setMaxSpeed (3000);
stepper1.setAcceleration(1000);



}

void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?

{
switch(results.value)

{
case 0xFF30CF: // VOL+ button pressed
stepper1.moveTo(3200);
while (stepper1.distanceToGo () !=0)

stepper1.run();
stepper1.setCurrentPosition(0);
break;
case 0xFF18E7:
stepper1.moveTo(-3200);
while (stepper1.distanceToGo () !=0)
stepper1.run ();
stepper1.setCurrentPosition(0);
break;}







irrecv.resume(); // receive the next value

digitalWrite(8,LOW);
digitalWrite(9, LOW);
}


}/* --end main loop -- */
 
Hi Reloader, thanks for your post. I am interested in the remote aspect. Do you have any pictures of your setup? I don't see anything in the code about a display so do you keep track of things using the graduations on the table? Looking forward to more, Cheers, Peter.
 
Hello,

as I told before, I am a bloody beginner. I bought an arduino kit from Elegoo. In this kit is a cheap IR remote sender and a IR receiver device.

All the rotary table programs I have seen here are open loop programs. So you have to trust your strong stepper. But you can test the program by running a full circle. The advantage of the Accellstepper library is, that it will run the stepper until all steps are done. Attached you will find a picture of my construction with the little IR receiver just above the red USB cable.
The program works, but I will give the construction with the 4*4 pad a chance. It looks much more comfortabele for me.

best regards

Edgar
Rundtisch.jpg
 
Hello,

as I told before, I am a bloody beginner. I bought an arduino kit from Elegoo. In this kit is a cheap IR remote sender and a IR receiver device.

I'm a beginner too with Arduinos. In your sketch you have two "include" statements, one surrounded by < > and the other in quotes. Some of my programs will not work with the includes in quotes but will if I have them in < >. I don't know why. I've copied some examples to modify and sometimes they work and sometimes not at all.
 
Hello,

thankes for your advice. I made some changes to this program and defined the steps to run as steppo.
So I have only to change steppo to change the steps to run.
I will check, if my program still runs without the <>.

best regards

Edgar
 
In theory, <> is used to include headers/files that are stored in a central location (or at least in a location that the system knows to check), while "" is used to include files in the local project directory.
 
Back
Top