ooooooh I think Gary and Toto will be hiding in a corner hoping the images fade from thier view - ludities I had seen the Ally Channels on youtube as well, very neat and simple idea. After Viccy Road has completed the Dundee and Elgin exhibitions, I'm tempted to replace the seeps with servo's, only 6 would be required and I have them already. It would require me changing the DCC accesory decoders - currently MERG DCC accesory decoder (Pulsed output) for either the steady state output version plus the servo4 controller or an arduino set up as dcc servo controller or the MERG CBUS equivalents. Decisions decisions Looking forward to the next installment Bob Paul
Hi all I don't know if anyone is interested in the next part of my Kyle build. This will be a DCC Arduino operated turntable. If so should I post the build here or somewhere else. Thanks Bob
Hi Bob Looking forward to it. I don't know how far you have got, so not sure if this will be of any help - I did a stepper tutorial as part of the Arduino 101 series, and has some basic code for a traverser. http://platform1mrc.com/p1mrc/index.php?threads/arduino-101-lesson-3.2362/ Paul
Hi Bob, You could post it here or under DCC control. Wherever you prefer it. I'l look forward to seeing it come together. Cheers Toto.
Hi Paul I have got on pretty well thanks. I did read your 101 and found it very helpful. Hi Toto I will post it here if that's OK it will keep the Kyle build all together. Thanks Bob
Turntable Build Part One Parts Used So I am using the following: 1 x Peco LK55 00/H0 turntable. https://tinyurl.com/ycxbqyop 1 x DCC Interfaces DCC turntable board 1 x ArduinoNano https://www.dccinterface.com/shop/ A RS Components SR 15C-A3 Hall effect sensor RS Part number 370-6896 A Powerful Magnet https://tinyurl.com/ybntb74e 2 Pieces of 5 mm thick acrylic https://tinyurl.com/y78z6ekq 1 x 60 tooth gear RS Part number 286-5720 1 x 10 tooth gear RS Part number 744-946 1 x timing belt 102 teeth 510 long RS Part number 474-5583 2 x miniature ball bearings 8mm in dia 22 out dia RS Part number 618-9957 3 x M4 countersunk 35 mm long machine screws washers and nuts https://tinyurl.com/ya3yzmcy 3 x Circuit board standoffs https://tinyurl.com/y7ebrqqk Plus 3 x 3d Printed columns and one base bearing holder print. The links are where I got my Parts from, there are obviously many other places to get them from. Thanks Bob
Part Two First can I thank Ray (Tender) on RMWeb for the time and effort he has put into the following topic. https://tinyurl.com/ybduy5kj Which gave my idea to build on. And also to Paul for his Arduino 101. And for Ian at DCC Interface.com for his excellent products and his help. Kyle used only one feed to the turntable as in this diagram. So I will only need to have one front station entry and one back station entry. But I will show how to to modify the program enable as many roads as you need on your layout. The first thing to find out was how I was going to fix the turntable base to the layout. I wanted to be able to remove the table as easily as possible. So I decided that all the mechanics and electrics are mounted on a base fitted to the table. I then cut the hole in the layout this was 310mm Dia. and had a recess built in to let the table be flush to the layout. As in the diagram below. Thanks Bob
Part Three Next I drilled three M4 holes and countersunk them at the drain cover indentations. These holes are at a 150 mm dia. Circle. Then made the acrylic parts for the mounting plates. As in this picture I am lucky enough to have a cnc laser cutter (bought off Ebay in a dead state, very cheap). So I cut the acrylic on this machine. I will make the DXF files available to anyone that would like them. The eagle eyed among you may have seen that the circular acrylic is actually Two 2mm thick discs as I ran out of 5mm thick stock. The bearings are just pressed in.
PART FIVE As I said before I am using a DCC interface board. This board uses an Arduino Nano and a A4988 motor driver board. I had before discovering Ian’s web site already got a Arduino Uno and a A4988 driver board running a bipolar stepper motor after adapting Tender’s programme on RMWeb http://www.rmweb.co.uk/community/in...d-peco-turntable-project-using-a-arduino-uno/ This is the circuit that he was using. As I did not have an Adafruit motor controller but I did have a Pololu A4988 I had to change the circuit to match. Here is a block diagram of the circuit And here is the fritzing circuit I then discovered Ian’s DCCinterface.com board and to save time and trouble of making my own I bought one his boards. This board incorporates all the parts that I had already got working on a breadboard. (Except for one mod I had to make because of the sensor I was using).
PART SIX This is how the A4988 is connected to the rest of the circuit. The connections are as follows A4988 Nano STEP D4 DIR D5 EN D6 VDD 5V GND GND This is the table of microsteps for the A4988 The top row of the 5×2 pin headers (on the DCC INTERFACE BOARD) are connected to +5v.(nearest pins to the bottom of the picture below) the bottom row are connected to the A4988 pins ( Sleep, Reset, MS1, MS2, MS3). With no jumpers connected, MS1, MS2 and MS3 are in the LOW position ( in relation to the table below). To set a MicroStepping to high, use a jumper to connect the A4988 pin to +5v – hence making it HIGH. E.g. for Eighth Step – place a jumper on MS1 and 5v , and MS2 and 5v. For Full steps, place no jumpers. I set mine to MS2 High = Quarter Step Important : Make sure there is a jumper between the SLEEP and RESET pins. As in the following picture
Niiiiiiice On the arduino which Stepper library are you going to use ? Have you looked at the AccelStepper library - this will give a ramp up and down (accelerate / decelerate) automatically without you having to calculate the values. Also move to value X, it knows its current position so will calculate the distance and direction (and the accel / decel). I have used this library with the traversers and is compatible with the A4988 controller (its the same controller in the big easy driver). Paul
PART SEVEN The modification I mentioned in the last part is that the sensor I am using needs to have a 10K pullup resistor fastening the signal out pin to 5Volts. I just fastened this to the leads on the connector as the following picture. The other modification was to the programme as this sensor goes LOW so the programme needs to change from HIGH to LOW. So here is the Arduino programme straight of the DCC site. Thank you Ian. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // DCC Stepper Motor Controller ( A4988 ) Example // See: https://www.dccinterface.com/how-to/assemblyguide/ // // Author: Alex Shepherd 2017-12-04 // // This example requires two Arduino Libraries: // // 1) The AccelStepper library from: http://www.airspayce.com/mikem/arduino/AccelStepper/index.html // // 2) The NmraDcc Library from: http://mrrwa.org/download/ // // Both libraries can be installed via the Arduino IDE Library Manager // #include <AccelStepper.h> #include <NmraDcc.h> // Uncomment to enable Powering-Off the Stepper if its not running #define STEPPER_ENABLE_PIN 6 // Home Position Sensor Input #define HOME_SENSOR_PIN 3 typedef struct { int address; int stationFront; int stationBack; } DCCAccessoryAddress; DCCAccessoryAddress gAddresses[2]; // for a 1.8 deg stepper, there are 200 full steps #define FULL_STEPS_PER_REVOLUTION 200 // Uncomment the lime below for the Driver Board Settings //#define FULL_TURN_STEPS (FULL_STEPS_PER_REVOLUTION) // full steps //#define FULL_TURN_STEPS (FULL_STEPS_PER_REVOLUTION * 2) // 1/2 steps #define FULL_TURN_STEPS (FULL_STEPS_PER_REVOLUTION * 4) // 1/4 steps //#define FULL_TURN_STEPS (FULL_STEPS_PER_REVOLUTION * 8) // 1/8 steps //#define FULL_TURN_STEPS (FULL_STEPS_PER_REVOLUTION * 16) // 1/16 steps // home location #define entryStation FULL_TURN_STEPS / 3 volatile bool bInterruptDetected = false; bool bHomePositionFound = false; // Now we'll wrap the stepper in an AccelStepper object AccelStepper stepper1(1, 4, 5); NmraDcc Dcc ; uint16_t lastAddr = 0xFFFF ; uint8_t lastDirection = 0xFF; // // Decoder Init // void ConfigureStations() { // this is home gAddresses[0].address = 200; gAddresses[0].stationFront = entryStation; gAddresses[0].stationBack = entryStation + (FULL_TURN_STEPS / 2); gAddresses[1].address = 201; gAddresses[1].stationFront = ((FULL_TURN_STEPS / 3) * 2); gAddresses[1].stationBack = ((FULL_TURN_STEPS / 3) * 2) + (FULL_TURN_STEPS / 2); } // This function is called whenever a normal DCC Turnout Packet is received void notifyDccAccTurnoutOutput( uint16_t Addr, uint8_t Direction, uint8_t OutputPower ) { Serial.print("notifyDccAccTurnoutOutput: ") ; Serial.print(Addr,DEC) ; Serial.print(','); Serial.print(Direction,DEC) ; Serial.print(','); Serial.println(OutputPower, HEX) ; for (int i = 0; i < (sizeof(gAddresses) / sizeof(DCCAccessoryAddress)) ; i++) { if ((Addr == gAddresses.address) && ((Addr != lastAddr) || (Direction != lastDirection)) && OutputPower) { lastAddr = Addr ; lastDirection = Direction ; Serial.print(F("Moving to Station : ")); Serial.println(i, DEC); #ifdef STEPPER_ENABLE_PIN stepper1.enableOutputs(); #endif if (Direction) { Serial.print(F("Moving to Front Position : ")); Serial.println(gAddresses.stationFront, DEC); stepper1.moveTo(gAddresses.stationFront); break; } else { Serial.print(F("Moving to Back Position : ")); Serial.println(gAddresses.stationBack, DEC); stepper1.moveTo(gAddresses.stationBack); break; } } } }; bool lastIsRunningState ; void setupStepperDriver() { #ifdef STEPPER_ENABLE_PIN stepper1.setPinsInverted(false, false, true); // Its important that these commands are in this order stepper1.setEnablePin(STEPPER_ENABLE_PIN); // otherwise the Outputs are NOT enabled initially #endif stepper1.setMaxSpeed(1000.0); stepper1.setAcceleration(1000); stepper1.setSpeed(600); lastIsRunningState = stepper1.isRunning(); } void moveToHomePosition() { pinMode(HOME_SENSOR_PIN, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(HOME_SENSOR_PIN), interruptEvent, RISING); bInterruptDetected = false; Serial.println(F("Performing 2 complete turns to find home.")); stepper1.move(FULL_TURN_STEPS * 2); } void interruptEvent() { detachInterrupt(digitalPinToInterrupt(HOME_SENSOR_PIN)); bInterruptDetected = true; } void setupDCCDecoder() { Serial.println(F("Setting up DCC Decorder...")); // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up Dcc.pin(0, 2, 1); // Call the main DCC Init function to enable the DCC Receiver Dcc.init( MAN_ID_DIY, 10, CV29_ACCESSORY_DECODER | CV29_OUTPUT_ADDRESS_MODE, 0 ); } void setup() { Serial.begin(115200); while(!Serial); // Wait for the USB Device to Enumerate Serial.println(F("Example Turntable Program - www.dccinterface.com")); ConfigureStations(); setupStepperDriver(); Serial.println(F("Finding home....")); moveToHomePosition(); } void loop() { if (bInterruptDetected) { bInterruptDetected = false; bHomePositionFound = true; Serial.println(F("Found Home - Ssetting Current Position to 0")); stepper1.setCurrentPosition(0); Serial.print("Moving to position "); Serial.println(entryStation, DEC); #ifdef STEPPER_ENABLE_PIN stepper1.enableOutputs(); #endif stepper1.moveTo(entryStation); setupDCCDecoder(); } if (bHomePositionFound) { // You MUST call the NmraDcc.process() method frequently from the Arduino loop() function for correct library operation Dcc.process(); } // Process the Stepper Library stepper1.run(); #ifdef STEPPER_ENABLE_PIN if(stepper1.isRunning() != lastIsRunningState) { lastIsRunningState = stepper1.isRunning(); if(!lastIsRunningState) { stepper1.disableOutputs(); Serial.println(F("Disable Stepper Outputs")); } } #endif } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Now I am using a stepper motor with 1.8 degree steps this gives you 200 steps for a complete revolution of the motor. As I am using the 60 tooth and 10 tooth gear to give a smoother movement I needed to change the steps per revolution. Original line in programme #define FULL_STEPS_PER_REVOLUTION 200 My version 60 to 10 =6 to 1 so 200 x 6 = 1200 #define FULL_STEPS_PER_REVOLUTION 1200 Now I am using ¼ step microstepping (MS2 linked to 5V) So there are 4800 steps for a complete revolution of the turntable deck. this means you can have 4800 different stations (HE HE ) The modification to the programme for the sensor is as follows Original code void moveToHomePosition() { pinMode(HOME_SENSOR_PIN, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(HOME_SENSOR_PIN), interruptEvent, RISING); My code void moveToHomePosition() { pinMode(HOME_SENSOR_PIN, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(HOME_SENSOR_PIN), interruptEvent, LOW); Just the one word change RISING to LOW Now the programme will run the turntable albeit a little fast. That’s next
PART EIGHT Now to slow things down These are the original lines of code stepper1.setMaxSpeed(1000.0); stepper1.setAcceleration(1000); stepper1.setSpeed(600); This is what I ended up with there may be better ways of doing this but this works just fine. stepper1.setMaxSpeed(50.0); stepper1.setAcceleration(500); stepper1.setSpeed(50); By the way if your deck moves the opposite way around than you want it to you only have to change two of the wires that connect the stepper motor to the board. I.E. swop about 1A with 1B that it for now unless you have any questions Be seeing you Bob