PDA

View Full Version : Arduino Question



emmdom
25th Jul 2013, 07:26 PM
Hello

First if this is in the wrong section I apologies in advance. I was working up some schematics on how to run my model train when I ran across the arduino post below. I read though all nine pages and was fascinated on what this little board can do and how I believe it can work for me. Unfortunately after reading and watching youtube vids I am unsure as to what I need and if it will cover all my basis.

I want to control with PWM two trains (three if my f units are running) at once along with my turn outs with the arduino. Can I do this with one Arduino Uno R3, and a Adafruit Motor/Stepper/Servo Shield or do I need a L298 Board for the Arduino instead of the adafruit board? I know I will need other electronic components which is fine but as far a microprocessor what is required.

Thanks for all the help:smile:

Nskale
25th Jul 2013, 07:35 PM
I take it you want to PWM DC trains right?

Papahnash
25th Jul 2013, 07:43 PM
Can I do this with one Arduino Uno R3, and a Adafruit Motor/Stepper/Servo Shield or do I need a L298 Board for the Arduino instead of the adafruit board? I know I will need other electronic components which is fine but as far a microprocessor what is required.

If someone on this forum doesn't have an answer, you may try posting on:

http://forum.arduino.cc/

The folks on that forum are very knowledgeable and willing to help.

pbender
25th Jul 2013, 08:00 PM
I have not used the adafruit motor driver shield, but if it is anything like the sparkfun version, it will have H bridges as the motor control outputs.

Paul

rnjorge
25th Jul 2013, 09:40 PM
I've been messing around with the arduino, but I have not come to a PWM setting that I would be happy with. Take a look at these pages:

http://modelrail.otenko.com/arduino/controlling-your-trains-with-an-arduino

http://playground.arduino.cc/Main/TimerPWMCheatsheet and

http://www.instructables.com/id/Wii-Nunchuk-Controlled-Model-Train/

As far as the arduino UNO board is concerned, it will be enought for controlling three trains. I was not happy with the noise the locos make at low speeds, even though I tried all the available PWM frequencies, so I have just given up on Arduino control.

As for turnouts, depending on what you want to do, it will use from 2 to 5 digital ports per turnout.

Using DPDT switches you can use one side to control a servo and the other to change position LEDs, with just 2 ports per turnout. The last code here works fine:

http://forum.arduino.cc/index.php?PHPSESSID=801ceb8810d9823b33a4e7347e6fe6 7e&topic=61780.0

so if you have a lot of turnouts na Arduino Mega will be better.

CSXRobert
25th Jul 2013, 09:59 PM
...
As far as the arduino UNO board is concerned, it will be enought for controlling three trains. I was not happy with the noise the locos make at low speeds, even though I tried all the available PWM frequencies, so I have just given up on Arduino control...

Get two large matching caps, 250 - 1000 uF and 16v or greater. Hook them up ground to ground and hook the + of one to the output going to one rail and the + of the other to the output going to the other rail and it will help greatly with the noise.

emmdom
25th Jul 2013, 11:40 PM
Yes I am looking into controlling dc trains with PWM. I have 10 atlas true track turnouts to control. If this is not possible I dont want to make the investment, I can do what I need to do with switches and block power, but if I can control everything my turnouts and trains without having to invest into dcc then I will look into it. I guess the bigger question is do I have enough IO on the arduino uno r3 to control the 10 turnouts and 3 trains, plus IR sensors to control the trains?

The adafruit shield does have h bridges but what I have found in my searches it that people also use the L298 board and I yet to find a post or post or vid that shows the adafruit in action. Thanks for all the help.

Nskale
26th Jul 2013, 08:51 AM
Yes I am looking into controlling dc trains with PWM. I have 10 atlas true track turnouts to control. If this is not possible I dont want to make the investment, I can do what I need to do with switches and block power, but if I can control everything my turnouts and trains without having to invest into dcc then I will look into it. I guess the bigger question is do I have enough IO on the arduino uno r3 to control the 10 turnouts and 3 trains, plus IR sensors to control the trains?

The adafruit shield does have h bridges but what I have found in my searches it that people also use the L298 board and I yet to find a post or post or vid that shows the adafruit in action. Thanks for all the help.

Well ...

The Uno has 6 alnalog inputs and 13 digital outputs, 6 of which can be PWM. So certainly you can control 3 DC motors (locos) with it (were not dealing with how you get the control signal yet, i.e. throttle method). That leaves you with 6 analog inputs and 10 digital outputs (with 3 PWM).

I use Kato turnouts which use a short DC pulse to switch them. But that comes from the DCC accessory called a DS64. However you could generate a pulse with the Arduino to do it.

But ... you have Atlas switches. I am not familiar with the control method for them. How are they switched? What type of voltage state/transition is required?

So given the I/O available, you tell me - can you use an Uno for your setup? Just think about the number of I/O pins you need vs. what is available as I've listed at the moment. There are some ways to extend the outputs with shift registers but hold that thought ...

emmdom
29th Jul 2013, 11:46 AM
I looked at my turnouts and they are connected to the AC side of my atlas power pack. When I opened the bottom of the turnout they work on a solenoid method. I attached a pic of my layout with some text which I hope helps describe what I would like to use the arduino.
I have 10 turnout switches (SW1-10)which I would like to control with the arduino, along with what I call my 7 blocks. The red lines across the track indicated places where I plan to add isolation rail joiners and spst swithces.
First I have a staging area for 4 train labeled train 1-4. The plan is to have a spst on BLK 4-7 so that I can power only the train I want to run, the spst on BLK 1-3 is so I can have some passing lanes. There are also two DPDT switches on BLK 1 and 2 to reverse the polarity indicated by the blue lines is where I isolate BLK 1 from 2. So with that do I have enough outputs on the arudino? ... I don't know if I understand correctly what you said previously then no I dont have enough IO on the arduino uno R3. I believe I need 17 digital to control the switches and blocked power spst. Not including at least 3 pwd outputs. Please correct me if I am wrong.

THanks

emmdom
29th Jul 2013, 11:49 AM
Forgot to add image.47827

rnjorge
30th Jul 2013, 10:47 AM
Well, for each turnout you would need to use two digital ouputs, one for each coil, and a circuit like the one showed here:
http://www.instructables.com/id/Controlling-solenoids-with-arduino/
That's 20 outputs plus the parts used to drive the coils.

emmdom
30th Jul 2013, 11:32 AM
Thanks Ricardo!
So from what I gather so far 20 digital for turnouts, 3 pwm (digital outs) for loco control seems to me that the arduino mega is a better fit for what I envision. Do you all know if shields that are the same form factor as the arduino r3 work with the arduino mega.

Thanks everyone.

rnjorge
30th Jul 2013, 05:25 PM
My personal opinion: It is not woth it!

I was going the same way. I have a small DC layout and I wanted a control pannel with LEDs showing the turnout position and, as I woulb be usining an Arduino I also wanted the pwm for speed control.

After a lot of investment in time and money I decided to use this for the turnouts (I'll be ordering the 10 bundle this week). http://www3.sympatico.ca/kstapleton3/751D.HTM

For speed, I got two of these http://www.bakatronics.com/shop/item.aspx?itemid=383 and, apart from the humming at low speeds, they are very good.

I only think the arduino would be a good choice if you would use servos.

But, it is only my personal opinion...

As for the shields, I have never tried with the Mega.

Let me know if you are more successfull then I was.

emmdom
30th Jul 2013, 07:37 PM
Well Ricardo after a day of research I think I may stick to the solid state approach and ditch the arduino idea. I plan on building some capacitor discharge units for my turnouts, blocking my power and using the power packs I have for now. I can build that for the same price as the arduino and the shields, plus it seems that I will still have to build additional circuits then program the unit. Very interesting idea but that adds more time which is very limited for this project. There isn't or atleast I have not found a clear cut how to run a train with an arduino there is still a lot of look here look there and that is where I am getting confused on what I actually need and what I can actually do. I wish I would have found someone who has a layout running off and arduino with a list of parts this is how I did it. Something I may want to dive into later for now I am not convinced.

Thanks again for all the help!