Jump to content
 

DCC Controlled (PECO) Turntable Project using a Arduino Uno


Recommended Posts

  • RMweb Gold

OK Geoff.

I can see what has happened. The turntable test routine is looking for a file 'Adafriut_PWMServoDriver.h' and the latest download reincarnation of the AdaFruit routines have renamed it to 'Adafriut_MS_PWMServoDriver.h'

 

So you have two choices.

1. change the line in the Turntable Test routine by inserting the '_MS' part to the include statement.

2. rename the two files removing the '_MS' part of the filename from the utility folder

 

I'd give 1. a try first. (You my have to also move the 'Utility' folder back to the Adafru...Library.)

 

Ray.

 

Thanks Ray. I will work through those and report back on the outcome.

 

Geoff

Link to post
Share on other sites

  • RMweb Gold

"redefinition of void setup()" means that you have two functions with the same name which is not allowed.

 

...R

 

I am sure you are right Robin but it means nothing to me I am afraid. All I thought I had done was as Ray suggested in the posts above. Thank you any way for your contribution which may help Ray to help me. I am putting folk to a lot of trouble with this I am sorry to say.

Thank you.

 

Geoff

Link to post
Share on other sites

Hi Geoff, looks like you've lost/corrupted the program. Go back to post 17, copy paste the code into a new file and edit the include line as 1. above i.e. insert  '_MS' and save.

 

Hope this helps.

 

Don't worry we'll get there............

 

Ray.

Edited by tender
Link to post
Share on other sites

  • RMweb Gold

Hi Geoff, looks like you've lost the program. Go back to post 17, copy paste the code into a new file and edit the include line as 1. above i.e. insert  '_MS' and save.

 

Hope this helps.

 

Don't worry we'll get there............

 

Ray.

 

Ok Ray will do. Should I delete any other references to Turntable test?

 

Thank you.

 

Geoff

Link to post
Share on other sites

  • RMweb Gold

Ok Ray will do. Should I delete any other references to Turntable test?

 

Thank you.

 

Geoff

 

Sorry Ray I still get an error as in post 427. Robin said that "redefinition of void setup()" means that you have two functions with the same name which is not allowed. Naturally I have no idea what that means.

 

Geoff

Link to post
Share on other sites

  • RMweb Gold

Not to me. Can you post the complete program as an attachment so I can look at it in my text editor?

 

...R

 

Here you go Robin. It is a copy and paste of Ray's programme from post 17 with the adjustment to the wording to include MS_ as suggested by Ray in post 425.

 

Geoff

PS I notice looking through it that the alteration to insert MS_ in the line "utility/Adafruit_PWMServoDriver.h"// Turntable test routine has not appeared even though I am sure I did it and saved it.

//
// Requires the Adafruit_Motorshield v2 library 
// And AccelStepper with AFMotor support 
 
// This sketch is for Adafruit Motorshield v2 only!
// Will not work with v1 shields
 
#include <AccelStepper.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"
 
Adafruit_MotorShield AFMStop(0x60); // Default address, no jumpers
 
// Connect stepper with 200 steps per revolution (1.8 degree)
// to the M3, M4 terminals (blue,yellow,green,red)
 
Adafruit_StepperMotor *myStepper2 = AFMStop.getStepper(200, 2);
 
// you can change these to SINGLE, DOUBLE, INTERLEAVE or MICROSTEP!
 
// wrapper for the motor! (3200 Microsteps/revolution)
void forwardstep2() {  
  myStepper2->onestep(FORWARD, MICROSTEP);
}
void backwardstep2() {  
  myStepper2->onestep(BACKWARD, MICROSTEP);
}
 
// Now we'll wrap the stepper in an AccelStepper object
 
AccelStepper stepper2(forwardstep2, backwardstep2);
 
 
void setup()
{  
  
  AFMStop.begin(); // Start the shield
  
  //configure pin3 as an input and enable the internal pull-up resistor
  pinMode(3, INPUT_PULLUP);
  //read the sensor (open collector type) value into a variable
  int sensorVal = digitalRead(3);
   
 
 
// step forward to sensor index point
  while (sensorVal == HIGH) {
    sensorVal = digitalRead(3);
    forwardstep2();
      delay(50);
  }
  delay(5000);
  
// set stepper speed, acceleration and position 
  stepper2.setMaxSpeed(50.0);
  stepper2.setAcceleration(10.0);
  stepper2.moveTo(800);  
  
}
 
void loop()
{
    // Change direction at the limits
 
    if (stepper2.distanceToGo() == 0)
       { delay(5000);
  stepper2.moveTo(-stepper2.currentPosition());
       }
 
    stepper2.run();
}void setup() {
  // put your setup code here, to run once:
 
}
 
void loop() {
  // put your main code here, to run repeatedly:
 

 

}
Link to post
Share on other sites

  • RMweb Gold

Ray, Robin, I have deleted the duplicated text in the programme and it has uploaded but my turntable is just gently oscillating back and forth a couple of degrees.

Partial success I think, at least it is not rattling away on the stepper test which it was before.

 

Geoff

Link to post
Share on other sites

Hi Geoff.

 

Yes, delete everything after stepper2.run();  and add a curly bracket so it looks like this:

 

stepper2.run();

 

}

 

If this compiles without errors and still oscillates a few degrees we probably need to check the wiring of the stepper motor.

Ray.

Link to post
Share on other sites

  • RMweb Gold

Hi Geoff.

 

Yes, delete everything after stepper2.run();  and add a curly bracket so it looks like this:

 

stepper2.run();

 

}

 

If this compiles without errors and still oscillates a few degrees we probably need to check the wiring of the stepper motor.

Ray.

 

Thanks Ray, that is what I had done and it compiled straight away but as you say left the turntable just oscillating a couple of degrees. I was really pleased to get that far and I cannot thank you and Robin enough. I have shut up shop for tonight but I will check the wiring tomorrow some time I hope.

Thank you so much for all the time you have given to this. I am sure I will be back here tomorrow with more questions.

 

Geoff

Link to post
Share on other sites

Ray, Robin, does this screen shot give any clues to the error?

 

Geoff

 

attachicon.gifScreenshot 2017-08-08 21.46.52.png

 

Hi Geoff,

Looks like you have two copies of Turntable_test. One in the libraries folder and one in the Adafruit.... folder. Check which one has the edits in and compiles without errors and delete the other.

Edited by tender
Link to post
Share on other sites

Hi Geoff.

I won't be around much until tomorrow evening so here's a picture of my Stepper motor wiring. Assuming you have the same motor this is how it should be wired.

 

post-11105-0-92260600-1502229900.jpg

 

 

Ray

 

PS, Just in case: Have you connected a 9-12 volt DC supply to the Power terminal of the Adafruit module

Edited by tender
Link to post
Share on other sites

  • RMweb Gold

Ray, I have a 12v supply to the adafruit board. I need to check the wiring of the motor, it is similar to yours but I cannot be sure of the exact order of the colours in relation to yours. I have just nipped up to the loft and checked it.The red and yellow are to M4 and the blue and green to M3. I see that differs from your wiring. I will swap them over tomorrow and see how I get on. When I have this all working how do I power the arduino without having the laptop hooked up to it?

 

Geoff

 

edit: the coax jack is not on the adafruit board, I used it to make an easy  connection from the power supply I am using.

Edited by geoff
Link to post
Share on other sites

  • RMweb Gold

Hi Geoff.

I won't be around much until tomorrow evening so here's a picture of my Stepper motor wiring. Assuming you have the same motor this is how it should be wired.

 

attachicon.gifIMG_0117.jpg

 

 

Ray

 

PS, Just in case: Have you connected a 9-12 volt DC supply to the Power terminal of the Adafruit module

 

Hello Ray,

I have reconnected the motor so that my connections accord with yours and after moving the working programme back into the Adafruit library I have the turntable rotating slowly, round and round but with the programme uploaded it does not stop at the sensor. I have adjusted the magnet to be as close to the wall of the well as I dare, the well is vacuum formed plastic and quite thin. The green wire from the sensor is connected via the DCC interface board to I/O3 on the Adafruit shield as per the diagram you posted earlier in this thread. More head scratching I think.

The attached photo was taken in the beginning of the construction and shows the motor wires incorrectly connected.

 

 

Geoff

post-224-0-71584600-1502285703.jpg

Link to post
Share on other sites

Yes Ray.

 

 

Ok, if you set the voltmeter to a DC range of 10volts or nearest equivalent and connect the negative probe to the GND connection and the positive probe to I/O3 on the Adafruit board you should see a reading of about 5 volts which should drop to near 0volts when the magnet is directly adjacent to the sensor. If this doesn't happen try turning the sensor around. If still no joy, remove the sensor and place a magnet directly on it and report back.

 

 

Ray.

Link to post
Share on other sites

  • RMweb Gold

Ok, if you set the voltmeter to a DC range of 10volts or nearest equivalent and connect the negative probe to the GND connection and the positive probe to I/O3 on the Adafruit board you should see a reading of about 5 volts which should drop to near 0volts when the magnet is directly adjacent to the sensor. If this doesn't happen try turning the sensor around. If still no joy, remove the sensor and place a magnet directly on it and report back.

 

 

Ray.

 

Will do Ray.

 

Geoff

Link to post
Share on other sites

  • RMweb Gold

Ok, if you set the voltmeter to a DC range of 10volts or nearest equivalent and connect the negative probe to the GND connection and the positive probe to I/O3 on the Adafruit board you should see a reading of about 5 volts which should drop to near 0volts when the magnet is directly adjacent to the sensor. If this doesn't happen try turning the sensor around. If still no joy, remove the sensor and place a magnet directly on it and report back.

 

 

Ray.

 

Ray, I have checked the voltage which is 4.95v and while the turntable is rotating past the sensor this doesn't change. I removed the sensor and held the turntable deck with the magnet 2 or 3mm away from the sensor face which had been fixed to the outside of the well and the voltage dropped away to almost zero. 

 

Geoff

Link to post
Share on other sites

Ray, I have checked the voltage which is 4.95v and while the turntable is rotating past the sensor this doesn't change. I removed the sensor and held the turntable deck with the magnet 2 or 3mm away from the sensor face which had been fixed to the outside of the well and the voltage dropped away to almost zero. 

 

Geoff

 

 

OK Geoff, Looks like the sensor is working ok so you should be able to get the voltage to drop to almost zero with the magnet on the turntable deck and the sensor on the outside of the well. Try with the sensor the other way around. Have another look at post 4 for reference. Are you using the PECO turntable?

 

Ray.

Link to post
Share on other sites

  • RMweb Gold

Ok Ray, I think I have sorted it. I set the turntable going and held the sensor in a slightly different position and the table rotated to it and then stopped and reversed. I will disconnect the motor, refix the sensor and give it another go.

 

Geoff

 

remix not remix

Edited by geoff
  • Like 1
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...