Jump to content
 

DCC Controlled (PECO) Turntable Project using a Arduino Uno


Recommended Posts

That was easier than I thought.

 

I have uploaded my accelstepper, DCC libraries and other useful stuff onto Github:

 

https://github.com/RigidCollision/Turntable

 

 

Code examples and utility code on it's way soon.

HELP

But what is the program turntable with DCC control for uploading to ARDUINO NANO? motor control A4988

 

Alessandro

Edited by Pinter75
Link to post
Share on other sites

Just added a speed harmonics and vibration test for steppers on my GitHub site.

It allows you to specify a lower and upper limit to step through sequentially, automatically running the motor at each speed in turn.

It kinda helps 'dial in' the best combination of microstepping / speed / motor to limit the potential of running the motor at a frequency that results in it vibrating.

 

Put the basic code for use with the turntable for getting it to work with DCC and a Hall sensor. It's basically Tenders code from page 1 or 2 of this thread with some minor adjustments for homing using an interrupt rather than sensing high or low on a digital I/O.

Allows a little more flexibility for using the code WITHOUT accelstepper if you want to drive it that way.

 

I am rapidly coming to the conclusion that accelstepper is simply not worth the overhead and hassle for problems it has been causing me with slow running issues and the inflexibility of some of it's 'features'. I am torn between abject laziness and writing my own slightly leaner library tailored for the turntable project with the actual functionality I need.

 

Looking forward to testing TMC2100 drivers...

Edited by Rigid Collision
Link to post
Share on other sites

Hiya,

I used ALLPCB www.allpcb.com.

These guys were GREAT. Good communication fast production and despatch; just 5 days from submission online to receipt via DHL!

 

You are brave using EAGLE I tried to get to grips with it and found it mind blowingly buggy and awful. Having said that, my experience of delving into the world of PCB production was like turning the clock back 15 years software-wise. The world of PCB design seems to be populated with buggy and troublesome products that are hard to use and don't always deliver. Considering my 20 years designing 3d software (which is far mare complicated) I don't think it was my lack of ability and I was left totallyunderwhelmed.

 

In the end I used DipTrace, I ditched the idea of circuit diagrams and adding components in favour of just using DiptTace rather like a glorified version of Illustrator. It allowed me to simply draw a board and add pads and traces whilst snapping to a grid. It allowed me to add silk screen details easily and it exported flawlessly into Gerber files with a drilling file. All-in-all much less hassle that 'designing' a board and specifying components and circuits!

 

Regards

 

 

Hello

I used ALLPCB absolutely brilliant - mine took a week but were sitting at the local couriers here over the weekend. I would recommend them as the boards were first class.

I think I will stick with Eagle as it seems better for Macs and I haven't used Windows machines for ages.

I have the circuit up and running, but I have already a list of extras I might add. The circuit design and build was so easy I will throw away the breadboards altogether!

I have sourced a stepper with a double shaft so I am thinking I will use a rotary encoder on one end as a reference and then I can have a nice feedback loop to improve accuracy.

I can get a 1024 step one for US$40 which would give me a shade less than a millimetre it the rim - might not be good enough though. After all the 3200 step stepper would be batter than .33 mm.

I do seem to have a bit of trouble getting the turntable to return to exactly the same position repeatedly 

I think I will need another Nano to look after the encoder as it will need to use a couple of interrupts to work nicely. Any one tried this ? 

 

regards

Edited by colinc3e
Link to post
Share on other sites

Hello

I used ALLPCB absolutely brilliant - mine took a week but were sitting at the local couriers here over the weekend. I would recommend them as the boards were first class.

I think I will stick with Eagle as it seems better for Macs and I haven't used Windows machines for ages.

I have the circuit up and running, but I have already a list of extras I might add. The circuit design and build was so easy I will throw away the breadboards altogether!

I have sourced a stepper with a double shaft so I am thinking I will use a rotary encoder on one end as a reference and then I can have a nice feedback loop to improve accuracy.

I can get a 1024 step one for US$40 which would give me a shade less than a millimetre it the rim - might not be good enough though. After all the 3200 step stepper would be batter than .33 mm.

I do seem to have a bit of trouble getting the turntable to return to exactly the same position repeatedly 

I think I will need another Nano to look after the encoder as it will need to use a couple of interrupts to work nicely. Any one tried this ? 

 

regards

I'm looking at my next board using the Arduino Pro Mini as it has more than two interrupts (I think).

 

My code uses the 2 interrupt pins on the Nano. Have a look at my GitHub page for the code.https://github.com/RigidCollision/Turntable

Link to post
Share on other sites

I'm looking at my next board using the Arduino Pro Mini as it has more than two interrupts (I think).

If you use pinChange interrupts all the Arduinos have multiple interrupts - though not quite as simple to code as the external interrupts.

 

...R

Link to post
Share on other sites

I have had a fair bit of interest in the board I made.

Pricing is as follows:

 

Bare board - £20 Incl. P&P

Complete kit (less Nano but including A4988) unassembled - £30 Incl. P&P

Complete kit (less Nano but including A4988) assembled and tested- £40 Incl. P&P

 

Comparable pricing with Uno and Adafruit shield pricing but in a neater package with a DCC interface. :)

I have a few boards/kits left and if there is interest I will get some more in. I may start using the Micro Pro board as it has more interrupts (the Nano and UNO only have 2 I/O ports capable of interrupt!).

It will require some minor design changes but it is possible to hook up some of the I/O to pins to enable them to be user configured.

 

If anyone has any requests I might look at doing other DCC Arduino project PCB boards for lights or signalling?

 

Where is the best/most convenient place to upload my AccelStepper libraries with 'setBacklash'?

 

Regards,

 

Hello Rigid,
I had no more news of him, the money arrived?
Link to post
Share on other sites

Hi everybody

 

It has been over a year since I purchased the parts for this project and I have finally got around to doing something with the bits, I have powered up the Arduino using the PC USB interface and got the Blink sketch to work. I have soldered the pins to the Motor Shield and plugged the two together, but I have some dumb questions about the additional circuitry, I started off thinking I would use DCC, but I may now do the job with buttons or switches. So on to the questions: -

  1. Ray's original design used a 6N137 chip (which I don't know what it does) but it appears to derive the +5 volts for the Arduino/Motor Shield from the DCC, is that correct?
  2. This chip also has a connection to one of the digital I/O ports, is this how the Arduino gets the DCC signal?
  3. If I am going to use buttons or a switch what do I need to change on the electrical side or can I still use the above but not use the DCC control part of the sketch?

I am afraid that I am not very knowledgable about electronics and therefore am not sure how it all works, I am only "following the instructions".

 

Thanks for any help in advance. :) :)

Link to post
Share on other sites

DCC monitor quirks

I have my turntable running with a Nano and A4988 using the 6N137 circuit for DCC interface.

I have another system running DCCMonitor to check what is happening on the DCC. I have tried the monitor with Hornby Select, Lenz 100 and a Sprog. 

On the select I need a loco on the tracks before I can read any signals - similar results with the other two systems and the odd drop out on Lenz. I have checked circuitry and used duplicate electronics, but no clues.

 

I suspect the DCC needs a 'load' to operate, but I have been searching literature and can't find an answer to this.

Also the setup on a Lenz system works for a while and then stops responding - maybe too much power draw as it has a few locos running. 

 

Any pointers greatly appreciated - thanks in advance 

Link to post
Share on other sites

DCC monitor quirks

I have my turntable running with a Nano and A4988 using the 6N137 circuit for DCC interface.

I have another system running DCCMonitor to check what is happening on the DCC. I have tried the monitor with Hornby Select, Lenz 100 and a Sprog. 

On the select I need a loco on the tracks before I can read any signals - similar results with the other two systems and the odd drop out on Lenz. I have checked circuitry and used duplicate electronics, but no clues.

 

I suspect the DCC needs a 'load' to operate, but I have been searching literature and can't find an answer to this.

Also the setup on a Lenz system works for a while and then stops responding - maybe too much power draw as it has a few locos running. 

 

Any pointers greatly appreciated - thanks in advance 

 

 

 

I have had a fair bit of interest in the board I made.

Pricing is as follows:

 

Bare board - £20 Incl. P&P

Complete kit (less Nano but including A4988) unassembled - £30 Incl. P&P

Complete kit (less Nano but including A4988) assembled and tested- £40 Incl. P&P

 

Comparable pricing with Uno and Adafruit shield pricing but in a neater package with a DCC interface. :)

I have a few boards/kits left and if there is interest I will get some more in. I may start using the Micro Pro board as it has more interrupts (the Nano and UNO only have 2 I/O ports capable of interrupt!).

It will require some minor design changes but it is possible to hook up some of the I/O to pins to enable them to be user configured.

 

If anyone has any requests I might look at doing other DCC Arduino project PCB boards for lights or signalling?

 

Where is the best/most convenient place to upload my AccelStepper libraries with 'setBacklash'?

 

Regards,

 

Hello Rigid,
I had no more news of him, the money arrived?

 

 

What is this post? :)

Has anyone used y boards yet? Really interested on how people are getting on with them.

Link to post
Share on other sites

What is this post? :)

Has anyone used y boards yet? Really interested on how people are getting on with them.

 

Hello Rigid,
 
I had no more news of him, the money arrived?
 
I tried to run a try copying the files on Arduino Nano, but it always fails.
I have to find an expert here to help me and the first time and do not understand anything
 
Pinter
Link to post
Share on other sites

Hi All

 

Is there a way to use a Arduino keyboard 4x4 as a alternative command station  ( turnout command from the hand controller )

Some times is very difficult to control 2 or more locos, and the turnouts from the hand controller.

 

Could somebody help me to change the sketch

 

tks

 

JB.

Edited by jbsorocaba
Link to post
Share on other sites

Hi All

 

Is there a way to use a Arduino keyboard 4x4 as a alternative command station  ( turnout command from the hand controller )

Some times is very difficult to control 2 or more locos, and the turnouts from the hand controller.

 

Could somebody help me to change the sketch

 

tks

 

JB.

While this is loconet specific, you could most likely tweak this for your command protocol...

 

http://model-railroad-hobbyist.com/node/26582

It uses a 3x4 keyboard, and arduino to send a turnout number and command (open or closed) to the command station, which in turns, send this command to the turnout controller specified.

Link to post
Share on other sites

I've been following this thread for a while and have not yet committed to building the project.  I have some resources that you guys may be interested in.  MERG published a journal in 2015 (http://www.merg.org.uk/merg_journal/download.php?fileid=83&userid=0) that had a design for an arduino controlled stepper turntable.  This design did not use a switch to signal a complete rotation - all of the positions are stored in memory based on the number of steps needed for rotation (say a 100:1 gearing x 1.8 degree stepper).

 

It's on page 29 of the journal I linked above.  It uses an LCD and 4 switches for control and programming.  The part list (it's really just an LCD, arduino, the controller and the switches (4x) is on page 39.

 

While the code is not published in the journal, the BOM is.  I then found a youtube user who built a version of this control and posted the code.  It can be found at - 

 

I downloaded the code and he listed in the comments below the video the connections used between the arduino and the stepper controller board (Sparkfun dSPIN board - the old one not the newer more expensive board).

 

Any thoughts?

Edited by gcodori
Link to post
Share on other sites

While this is loconet specific, you could most likely tweak this for your command protocol...

 

http://model-railroad-hobbyist.com/node/26582

It uses a 3x4 keyboard, and arduino to send a turnout number and command (open or closed) to the command station, which in turns, send this command to the turnout controller specified.

gcodori

Thank you so much for the information.  I will see the journal 

Link to post
Share on other sites

Hi

Unfortunately my system is Xpressnet and I think this will not work.  I still waiting for a help

Tks

 

If xpressnet is your protocol - then you MUST check out Paco's terrific website - he has plenty of free designs for throttles, decoders, control stations, computer adapters and boosters for xpressnet/Roco/Lenz.

You can find it here

http://usuaris.tinet.cat/fmco/lokmaus_en.html

 

Also check out his section on the xpressnet TCO project - it is the basis of a control panel for controlling turnouts and setting routes, etc.  Look at http://usuaris.tinet.cat/fmco/lokmaus_en.html#xbustco

While it is not a keypad - it is the start of where you have switches on a panel that you can throw to control a turnout.

 

If you prefer a keypad, you can build his minimaus V2B with the keyboard and mount it in the layout instead of making it portable - you can control turnouts (up to 999 turnouts!), set routes and even program from this keyboard.  As you can see it's only two chips some resistors and the keypad - SIMPLE!

 

All of his designs are very simple to build and he outs it on the web free.  

Link to post
Share on other sites

If xpressnet is your protocol - then you MUST check out Paco's terrific website - he has plenty of free designs for throttles, decoders, control stations, computer adapters and boosters for xpressnet/Roco/Lenz.

You can find it here

http://usuaris.tinet.cat/fmco/lokmaus_en.html

 

Also check out his section on the xpressnet TCO project - it is the basis of a control panel for controlling turnouts and setting routes, etc.  Look at http://usuaris.tinet.cat/fmco/lokmaus_en.html#xbustco

While it is not a keypad - it is the start of where you have switches on a panel that you can throw to control a turnout.

 

If you prefer a keypad, you can build his minimaus V2B with the keyboard and mount it in the layout instead of making it portable - you can control turnouts (up to 999 turnouts!), set routes and even program from this keyboard.  As you can see it's only two chips some resistors and the keypad - SIMPLE!

 

All of his designs are very simple to build and he outs it on the web free.  

Hi gcodori

 

Thank you so much for the informations.  I will see the sites.

Cheers

Link to post
Share on other sites

  • 2 weeks later...

Hi all.

 

Well, I've decided to give this one last go before writing it off as an expensive mistake. So far no matter what numbers I've played with in trying to get the deck to arrive at 2 positions has succeeded .

I've tried to shortened the programme so that one command sends the deck to the first position and the second to the next point required and then back again, no luck.

What I'd like to achieve is simply this. ( base the turntable as a clock face for description purposes )

The deck sits at 6 'o' clock, which is the 'on' road and the head is at 12.

Enter command to move.

Deck rotates, either direction, until the head is at the 7 on the clock face. This is the off road.

Enter command to move back to the 6 'o' clock position, either direction, clockwise or anti-clockwise, ready for the next loco.

I don't mind having to 'reset' the deck each time to accept another loco, as long as it does just these 2 positions.

So far nothing it seems I've tried will achieve this.

So, I'm asking for any assistance in reaching my goal of an operating turntable, anyone's input is gratefully accepted and my thanks in advance for your help in resolving this matter.

Link to post
Share on other sites

Firstly, I haven't been following in detail, as I've been rather preoccupied with baseboard building, but I'll chip in a few thoughts in the hope they'll get you started.

 

Firstly, like eating an elephant, break the job down into manageable chunks. My approach would be to forget the DCC to start with, simply get a repeatable position of the deck.

 

I'm assuming you have a stepper motor that will drive the table smoothly, and without "losing" steps. I'm also assuming you're using an Arduino.

 

You can do this whilst in program mode by getting the Arduino to feed back the position to the computer. But that implies a repeatable zero position. I used an optical switch, others have used Hall effect or reed switches with a magnet. Something that allows you to get a good datum when you turn the system on.

 

Once you have a datum, you can write simple routines to establish the total steps for a complete circuit, the steps needed to eliminate backlash when reversing (if you have a gearbox as I do) and the steps between your entry and exit roads.

 

Then write a simple program in which these are stored as variables (for later adjustment) and which uses them to move the table between the various positions. If for example your table "only" needs to go cw from position "a" to position "b" and then reset by the shortest route, this might be easily arranged with two buttons, each triggering a subroutine.

 

I think it would then be a fairly easy step to add a decoder routine to read the DCC input, and activate the subroutines that way.

 

Hoping this isn't teaching granny to suck eggs,

Best

Simon

Link to post
Share on other sites

Hi Simon

 

Sorry to say but you lost me round about ''You can do this whilst in program mode by getting the Arduino to feed back the position to the computer''

 

I've no idea how to do this sort of thing or write a routine.

 

Phil

Link to post
Share on other sites

Hi guys

 

I am introducing a keyboard and LCD for control of this turntable, using a sensor as a reference, connected to the Arduino pin 3 as partial sketch below.
I would like to send a message to the LCD when the turntable reach the sensor so that I know that truntable stopped.
 
I already burned the neurones but did not get anything until now. Can someone please give me a help.
 
Tks
 
//...

  void setup(){

   Serial.begin(9600);                             // sets up Serial library at 9600 bps for a serial monitor connected to the Artduino
   Serial.println("Stepper test for turntable");   // prints the comment between the "" on the serial monitor when starting.
    
   
  lcd.begin(20,4);                          // initialize the lcd for 20 chars 4 lines, turn on backlight
   
  for(int i = 0; i< 3; i++)                 // ------- Quick 3 blinks of backlight  -------------
  {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }
  lcd.backlight(); // finish with backlight on  
  
  lcd.print("    MOVING");
  lcd.setCursor(0,1);
  lcd.print(" TO TRACK 1 ");
     
  AFMS.begin();  // create with the default frequency 1.6KHz
 
  Astepper1.setMaxSpeed(50.0);           // sets the maximum rotational speed of the stepper in steps per second.  
                                          // (the value of 50 will rotate the turntable for a full revolution 
                                          // in about 3200/50 seconds (i.e around 64 seconds).  
  Astepper1.setAcceleration(10.0);


  pinMode(3, INPUT_PULLUP);              //  INPUT PARA O SENSOR DE PARA INICIAL.  ADICIONADO NESTA VERSÃO
 
  int sensorVal = digitalRead(3);          //read the sensor (open collector type) value into a variable
     
  while (sensorVal == HIGH) {              // if near reference point move away
  sensorVal = digitalRead(3);
  forwardstep1();
  delay(50);
 
  Astepper1.setCurrentPosition(0);    //adicionado para posição zero ref. a todos

  }
  
   while (sensorVal == LOW) {                  // step forward to sensor index point 
   sensorVal = digitalRead(3);
   backwardstep1();
   delay(50);

 
  }
}

//..........................................................
Link to post
Share on other sites

  • 4 weeks later...

Hi all can someone help me please when I compile the program in post #48 I get the following

 

 

 

C:\Users\Bob Sims\Documents\Arduino\tenderfinal\tenderfinal.ino:9:45: fatal error: utility/Adafruit_PWMServoDriver.h: No such file or directory

 

Thanks Bob

Link to post
Share on other sites

  • 4 weeks later...

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