Arduino UNO brass annealer project help.....

Howdy from Texas,

I am working on building a brass annealing machine.

It will basically be a rotating wheel with 4 holes in it that will rotate, pickup a piece of brass, rotate the brass in the flame (pause for a certain time in flame) then advance starting the whole process over.

I am new to the Arduino, I have programmed PLC's and VFD's but all the ones I have dealt with have all been in ladder logic so I do not really have any experience with the programming language. I have been reading and reading but am still not far enough along. My UNO and other parts should be here next week.

I got an UNO starter kit, LCD, Motor shield, and stepper motor.

I am setting the drive up with a 8:1 gear reduction

Here is what I have started on the code but I still keep getting error after error.

I was going to start with 4 switches for different brass and one switch for a manual operation. Eventually I want to setup the LCD so it displays the brass caliber, programmed time, and countdown time in flame.

The other calibers I just need to cut and paste, change the time in flame and the digital input to operate that set of parameters.

Ok so where can I learn additional information on getting this pulled off? My first milestone is just to get it to function, adding the LCD, the Jog button with timing feature in the future will just be icing on the cake....

Thanks in advance for the help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

/*
AUTOMATED CASE ANNEALER
push button to operate function
rotate carriage
time in flame
rotate carriage
different settings for each case
display case and time in flame on display
differnt cases select different switch to set differnt time

Created 8 March 2014
Modified 9 March 2014
Jake Freese
*/

#include <Stepper.h>
#include <LiquidCrystal.h>

//motor 200 steps per revolution
#define STEPS 200
//bipolar stepper motor 4 pins
#define motor pin1 8
#define motor pin2 9
#define motor pin3 10
#define motor pin4 11
//button is setup for each caliber
#define button 3
#define button 4
#define button 5
#define button 6
#define button 7
//button 7 will be for manual jog and timing
#define loop
#define high

const int stepsPerRevolution = 200;
// intalize the stepper library on pins 8 through 11
Stepper MyStepper (200, 8, 9, 10, 11);
//button to operate unit for specific caliber

//initial step count
int stepCount = 0;
//jog speed between time in flame
int setSpeed(240);
//jog distance
int Steps(800);
//time in flame 308 caliber
delay (400);
//display caliber set for, time set, countdown time

//loop as long as button is depressed

I was attempting to use the loop function when the button is closed but I keep getting errors and it is looking like the loop is not the proper function.

I keep getting errors

And we have to figure out what they are?

Please use code tags when posting code, and post all your code, not just snippets.

Thanks AWOL

/*
AUTOMATED CASE ANNEALER 
push button to operate function
rotate carriage
time in flame
rotate carriage
different settings for each case
display case and time in flame on display
differnt cases select different switch to set differnt time

Created 8 March 2014
Modified 9 March 2014
Jake Freese
*/

#include <Stepper.h>
#include <LiquidCrystal.h>

//motor 200 steps per revolution
#define STEPS 200 
//bipolar stepper motor 4 pins
#define motor pin1 8
#define motor pin2 9
#define motor pin3 10
#define motor pin4 11
//button is setup for each caliber
#define button 3 
#define button 4
#define button 5
#define button 6
#define loop 
#define high 


    const int stepsPerRevolution = 200;
// stepper settings and pin location
    Stepper MyStepper (200, 8, 9, 10, 11);
//button to operate unit for specific caliber

  int pin = 3

  pinmode(3,INPUT);
   
//loop as long as button is depressed
   loop (3,HIGH)
//initial step count 
    int stepCount = 0;
//jog speed between time in flame
    int setSpeed(240);
//jog distance
    int Steps(800);
//time in flame 308 caliber
    delay (400);
    
//display caliber set for, time set, countdown time

Here is my list of errors. I am going to have to go back to the C++ tutorials this is kicking my butt........

In file included from annealer.ino:36:
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Arduino.h:118: error: expected unqualified-id before 'void'
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Arduino.h:118: error: expected )' before 'void' annealer:43: error: expected ',' or ';' before 'pinmode' annealer:46: error: expected unqualified-id before numeric constant annealer:46: error: expected )' before numeric constant
annealer:54: error: expected constructor, destructor, or type conversion before '(' token

I sure wish there was a way to display the code line number on the side of the editor so I could just glance down instead of having to click or arrow key up or down to figure out what line is screwed up.

The first error is simply a missing semicolon on this line:

  int pin = 3

However, you're then trying to execute a pinmode command outside of any function. Take a look at the examples that come with the IDE and see how the setup and loop functions are used in arduino sketches.

Thanks WildBill I will get looking over those.

"sure wish there was a way to display the code line number on the side of the editor so I could just glance down instead of having to click or arrow key up or down to figure out what line is screwed up"

If you place the cursor on the error messave, doesnt the ide highlight the erring line in the source??

Well I got the rest of the code written and it is happy with it.

But........

When it powers up it steps the 400 steps and then it is done.

My intention was for it run when the button is depressed it will advance the stepper motor, then wait, then advance the stepper and continue as long as the button is depressed.

How do I need to better approach this to get the desired function??

Thanks!

void loop() {
  // 308 settings
    while (digitalRead(buttonPinA1) == HIGH)
  // loop while button pressed
   Serial.println("308");
  // number of steps required to index
  myStepper1->step(400, FORWARD, SINGLE);
  // time in flame 
  delay(400);

jakefreese:
My intention was for it run when the button is depressed it will advance the stepper motor, then wait, then advance the stepper and continue as long as the button is depressed.

void loop() {

// 308 settings
    while (digitalRead(buttonPinA1) == HIGH)
  // loop while button pressed
   Serial.println("308");
  // number of steps required to index
  myStepper1->step(400, FORWARD, SINGLE);
  // time in flame
  delay(400);

In that case it would make more sense for the while loop to extend to after the delay.

void loop()
{
   // 308 settings
    while (digitalRead(buttonPinA1) == HIGH)      // loop while button pressed
    {
      Serial.println("308");
      // number of steps required to index
      myStepper1->step(400, FORWARD, SINGLE);
      // time in flame 
      delay(400);
    }

Thanks Peter,

That got me closer, I still have not been able to get my command inputs to work properly, I was attempting to utilize the analog inputs for this as digitals. But what I have tried has not worked so far. I was numbering them 14-19 like I found in another post but still no work...

/*
automated annealer
button 14 for 308
button 15 for 22-250
button 16 for 6XC
button 17 for 260

Jake Freese 
      3/10/14
EDIT  3/22/14

*/

#include <Adafruit_Sensor.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include <Adafruit_MotorShield.h>
#include <AccelStepper.h>
#include <Wire.h>
#include "utility/Adafruit_PWMServoDriver.h"

Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 

Adafruit_StepperMotor *myStepper1 = AFMS.getStepper(200, 2);

void forwardstep1() {  
  myStepper1->onestep(FORWARD, SINGLE);
}
void backwardstep1() {  
  myStepper1->onestep(BACKWARD, SINGLE);
}
AccelStepper AStepper1(forwardstep1, backwardstep1);

 
// button 2 for 308 caliber
const int buttonPin14 = 14;
// button 3 for 22-250 caliber
const int buttonPin15 = 15;
// button 4 for 6XC caliber
const int buttonPin16 = 16;
// button 5 for 260 caliber
const int buttonPin17 = 17;

void setup() 
{
   Serial.begin(9600);
    pinMode (14, INPUT);
    pinMode (15, INPUT);
    pinMode (16, INPUT);
    pinMode (17, INPUT);
 
    AFMS.begin();
  // set the speed at 120 rpm:
 myStepper1->setSpeed(120);
}
  
void loop() {
  {// 308 settings
    while (digitalRead(14) == HIGH)
  // loop while button pressed
   Serial.println("308");
  // number of steps required to index
  myStepper1->step(400, FORWARD, SINGLE);
  // time in flame 
  delay(4000);
  }
  {//22-250 settings
    while (digitalRead(15) == HIGH)
  // loop while button pressed
   Serial.println("22-250");
  // number of steps required to index
  myStepper1->step(400, FORWARD, SINGLE);
  // time in flame 
  delay(3000);
  }
  {//6XC settings
    while (digitalRead(16) == HIGH)
  // loop while button pressed
   Serial.println("6XC");
  // number of steps required to index
  myStepper1->step(400, FORWARD, SINGLE);
  // time in flame 
  delay(3250);
  }
  {//260 settings
    while (digitalRead(17) == HIGH)
  // loop while button pressed
   Serial.println("260");
  // number of steps required to index
  myStepper1->step(400, FORWARD, SINGLE);
  // time in flame 
  delay(3750);
  }
  }

I got it closer but now the functionality is still not there.

If you put pin 14 high the ( analog A0) I still do not get the advance of the stepper and wait. I have been looking through some of the examples and other projects to see if I can figure out where I have gone wrong, but still have not gotten it ironed out.

Thanks again for the help!

Your code indentation is horrible - please use the IDE autoformat option to fix it.

Your while loops are all wrong:

  {//22-250 settings
    while (digitalRead(15) == HIGH)
  // loop while button pressed
   Serial.println("22-250");
  // number of steps required to index
  myStepper1->step(400, FORWARD, SINGLE);
  // time in flame 
  delay(3000);
  }

The { and } need to come after the 'while' clause. The while statement controls the execution of a single following statement. The { and } form a compound statement containing all the code between them. If you omit them, only the first statement after the while clause is executed.

I suggest you look again at the code I posted and compare it to what you have implemented.