Jump to content
 

DCC Controlled (PECO) Turntable Project using a Arduino Uno


Recommended Posts

Hi Bryan

Sorry it's of topic but how did you connect up to the rails on the table so you are able to turn the table without twisting the wires.

Ray

Not completed it yet, but my plan is to have a ring of copper clad paxolin (same stuff as copper clad sleepers but in sheet form) cut from a sheet and two phosphor bronze wipers. The ring will have a insulating cut across the diameter in line with the primary entrance track and the wipers will be in line with the two rails. Make sure the insulating cut is wide enough so the wipers do not touch both halves.

post-3433-0-33206900-1446076424_thumb.jpg

Of course this only works if you haven't got entrance tracks at right-angles, I will only have three in a spread shown on the diagram.

 

Electrical connections would be, connection to the split ring in line with the entrance rails and the rails on the bridge to the wiper on the same side, therefore when the table turns through 180 degrees the bridge rails swap polarity. (This would work with DC and DCC as well I think).

 

Hope that makes sense, haven't done anything in the physical world yet so it may need some fettling to get it working.

Edited by gz3xzf
Link to post
Share on other sites

If you use DCC with or even without sound, you should not use split rings. They will stop the sound or cause a short which will shut down the DCC.

 

Consider a complete ring (the support rail) as one supply and the pivot as the other, with either a polarity switch or relay driven by the position of the turntable (eg cam & microswitch), or a "juicer".

 

HTH

Simon

Link to post
Share on other sites

Addendum having seen Bryan's response which crossed in the aether with mine - if you use doubly split slip-rings, you will not cause a short & shut-down.

 

You will lose sound and possibly cause your loco to restart.

 

Best

Simon

Link to post
Share on other sites

If you use DCC with or even without sound, you should not use split rings. They will stop the sound or cause a short which will shut down the DCC.

 

Consider a complete ring (the support rail) as one supply and the pivot as the other, with either a polarity switch or relay driven by the position of the turntable (eg cam & microswitch), or a "juicer".

 

HTH

Simon

Addendum having seen Bryan's response which crossed in the aether with mine - if you use doubly split slip-rings, you will not cause a short & shut-down.

 

You will lose sound and possibly cause your loco to restart.

 

Best

Simon

Simon, I hadn't thought about the sound stopping, but I haven't taken a leap into the world of DCC sound yet; what I was trying to get away from was the need for a DCC reversing module, but I guess the that would really be the easiest way to go.

 

Hopefully going to Weymouth show over the weekend to pick up some bits and pieces so may make a start on getting the rails fitted to the bridge and testing pick-up methods over the next week or so, I'll let you know how I get on.

Edited by gz3xzf
Link to post
Share on other sites

Hi. If either Ray or gz3xzf would like the brass kit for the Dapol / Airfix kit, I can have a look and if I find it, post it on  ( just cover the cost of the postage )

Hi 73c

I wouldn't mind having that brass kit for Dapol TT. I will pm you with my address Later today.

Link to post
Share on other sites

Hi. If either Ray or gz3xzf would like the brass kit for the Dapol / Airfix kit, I can have a look and if I find it, post it on  ( just cover the cost of the postage )

Thanks for the offer 73C, but I have already butchered the plastic kit (made it shorter) so I will decline; hope Ray finds a good home for it.

Link to post
Share on other sites

Hi 73c

I wouldn't mind having that brass kit for Dapol TT. I will pm you with my address Later today.

I think I know where this is going :)

 

New depot mate ?

Link to post
Share on other sites

Hi all, I am replying to the question of supplying power to the bridge. I have included a picture of a miniature slip ring that I am using. These can be 2 to 12 wires, which should be enough to do what you want to do. Most electronic stores should have, or, can get them, just Google.

 

Barry.

post-26293-0-63916000-1446861141.png

Link to post
Share on other sites

That's very helpful, thanks - I have a stalled crane project for which it will be ideal.

 

For a turntable, I don't think it's necessary. You only need 2 wires, for either DC or DCC, with the added bonus that if you want lights of some sort on the turntable, you can do that from the DCC.

 

It's necessary to reverse polarity when the turntable rotates 180 degrees.

 

With DC, there will be no power to the table whilst it's turning, so it is quite easy to arrange a commutator - two common ways - either the support rail around the pit is split in two and half used to supply each of the deck rails, or a piece of copperclad PCB is placed around the pivot and this is cut to provide the commutation. Wipers are easily arranged with springy brass or phos-bronze strip, or sprung plungers.

 

DCC is slightly more complicated, as the power is not switched off. Therefore it's rather important to avoid a short circuit as the wipers cross the gaps in the commutator (PCB or rail), as that's likely to trip out your whole layout/power district. The other consideration is that if you have sound equipped locos, a gap that prevents short circuits might well cause the sound decoder to "restart" which can be annoying. Probably worse with diesels, but you're unlikely to be turning them.

 

My solution to this problem is to provide permanent supply to the deck rails using the circular ring rail around the pit as one of the connections, and the pivot axle as the other. Polarity switching is handled on my turntable by a pair of relays driven by the Arduino, but it would be possible to use a "juicer" or even a pair of cam-operated micro switches.

 

HTH

Simon

Link to post
Share on other sites

I have used the sheet ring method but used two rings with no gaps, I tried the support rail and spindle but kept getting loss of power. I have put the sheet as a square on the bottom of the deck and used two plunger pick-ups in holes in the deck, power is feed to the pick-ups trough a twin ducer feed from the approach track.

 

I also tried the rings with gaps but found that I could not stop shorts and with wide gaps loss of power caused problems with some chips.

 

regards

 

mike g

Link to post
Share on other sites

Hi all

Can anybody assist me please, I've had a change of layout design and now only have 2 roads to and from the TT. I'd like if possible for it to turn anti-clockwise each time, from the 6 'o' clock position (the head being at 12) so the head rotates back round to the 7 and then slightly on again to the 6 'o' clock when instructed to.

Do I leave out the first set of instructions in the sketch regarding myStepper2 'forward' and the first set in the 'position' instructions ( the 'moveTo' )

Like Lucian, mine also sits and makes a high pitched noise when at rest

Any help would be greatly appreciated.

Thank you

 

 

Hi

 

I can try to help, but I am not familiar with the program as written - you need to go through the sections of code to find the relevant bits and ensure that the function does what you need,  Ideally, you want someone who is familiar with the code to talk you through.

 

Regarding the whining, this must be either the frequency of the motor driver, or a vibration induced because the motor has not quite got to a null position, and it's therefore being driven, but not enough.  If it does it every time, I'd blame the former, and if it does it sometimes, even mostly, then the latter.  The latter is easier to fix, you can lubricate the table, and its wheels and bearings, and/or write a small routine to "wobble" or "jitter" the table, both should help.

 

HTH

Simon

Link to post
Share on other sites

Hi all

Can anybody assist me please, I've had a change of layout design and now only have 2 roads to and from the TT. I'd like if possible for it to turn anti-clockwise each time, from the 6 'o' clock position (the head being at 12) so the head rotates back round to the 7 and then slightly on again to the 6 'o' clock when instructed to.

Do I leave out the first set of instructions in the sketch regarding myStepper2 'forward' and the first set in the 'position' instructions ( the 'moveTo' )

Like Lucian, mine also sits and makes a high pitched noise when at rest

Any help would be greatly appreciated.

Thank you

 

If memory serves me well, (its been a long time since looking at this) as it stands, the original code doesn't allow for the turntable to turn through the zero position. i.e. if the current position is 200 and you want to go to position 3000 the moveTo command will step clockwise 2800 steps not 400 steps anticlockwise (through zero).

 

Like i said, its been a long time and my T/T is boxed up at present so can't check. I may be wrong!

 

Ray.

Link to post
Share on other sites

Hi Simond & Ray

 

Thanks both of you for your replies. The TT runs fine when not powered. so I don't think it's tight or dry surfaces etc so it may well be, that it's not sitting at a null position.

Writing any code would be beyond my capabilities, I'll have a play around with the settings and see if I can at least get it to stop where I'd like it to for now.

Link to post
Share on other sites

Hi all

Can anybody assist me please, I've had a change of layout design and now only have 2 roads to and from the TT. I'd like if possible for it to turn anti-clockwise each time, from the 6 'o' clock position (the head being at 12) so the head rotates back round to the 7 and then slightly on again to the 6 'o' clock when instructed to.

Do I leave out the first set of instructions in the sketch regarding myStepper2 'forward' and the first set in the 'position' instructions ( the 'moveTo' )

Like Lucian, mine also sits and makes a high pitched noise when at rest

Any help would be greatly appreciated.

Thank you

Hello, i used the code posted by luce001 on page 7. You should use the servo brake or a gear transmission.

Link to post
Share on other sites

Hi all

Can anybody assist me please, I've had a change of layout design and now only have 2 roads to and from the TT. I'd like if possible for it to turn anti-clockwise each time, from the 6 'o' clock position (the head being at 12) so the head rotates back round to the 7 and then slightly on again to the 6 'o' clock when instructed to.

Do I leave out the first set of instructions in the sketch regarding myStepper2 'forward' and the first set in the 'position' instructions ( the 'moveTo' )

Like Lucian, mine also sits and makes a high pitched noise when at rest

Any help would be greatly appreciated.

Thank you

Is this movement still a concern?

Link to post
Share on other sites

My turn table (since abandoned project due to layout revision) was pivoted on a 1/4" stereo jack and socket.

This kept the table live but meant I had to use a DPDT switch to reverse the DCC 'polarity' for a >90 - 180 degree swing.

The table motor was manually controlled by a sprung [(on)-off-(on)] switch so flipping the DPDT polarity switch next to it was no problem.

I added a bi-colour red/green led to each end of the table to remind me if the 'polarity' was right/wrong.

 

The wiring diagram is in my gallery for those interested.

Edited by RAFHAAA96
Link to post
Share on other sites

  • 2 weeks later...

Hi luciansima80

Does that mean not using a stepper motor and changing the drive to a servo or an electric motor with a gear train?

No, i meant to add the servo motor brake or a gear system.

 

I addded the servo brake because it was easier, when it stops it has a very slight jitter and can move away from the desired position with approx. 1 mm. For N scale this is a huge problem so i added the servo to keep it in place as it stops.

Link to post
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
I have 2 sketches that I am using to control a turntable. One is Tender's DCC Turntable control and one that uses a Bluetooth module connected to

the Arduino and controlled by an Android phone. Both sketches work on their own but when I combine the 2 sketches the Bluetooth sketch is not working.

I have added the Bluetooth control to the Loop as this is only a serial Read but this does not seem to work. I have use pins 0 & 1 for the RX and TX for the Bluetooth and Interrupt 0

for the DCC signal.

See code below
// DCC Turntable Control Test Routines

#include <DCC_Decoder.h>
#include <AccelStepper.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Defines and structures
//
#define kDCC_INTERRUPT            0

typedef struct
{
    int               address;                // Address to respond to

} DCCAccessoryAddress;

DCCAccessoryAddress gAddresses[8];

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// Adafruit Setup

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);


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int led = 13;
int test = 0;
int rotate = 0;
int sensorVal = digitalRead(3);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Decoder Init 
//
void ConfigureDecoder()
{
    gAddresses[0].address = 200;
    gAddresses[1].address = 201;
    gAddresses[2].address = 202;
    gAddresses[3].address = 203;
    gAddresses[4].address = 204;
    gAddresses[5].address = 205;
    gAddresses[6].address = 206;
    gAddresses[7].address = 207;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Basic accessory packet handler 
//
void BasicAccDecoderPacket_Handler(int address, boolean activate, byte data)
{
        // Convert NMRA packet address format to human address
    address -= 1;
    address *= 4;
    address += 1;
    address += (data & 0x06) >> 1;
    
    boolean enable = (data & 0x01) ? 1 : 0;
    
    for(int i=0; i<(int)(sizeof(gAddresses)/sizeof(gAddresses[0])); i++)
    {
        if( address == gAddresses[i].address )
        {
            Serial.print("Basic addr: ");
            Serial.print(address,DEC);
            Serial.print("   activate: ");
            Serial.println(enable,DEC);
            
            if( enable )
            {
                switch (i) {
                  case 1:
                    stepper2.moveTo(200);
                  break;
                  case 2:
                    stepper2.moveTo(400);
                  break;
                  case 3:
                    stepper2.moveTo(600);
                  break;
                  case 4:
                    test = HIGH;
                    Test();
                  break;
                  case 5:
                    stepper2.runToNewPosition(1600);
                  break;
                  case 6:
                    rotate = HIGH;
                    Rotate();
                  break;
                }
             }
            else{
                switch (i) {
                  case 1:
                    stepper2.moveTo(1800);
                  break;
                  case 2:
                    stepper2.moveTo(2000);
                  break;
                  case 3:
                    stepper2.moveTo(2200);
                  break;
                  case 4:
                    test = LOW;
                    Test();
                  break;
                  case 5:
                    stepper2.runToNewPosition(-1600);
                  break;
                  case 6:
                    rotate = LOW;
                    Rotate();
                  break;
                }
            }
        }
    }
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Setup
//
void setup() 
{ 
   Serial.begin(9600);
  // initialize the digital pin as an output and set it low initially
  pinMode(led, OUTPUT);
  digitalWrite(led, LOW);
  
  
   
   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
  
  
  //set stepper motor speed and acceleration 
  stepper2.setMaxSpeed(30.0);
  stepper2.setAcceleration(20.0);
//  stepper2.moveTo(800);

// if near reference point move away
  sensorVal = digitalRead(3);
  while (sensorVal == LOW) {
    sensorVal = digitalRead(3);
    forwardstep2();
      delay(50);
  }
  
// step forward to sensor index point
  while (sensorVal == HIGH) {
    sensorVal = digitalRead(3);
    forwardstep2();
      delay(50);
  }
   
   DCC.SetBasicAccessoryDecoderPacketHandler(BasicAccDecoderPacket_Handler, true);
   ConfigureDecoder();
   DCC.SetupDecoder( 0x00, 0x00, kDCC_INTERRUPT );
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Main loop
//
void loop()
{
  
    static int addr = 0;
    
        ////////////////////////////////////////////////////////////////
        // Loop DCC library
    DCC.loop();
    
        ////////////////////////////////////////////////////////////////
        // Bump to next address to test
    if( ++addr >= (int)(sizeof(gAddresses)/sizeof(gAddresses[0])) )
    {
        addr = 0;
    }
    
    stepper2.run();
    
  String t; //create an empty string to store messages from Android
  while(Serial.available()) { //keep reading bytes while they are still more in the buffer
    t += (char)Serial.read(); //read byte, convert to char, and append it to string
  }
  
  if(t.length()) { //if string is not empty do the following
    if(t == "Ton") { //if the string is equal to "on" then turn LED on
      digitalWrite(led, HIGH); //Set digital pin to high to turn LED on
      Serial.write("Moving to Main Track CW"); //Tell the Android app that the LED was turned on
    }
    else if (t == "Toff") { 
      digitalWrite(led, LOW);  
      Serial.write("Moving to Main Track CCW");
    } // turn the LED off by making the voltage LOW
  }  
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void Test(){
  
  // 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);  
  
  if (stepper2.distanceToGo() == 0)
       { delay(5000);
	stepper2.moveTo(-stepper2.currentPosition());
       }
       
        //stepper2.run();  //maybe needed
}

void Rotate(){
   if (rotate == HIGH ){
     stepper2.runToNewPosition(3200);
   }
  else{
   stepper2.runToNewPosition(-3200); 
  }  
}

Can anyone can point me in the right direction.

 

Alan

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...