Jump to content
 

DCC Controlled (PECO) Turntable Project using a Arduino Uno


Recommended Posts

Hi Ray.

 

yes, i think it was down to a dodgy dcc pickup - im using a crocodile clip to pick up the signal from a small piece of test track.

 

the setup is as follows...

 

Win 10 PC.

Sprog 3 DCC via usb

Arduino uno v3 via usb.

 

Sprog track feeds connected to a small section of test track.

breadboard with components on next to arduino.

crocodile clips connecting to the track....

 

good news tonight is that i made a much better track connection and it all seems fine now..,.

 

I have also added in your decoder code, and i can see when i flick decoder 200 in JMRI :-)

  • Like 1
Link to post
Share on other sites

Just a quick Update....

 

i designed a PCB using fritzing ( http://www.fritzing.org ) which is an awesomely easy app by the way...

 

I have NEVER designed a circuit board before, but this was so easy.

 

and on top of that, they have an export function, AND a fabricate button - which links to www.aisler.net who then produce them - ok its not as cheap as china made boards, but the main thing is its easy and the support is amazing.

 

I made my first board, and after 10 days i was showing a friend what i had done, when i realised i missed a 5v track!

 

I emailed them and they gave me a discount code for my replacement.

 

These guys are seriously great...... I cant recommend them enough.

Link to post
Share on other sites

  • 2 weeks later...
  • RMweb Gold

Part 2: Turntable/Motor mount  Construction

 

 

The track pick-up for the Bridge deck is via a split ring arrangement, if you want to use sound locos you may want to modify this as there is a dead spot in the rotation. There are other threads discussing this.

Find the dead spot (using a meter and rotating the deck) and mount the Hall Sensor between the rail positions on the outside of the well up under the lip of the well (superglue). The embossed writing on the sensor should be against the well wall. This will be the reference point for the turntable controller and avoided as one of the exit roads.

 

 

Next Instalment – The Electrics

 

Tender,

I am slightly confused by the paragraph in bold. Does the last sentence refer to the Dead spot, or the Sensor in the case of avoiding the exit road?

My turntable is already installed on the layout and cannot easily be removed. I am struggling to understand how I will set up the motor to stop at the point  where the approach track meets the table. I only have the one approach road and no run off the table at any other point, the table only being used to turn locos. 

I am looking at the stepper motor drive as a replacement for a less than satisfactory arrangement which is currently in use. I am a DCC sound user so my turntable track is permanently powered with an Auto -reverser to handle the direction change.

 

Geoff

 

Link to post
Share on other sites

Hi Geoff,

 

If your turntable deck is permanently powered you can forget about trying to find the dead spot as there won't be one. Just mount the sensor at any convenient position but preferably not  inline with one of the exits roads.

 

Ray.

 

Edit.

If you just need to turn through 180 degrees, in Part 6 look for this bit of code and change the two values in 'stepper2.moveTo(xxx)' until the turntable stops at the right positions.

 

{

Serial.print("Basic addr: ");
Serial.print(address,DEC);
Serial.print(" activate: ");
Serial.println(enable,DEC);

if( enable )
{
stepper2.moveTo(400);
}
else
{
stepper2.moveTo(2000);
}
}

Edited by tender
Link to post
Share on other sites

  • RMweb Gold

Hi Geoff,

 

If your turntable deck is permanently powered you can forget about trying to find the dead spot as there won't be one. Just mount the sensor at any convenient position but preferably not  inline with one of the exits roads.

 

Ray.

 

Edit.

If you just need to turn through 180 degrees, in Part 6 look for this bit of code and change the two values in 'stepper2.moveTo(xxx)' until the turntable stops at the right positions.

 

{

Serial.print("Basic addr: ");

Serial.print(address,DEC);

Serial.print(" activate: ");

Serial.println(enable,DEC);

 

if( enable )

{

stepper2.moveTo(400);

}

else

{

stepper2.moveTo(2000);

}

}

 

Thank you Ray for such a fast response. I will look into getting hold of the components. 

 

Thanks again.

 

Geoff

Link to post
Share on other sites

  • RMweb Gold

Part 3 The Electrics.

 

One thing that’s puts a lot of people off projects like this is the complexity of the electrics involved, me included. However I’m pleased to say that the amount of wiring involved with this project is minimal, with all the complex stuff being done by the Arduino/Adafruit modules.

All you need to do is solder a few connectors to the Adafruit module and build the DCC interface circuit on a piece of strip(vero)board.

 

attachicon.gifDCCIF.png

 

Above is a tidied up version of the DCC interface circuit with connectors for all connections, but you can just solder wire to the board as I have done in the prototype pictured below with the Arduino and Adafruit boards. (The Arduino and Adafruit boards are plugged together)

 

Component Values

R1/2 10k

R3 1K

D1 1N4148

U2 6N137

 

 

Sorry to bother you again Ray but how critical are the resistor values? I have 10k but only 1.1k or 998ohms for R3.

 

Geoff

Link to post
Share on other sites

 

Part 3 The Electrics.

 

One thing that’s puts a lot of people off projects like this is the complexity of the electrics involved, me included. However I’m pleased to say that the amount of wiring involved with this project is minimal, with all the complex stuff being done by the Arduino/Adafruit modules.

All you need to do is solder a few connectors to the Adafruit module and build the DCC interface circuit on a piece of strip(vero)board.

 

attachicon.gifDCCIF.png

 

Above is a tidied up version of the DCC interface circuit with connectors for all connections, but you can just solder wire to the board as I have done in the prototype pictured below with the Arduino and Adafruit boards. (The Arduino and Adafruit boards are plugged together)

 

Component Values

R1/2 10k

R3 1K

D1 1N4148

U2 6N137

 

 

Sorry to bother you again Ray but how critical are the resistor values? I have 10k but only 1.1k or 998ohms for R3.

 

Geoff

 

 

Hi Geoff, 1.1k or 998ohms will be fine for R3

Link to post
Share on other sites

  • RMweb Gold

Hi Geoff, 1.1k or 998ohms will be fine for R3

Thank you Ray. Almost all the parts are gathered now, I just have to figure out the software side. I am a Mac user so I might have to scratch my head a bit to get the downloads sorted and working.

 

Thank you for your help.

 

Geoff

Link to post
Share on other sites

Thank you Ray. Almost all the parts are gathered now, I just have to figure out the software side. I am a Mac user so I might have to scratch my head a bit to get the downloads sorted and working.

 

Thank you for your help.

 

Geoff

 

That will be interesting Geoff, i'm also a Mac user but have a Windows laptop for my Train stuff (Train Controller mainly). The Arduino IDE is available for MAC but I've not tried it yet, let us know how you get on.

I've also been playing with a Raspberry Pi with JMRI and WiThrottle on iPhone/iPad but that another story.

Link to post
Share on other sites

  • RMweb Gold

That will be interesting Geoff, i'm also a Mac user but have a Windows laptop for my Train stuff (Train Controller mainly). The Arduino IDE is available for MAC but I've not tried it yet, let us know how you get on.

I've also been playing with a Raspberry Pi with JMRI and WiThrottle on iPhone/iPad but that another story.

 

Ray,

How very interesting! I too have a Windows laptop for my layout. I needed it for my Lokprogrammer and a very old program called Wagonflow which I use to build freight train manifests and display my timetable. Normally that laptop is not connected to the internet but to a discreet router for running Wi-throttle on JMRI. I want to use my MacBook for the Arduino as I can more easily move it to where the turntable is situated. I will try to let you know how I get on or alternatively I will be shouting for help!

Thank you again for your help.

 

Geoff

Link to post
Share on other sites

  • RMweb Gold

Well Ray, whilst waiting for the motor to arrive I thought I had better try to get to grips with the software.

I downloaded the Arduino IDE and the adafruit motor shield software and then really had a tussle to get the DCC Libraries but I think I have them all now and, I think the Arduino is working ok, well at least the led is blinking as it is supposed to after the BLINK test.

I took loads of screen shots which may help other Mac users who are not conversant with this type of work.

 

Geoff

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Screenshot 2017-07-05 13.11.12.png

Screenshot 2017-07-05 13.11.29.png

Screenshot 2017-07-05 13.19.23.png

Screenshot 2017-07-05 13.22.11.png

Screenshot 2017-07-05 13.22.15.png

Screenshot 2017-07-05 13.22.21.png

Screenshot 2017-07-05 13.24.58.png

Screenshot 2017-07-05 13.29.23.png

Screenshot 2017-07-05 13.36.27.png

Screenshot 2017-07-05 13.38.19.png

Screenshot 2017-07-05 13.38.41.png

Screenshot 2017-07-05 13.40.42.png

Screenshot 2017-07-05 13.40.55.png

Screenshot 2017-07-05 13.42.13.png

Screenshot 2017-07-05 14.01.37.png

Screenshot 2017-07-05 14.01.51.png

Screenshot 2017-07-05 14.17.07.png

Screenshot 2017-07-05 14.18.20.png

Screenshot 2017-07-05 14.19.41.png

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

Well Ray, whilst waiting for the motor to arrive I thought I had better try to get to grips with the software.

I downloaded the Arduino IDE and the adafruit motor shield software and then really had a tussle to get the DCC Libraries but I think I have them all now and, I think the Arduino is working ok, well at least the led is blinking as it is supposed to after the BLINK test.

I took loads of screen shots which may help other Mac users who are not conversant with this type of work.

 

Geoff

attachicon.gifScreenshot 2017-07-05 13.11.12.png

attachicon.gifScreenshot 2017-07-05 13.11.29.png

attachicon.gifScreenshot 2017-07-05 13.19.23.png

attachicon.gifScreenshot 2017-07-05 13.22.11.png

attachicon.gifScreenshot 2017-07-05 13.22.15.png

attachicon.gifScreenshot 2017-07-05 13.22.21.png

attachicon.gifScreenshot 2017-07-05 13.24.58.png

attachicon.gifScreenshot 2017-07-05 13.29.23.png

attachicon.gifScreenshot 2017-07-05 13.36.27.png

attachicon.gifScreenshot 2017-07-05 13.38.19.png

attachicon.gifScreenshot 2017-07-05 13.38.41.png

attachicon.gifScreenshot 2017-07-05 13.40.42.png

attachicon.gifScreenshot 2017-07-05 13.40.55.png

attachicon.gifScreenshot 2017-07-05 13.42.13.png

attachicon.gifScreenshot 2017-07-05 14.01.37.png

attachicon.gifScreenshot 2017-07-05 14.01.51.png

attachicon.gifScreenshot 2017-07-05 14.17.07.png

attachicon.gifScreenshot 2017-07-05 14.18.20.png

attachicon.gifScreenshot 2017-07-05 14.19.41.png

 

 

Many Thanks for posting that Geoff, a very useful reference for Mac users. Will try it on my Mac when i get a chance.

Did you have any problems finding the Arduino when it was plugged into the USB socket on the Mac?

Ray.

Edited by tender
Link to post
Share on other sites

  • RMweb Gold

Many Thanks for posting that Geoff, a very useful reference for Mac users. Will try it on my Mac when i get a chance.

Did you have any problems finding the Arduino when it was plugged into the USB socket on the Mac?

Ray.

That is a good question Ray. It all appeared to be working when I ran BLINK but when I wanted to disconnect I could not find a symbol for it in the list own the side of the screen as you would for example with a memory stick. I had stretched the " little grey cells" considerably to get the downloads so I may have missed something. I will have another play tomorrow. I can't get much further until the motor arrives, it is in the post, and I wander down to Maplins to get the diode to build the DCC board.

 

Geoff

Link to post
Share on other sites

  • RMweb Gold

That is a good question Ray. It all appeared to be working when I ran BLINK but when I wanted to disconnect I could not find a symbol for it in the list own the side of the screen as you would for example with a memory stick. I had stretched the " little grey cells" considerably to get the downloads so I may have missed something. I will have another play tomorrow. I can't get much further until the motor arrives, it is in the post, and I wander down to Maplins to get the diode to build the DCC board.

 

Geoff

 

Ray, I have followed the steps shown in the video linked below. While there were some slight differences in areas, such as which Arduino is in use, mine came up as Arduino Uno Genuine, and the port was labelled differently but when I 'uploaded' the BLINK sketch the Arduino responded. However there is no device shown in the "Finder" menu as there would be with a memory stick.

I now have the motor but still need to get the diode to build the DCC module and wait for the magnet which is on back order.

Thank goodness for the web as I was completely flummoxed when I looked at the motor shield and wondered how on earth it connects to the Arduino, but I have found the information.

 

Geoff (stumbling along.)

 

 

Link to post
Share on other sites

Hi,

 

me again.

 

I have made my own circuit board and started to use the A4988 motor driver instead of the AdaFruit one, however i'm not impressed at all.

 

The results have been far less than i expected. I cant get a smooth movement - its constantly jerky - and this is with the AccelStepper library. I have to speed it up too much in order to get smooth running on 1/16 steps.

 

I am considering going back to the Adafruit shield as the results for this were good.

 

Also be aware of the code from RigidColision. His code was for a stepper motor with a gearbox - don't do what i did and just upload it to the Arduino without change - it makes the turntable turn in to a helicopter!

 

Anyone else had these thoughts?

Link to post
Share on other sites

  • RMweb Gold

Hello Ray,

After a challenging morning I managed to get things working as far as the stepper test which worked, and kept on working ad infinitum! Where is the stop button! I stopped the whole system and then re-booted and moved on to the DCC interface test which sadly failed dismally with not a single packet being recorded.

 

I have attached a screen shot and a photo of my set up. The DCC board is built from the diagram you posted. I have checked and double checked it but maybe I have missed or misunderstood something. I made an assumption, not always wise, that pin 1 on the opto-isolator was under the dimple, top left corner of the isolator in the photo pointing towards the motor. The unconnected white wire comes from the reset connection on my board. Should I connect it to the motor shield? I couldn't see one on your board.

I am out of my depth now!

 

Geoff

 

 

IMG_0633.jpeg

IMG_0634.jpeg

Edited by geoff
restoring photographs.
Link to post
Share on other sites

  • RMweb Gold

Me again Ray,

Although I have attempted to build the DCC interface I would be just as happy with a simple switch to operate the turntable. Of course to have both facilities would give me flexibility when I am operating by myself. Is there simple way to incorporate a simple switch into the system?

 

Geoff

Link to post
Share on other sites

  • RMweb Gold

Geoff...

 

also, if it helps, I was going to make up some PCB's that are just the DCC interface to the arduino nano. i could make one and send it to you ???

 

Hello Ian,

I was using a Digitrax DCS50 Zephyr with a direct connection from its track output. I also tried with my DT 402 throttle just in case the Zephyr wasn't sending any packets for some reason. 

That is a very kind offer to make a DCC interface board but my Arduino is a Uno. Will that make a significant difference? It would be good to compare my effort with one which works. 

I originally built mine by copying the arrangement shown in Ray's two photographs but when I checked it against the circuit diagram which Ray had posted earlier in the thread it didn't seem to match up so I reworked it to match the diagram. This is really new territory for me so I am almost flying blind and it is all helped by working on a Mac when all the worked examples illustrated are for Windows machines!

 

Thank you .

Geoff

Link to post
Share on other sites

  • RMweb Gold
On 12/07/2017 at 20:04, tender said:

Hi Geoff.

If you can post a picture of both sides of your board i will have a look and see if any things amiss.

 

Ray.

 

Hello Ray,

Ian Jeffery has been assisting by email and spotted that I had the 1k and 10k resistors transposed. I have swapped them round and it seems to work now.

Thank you for your help and as I said to Ian, don't go away there is a long way to go yet for me. I have to wait now for the magnet which is on back order, probably stuck somewhere like the north pole.

 

Geoff

 

 

 

IMG_4576.jpeg

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

  • RMweb Gold

Hi Geoff, Ian

Glad you got the DCC interface sorted. Keep us updated with progress.

 

Ray.

 

Will do Ray. I need to sort out the motor mounting before I can progress much further as my turntable is already installed in my layout.

 

Geoff

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