Geoff Bunza geoffb

One of my earlier entries:  SMA10 – Build a 17-Function DCC Decoder for about $5 ( https://forum.mrhmag.com/post/sma10-%E2%80%93-build-a-17function-dcc-decoder-for-about-5-12197796 ) generated a considerable amount of interest regarding the possible enhancement for controlling Servomotors (Servos). This is my next version of a 17 Channel Multifunction DCC Decoder based on a low cost $2.56 Arduino Pro Mini. This version supports configuring each of the 17 function pins for On/Off (LED/TTL) Control, or Configurable Blinking Control, or Configurable Servo Control, or Configurable Pairs Blinking Control. Yes, that does mean it can support 17 servos, each with rate, start point, and end point setting via DCC CV’s, per pin, as well as new LED configurable functions. Read On. Additional doc found here: http://model-railroad-hobbyist.com/node/19775There is another decoder version added herein. Look for "New Decoder Version to Control Lighting Groups" in Page 12 of the Comments: http://model-railroad-hobbyist.com/node/19446?page=11   The most recent Update can be found here: SMA20 New Low Cost 17 Channel DCC Decoders with PC Boards & Dual Motor, LED, & Servo Control    https://forum.mrhmag.com/post/sma20-low-cost-17-channel-dcc-decoders-ver-6-01-with-soundtriggered-soundstepperdual-motorled-and-12201920

Bemchtop.JPG 

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 1
Geoff Bunza geoffb

Building the Decoder -- Hardware

The hardware for this decoder includes little more than before: a $2.59 Arduino Pro Mini Board, a 6N137 optocoupler, a LM78L05 voltage regulator, miscellaneous resistors and capacitors, and some header pins to connect to the servos. The BIG change is the program and library modified for the job, which I make available for modeler use. I strongly suggest that you read the prior article ( https://forum.mrhmag.com/post/sma10-%E2%80%93-build-a-17function-dcc-decoder-for-about-5-12197796 ) for complete details. The Pro Mini and other parts are mounted on a piece of perf board.


erfBoard.JPG 

Perf Board

An updated diagram is included below. Again, these are available from many different sources—electronics distributors, surplus dealers, ebay, Radio shack, and Fry’s Electronics. Assembly is pretty straightforward if you’ve ever soldered a small set of components before. You could also use a solderless breadboard (like Radio Shack 276-003) to assemble a decoder. The example decoder pictured above has 17 optional LEDs connected to each “Function Output” pin. On the Arduino Pro Mini these are labeled 3-13 and A0-A5 and they directly correspond to standard DCC Decoder Functions F0 through F16. Next to each mounted LED is a three pin header for individual Servo attachment.  The Servos I use are low cost 9G Servo Motors that are very commonly used in the RC hobby. They are available in many hobby stroes, and can be ordered direct from Chinese manufacturers through ebay at a steep discount. Note: while cheap servos are available, their noticeable characteristic is a great variability from servo to servo, including swing measure, noise, and current draw.
Servo.JPG 

9G ServoMotor

The Servo needs three connections per servo:  a ground, or common (black), +5 Volt power (Red), and a control signal (often White). The control signal is directly connected to the Arduino Pro Mini Pins labeled 3-13 and A0-A5. Ground connects to the Pro Mini GND connection. The power supply, realistically, should be separate from the DCC bus (rails). You will need a +5 Volt supply to power the Servos. This new supply can also power decoder logic, so this will minimize the load on the DCC lines. Each Servo can have a peak current draw of about 140ma, so 17 can draw 2.4 Amps! If you operate fewer, you’ll need less power.

o%20Mini.JPG 

The materials were all hand soldered.  You don’t need to mount any of the LEDs on the board.  I did it as a test and demo. As before the LEDs I used need only about .1-.2ma for a bright indication. The LEDs you use may need a lower dropping resistor than 10K Ohms. If you control a Servo with a particular function pin, I recommend that you remove the LED at that pin. Regardless, you should cut off the surface mount LED Pin 13 indicator or its dropping resistor on the Pro Mini Board, as it is both redundant and may interfere with the function assigned to that pin. Capacitor C8 (270pf) is important for increased noise immunity. Make sure you place C8 as close to the 6N137 as possible.

Partial Bill of Materials:

Arduino Pro Mini atmega328 5V 16M    (  from EBay:   http://tinyurl.com/kexh66b )   $2.59

(This price varies. I've seen it as low as $2.25. Search Ebay for "Pro Mini." Price often includes free shipping.

Digikey example parts ( http://www.digikey.com):

160-1791-ND                   OPTOCOUPLER HS LOGIC OUT 8-DIP         0.73

LM78L05ACZXCT-ND  IC REG LDO 5V 0.1A TO92-3                           0.44

493-5914-1-ND                CAP ALUM 220UF 25V 20% RADIAL            0.38

DF005M-ND                    RECTIFIER BRIDGE 50V 1.5A 4-DIP             0.45

1N5819FSCT-ND            DIODE SCHOTTKY 40V 1A DO41                  0.50

P5149-ND                        CAP ALUM 22UF 25V 20% RADIAL              0.20

445-8421-ND                   CAP CER 0.1UF 25V 10% RADIAL                 0.29

BC1018CT-ND                CAP CER 270PF 50V 5% RADIAL                  0.35

CF14JT10K0CT-ND        RES 10K OHM 1/4W 5% CARBON FILM      0.10

CF14JT5K10CT-ND        RES 5.1K OHM 1/4W 5% CARBON FILM     0.10

1N5819-TPCT-ND           DIODE SCHOTTKY 40V 1A DO41                 0.39

LEDs: try looking for some at Surplusgizmos.com like Part Number LBT30W2C-CUA-C   3mm LED 20ma Bright White 15,000 MCD  0.30     or at Allelectronics.com like CAT# LED-83  3mm diameter T-1 LED. Ultrabright white   0.95

I usually buy white LEDs and then color them with Clear Tamiya paint to suit the situation.Learn more about using LEDs here: https://forum.mrhmag.com/magazine-feedback-was-ezines-891776

The boards I use can be found here:  zip decoderpcbs.zip
They're cheap, double sided with plated through holes.

Construction Comments Addendum
1. Use only the library I provided in the Zip file, previous editions will not work.
2. The green LEDs used as Function indicators are especially bright even with very low current. With a 10K dropping resistor normal LEDs you might have may not light up. Try using a lower value resistor -- closer to 1K for more normal LEDs. (I get these from surplusgizmos.com listed as 3mm green LED).
3. To get the LEDs to fit side by side on .1inch centers, I used a sanding disk mounted in a moto tool to sand the sides down just a bit in parallel with the LED pins. They are plugged into an IC socket cut and soldered to the board-- it keeps them in somewhat neat order.


derSmall.jpg 

17 Channel Configurable Multifunction DCC Decoder Schematic (A4-A6 connections omitted)

r%26Pins.JPG 

Building the Decoder: Big  Changes Inside - New Decoder Code

The Arduino Pro Mini needs to be loaded with the decoder program which you can download from here (updated November 26, 2016):

http://mrhpub.com/files/users/geoffbfiles/new-dual-multifunction-decoderv5_4.zip

There are two folders in the zip file: NmraDcc and SoftwareServo

If you have set up and installed the Arduino development code from http://arduino.cc/en/Main/Software  (Read on for details)

Then copy both folders to \My Documents\Arduino\libraries on yourcomputer. Then look for Eamples in NmraDcc and you will find Dec_15Serv_2LED_6Ftn,Dec_13Serv_4LED_6Ftn, Dec_10Serv_7LED_6Ftn, and Dec_17LED_1Ftn.

Respectively representing pre defined decoders with 15 Servos F0-F14 and 2 LED F15-F16, 13 Servos F0-F12 and 4 LEDs F13-F16, 10 Servos F0-F9 and 7 LEDs F10-F16, and last 17 LEDs F0-F16 like the original decoder I presented. Servos are controlled from end to end of their throw by the respective Function (On/Off), each end of the Servo throw is controlled by the Start and Stop CV for the Function, and the rate of travel can be set as well—per Function.

Open one of the sketches (programs), set your decoder address, and you are good to go!  Once you have loaded the Pro Mini, remove the “//” in  the line: “//#define DECODER_LOADED” so it looks like below:

/ ******** UNLESS YOU WANT ALL CV'S RESET UPON EVERY POWER UP

// ******** AFTER THE INITIAL DECODER LOAD REMOVE THE "//" IN THE FOOLOWING LINE!!

#define DECODER_LOADED

And then RELOAD the Pro Mini. This will set up all the default CV’s and then permit you to modify them with your DCC controller of choice. You can even reset the short address in CV 1.

In the first 3 decoders, you can set the function you want per Function Output Pin. Starting at CV30 each function (F0-F16) can be set like this:

Function 0

30  Configuration for the Function:  0=On/Off, 1 =Blink, 2=Servo Control, 3=Double LED Blink

31  Rate  Blink=Blinking Rate (higher=faster) , Servo=Move Rate (higher=faster)

32  Start Position for Function=0 (for servos about 26 or so)

33  End Position for Function=1  (for servos about 140 or so)

34  Current Position or Value (For Servos make this the same as Start Position)

Function 1

35  Configuration for the Function:  0=On/Off, 1 =Blink, 2=Servo Control, 3=Double LED Blink

36  Rate  Blink=Blinking Rate (higher=faster) , Servo=Move Rate (higher=faster)

...

The Double Blink Function Configuration 3) will alternately blink the designated pin and the pin immediately following (as for a crossing gate). Do NOT set the following pin to a Servo configuration. Special programming was added so starting up many servos would not cause a major current surge for the power supply.

If you change a configuration CV it is recommended that you either reset the Pro Mini or power cycle it after you make all your changes.

You can set CV120 to 120 (decimal) and power cycle (off/on) the decoder and it will reset to ALL CV values in the original load list. You can also edit the CV “Factory Reset” list yourself. It looks like:

VPair FactoryDefaultCVs [] =

{

  {CV_MULTIFUNCTION_PRIMARY_ADDRESS, This_Decoder_Address},

  {CV_ACCESSORY_DECODER_ADDRESS_MSB, 0},

  {CV_MULTIFUNCTION_EXTENDED_ADDRESS_MSB, 0},

  {CV_MULTIFUNCTION_EXTENDED_ADDRESS_LSB, 0},

  {CV_DECODER_MASTER_RESET, 0},

  {30, 2}, //F0 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

  {31, 1},    //F0 Rate  Blink=Eate,PWM=Rate,Servo=Rate

  {32, 28},   //F0  Start Position F0=0

  {33, 140},  //F0  End Position   F0=1

  {34, 28},   //F0  Current Position

  {35, 2},  //F1 Config  0=On/Off,1=Blink,2=Servo,3=Double LED Blink

  {36, 1},    // Rate  Blink=Eate,PWM=Rate,Servo=Rate

in your sketch. Change ONLY the value after the CV number in the list.

If you did everything right, you can control your decoder and turn on and off 17 functions at will. You will note that as the decoder powers on, it will run through a test cycle turning all functions on, then all functions off—and only once. If you don’t want this, you can simply delete the test in the code which are:

  for (int i=1; i< = numleds; i++) {

     digitalWrite(ledpins, HIGH);

     delay (tim_delay/10);

  }

  delay( tim_delay);

  for (int i=1; i< = numleds; i++) {

     digitalWrite(ledpins, LOW);

     delay (tim_delay/10);

  }

  delay( tim_delay);

You do not need to know to understand the program at all. Simply set the address and load it. You are always welcome to learn more, but it is completely usable as is.

You can get a step by step cookbook for loading the Pro Mini here:

https://forum.mrhmag.com/post/scale-model-animation-8-starting-projects-and-virtual-rooms-for-modeling-12196257

You will need a USB cable to load the program. You can get one here:

http://tinyurl.com/lydcv99

It can be used again and again for more decoders and future projects.

Once you get it assembled and programmed, hook it up to any DCC track bus and power supply, and away you go!

This video will give you another look at the decoder:

The original NmraDcc library was obtained from the “Model Railroading with Arduino” website ( http://mrrwa.org/) which is made available free for personal use under a GNU general public license. This was a version written by Alex Shepherd from 2012. Many thanks for Alex’s work.

Each of the decoder ‘loads”/sketches shown here are completely usable by themselves. With a little more work than just copying and editing you can build complex functions beyond what is presented here. Because this is an Arduino, a “Function” could also read a pin instead of outputting to it. The possibilities for your own special functions are endless!

Comments and appropriate suggestions are always encouraged.

Have Fun.  Best regards,

Geoff Bunza

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
GetSmart007.5

servo shield

would the adafruit servo shield,which can control 16 servos work with the arduino pro mini???

 

Also Geoff what kind of relay(solid-state) would you recomend for an electro-frog.

 

Geoff maybe mrh needs to setup a seperate forum for DIY electronics/animation for DCC/DC.

 

Reply 0
Geoff Bunza geoffb

@Getsmart / noname

Hi, 

The servo shield is electrically but not mechanically compatible with the Pro Mini.  If you want to use "shields" with an Arduino for assembly convenience, use the Arduino Uno board (bigger, more $$, but shield compatible) and the Uno uses exactly the same processor as the Pro Mini - the mega328P.

This means the sketch (software) provided herein should work just fine.

You can use a 4.5Volt DPDT DIP relay directly driven by an Arduno pin. Check Digikey or, Mouser, or Allelectronics for the relays. I had considered another option to pair a second relay control pin as another configurable function, but have no immediate need myself. Also am considering a 3 position servo control in the same thinking.

Best regards,

Geoff Bunza

 

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Dave O

Nice update Dr. Geoff ...

Still awaiting parts to be delivered, so that I can give this stuff a whirl.  Really, it is wonderful to have folks such as yourself and the others who have posted these types of "projects" around to help minimize the "risk of failure" by those of us who want to give it a go.  Thanks again, for posting.

Reply 0
tomd

Thanks for this Geoff

Geoff:

I just want to say thanks for this!

I have multiple projects where I want to use servos planned.  I have begun to work on the first one using the Zimo MX82E controller.  But this cut the price way down. I placed quite a few orders last night!

This is forcing me to use my very rusty EE and programming background - a good motivator.

Thanks again.

Tom

Reply 0
Babbo_Enzo

It will nice if 8 pins are

It will nice if 8 pins are devoted to input like fascia switches , and the other 8 pins are for servo.... and ...

- how to drive 8 frog switch ???

- how to report turnout position?

Well ... maybe to much!

Thanks anyway for your motivation! Great source and article!

 

Reply 0
Geoff Bunza geoffb

@Dave, Tom and Enzo

Hi Guys,

You are most welcome.

Have fun.

Best Regards,

Geoff Bunza

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Geoff Bunza geoffb

Opening the Floodgates for Suggestions

Hi Enzo,

Quote:

It will nice if 8 pins are devoted to input like fascia switches , and the other 8 pins are for servo.... and ...

- how to drive 8 frog switch ???

- how to report turnout position?

These are completely appropriate suggestions/requests. First, a couple of comments:

I am considering building (reprogramming) a version of the decoder, such that when the sevo has traveled to one end or the othe, a second set of pins corresponding to each servo would indicate 0 or 1 (Ground or +5Volts) and these could be used for signaling, or to drive a LED indicator, or to drive a small dual-inline-package (DIP) relay like: http://www.allelectronics.com/make-a-store/item/rly-625/5-vdc-dpdt-dip-relay/1.html

This would enable  you to use the servo to throw a turnout, power the frog, and indicate the position of throw. Obviously it would use anther pin (of the 17 available) per servo, so it would be limited to controlling 8 servos.

Likewise, a fascia switch could be used to control turnout position, but it would also use another pin per servo (now 3 per servo) so a total of 5 servos could be supported. But it would seem to me that the fascia switch would substitute for DCC control, so only the endpoints and throw rates would use the DCC interface.

Are these versions useful to modelers?

Now for opening the floodgates! I would like to ask what people might like to see for alternative feature sets? Since some of these are not what I would use these for (animation being in my foremost thinking), let me know via this forum, what might be worthwhile, and as time and interest permits, I might be able to make these available for modeler use! You are prompted to think beyond turnout control, but please realize that I don't want to spend all my modeling time doing updates for these. For example, how would you envision DCC control of a 3 position semaphore? 3 DCC functions?

I would also like to encourage others who have found new uses for these, and/or developed new functions for these to share their results and work too! In fact, I very much hope this will spur more modelers on of all interests to try these out. I have no vested interest in this, I just love to see people get enthusiastic in what they do.

Best regards,

Geoff Bunza

 

 

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
GetSmart007.5

Better Mouse trap..and they will come knocking at your door

You could have them connected to your fascia and handle more than 8 inputs then send out a communication signal (radio/whatever) to multiple receivers which each could control 16 servos/relays/ir-dots/crossings/semaphores/dancing bears leaving foot prints in the mud/light-dark detectors/sound/lights/smoke/camera/action/bombs bursting in air/a rockets launch red glare/flags a waving/ air  flow/water flow/lighting effects/turnout control/toilets flushing/turntables turning/cows isa mooing/freshly learned fishermen fishing/frying pans frying by the camp fire/

< noun> < verb> / < noun> < verb> < object noun> / if < this> then< verb> /do while< condition> < action verbs> /         ......etc. 

Have you seen what those Europeans have been doing with their animations.  Where as we in North America have been procrastinating, they are procreating, We have had our heads in a box, so lets think outside the box.

Geoff and the others  along the way have given us a means by which we can build our own programmable stationary decoders (mobile not yet, footprint is too big) with multiple connectivity across the layout and each with multiple functionalities.  The possibilities are enormous.   Mobile maybe yet still to come.

Jumping Gee Wilercures Batman.

 

Reply 0
Dave O

Turnout Control with servos ...

... is something that I could see myself doing.  Initially, the plan is to just manually operate them from the fascia, but having a controller perform the actual operation opens up some interesting possibilities.

Reply 0
Benny

...

Turnout indication and signaling outputs would be the next step, though these elements could be driven by using the turnout position itself and the polarity of the frog as a relay [using electro frogs,of course]

Having the indicator wires coming right off the decoder would clean up wiring, though.  But again, you may not have to give up a function for each LED indicator.  Control wire receives 0, lED goes Red; Control Wire receives 1, LED goes Green.

The big question here is, if I have a three position [yellow], how do I get the half step? [Stop the servo half way].  I have a 3 position semaphore, for example, it has that middle yellow position and it is tricky getting that middle position.

Very slick decoder, it's definitely going to improve work with signaling!

--------------------------------------------------------

Benny's Index or Somewhere Chasing Rabbits

Reply 0
Geoff Bunza geoffb

@ Benny 3 Position Semaphore

Hi Benny,

The 3 Position Semaphore is relatively easy to set, like the stop and start positions of the servo are set now. One would create a third CV to control the middle position. Each CV is a number from 1 180. In the case of the servos I use, about 26 to 140 sets the maximum swing, so somewhere near 83 is likely the midpoint of travel.

What I would like to know is how would you like to select each of the 3 blade positions? Perhaps with 3 functions per semaphore? Say F10, F11,and F12? Is this acceptable? Do you have another way one might do it?

Thanks for your ideas.

Best regards,

Geoff Bunza

 

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Benny

...

That would be a very simple method of setting blade position, giving it its own button/command prompt - my preference, of course.  Granted, most people I'd talked to consider signaling to be an automatic function, whereas the system does the work automatically.

--------------------------------------------------------

Benny's Index or Somewhere Chasing Rabbits

Reply 0
barr_ceo

There was quite a bit of discussion

There was quite a bit of discussion about servo/semaphore control of three position signals on one of the newsgroups several years ago. IIRC the preferred method at that time was to use a single function and have it cycle through the three positions - red-yellow-green, red-yellow-green. This would make it easier for a "signal tower operator" to run signals with a throttle. With more memory available now, though, that may be a moot point. I believe the desired adjustments were:

Max Point, Min Point, Center Point, Speed, rebound/bounce (especially useful for crossing gates) and light functions Off, On, Alternate Flashing, and flash rate.

Given the space that seems to be available for programming in this, I'd suggest a "random flash rate"  and "random duty cycle" also, suitable for anything from a flickering campfire to a welder's torch.

Reply 0
John C H

Push button and LED on one I/O pin

Geoff

I have Tam Valley Depot servo control boards on my layout. Studying the boards and reading all of Duncan's information, leads me to believe that the system that they use is one I/O pin does double duty of sensing the switch and driving the LED by switching back and forth between input to output. Granted, they use a PIC but an Arduino should still be able to control 8 servos, 8 LEDs and sense 8 buttons. I haven't done it yet but certainly think it is feasible. 

John Houghton

Collingwood, Ontario

 Canada 

Reply 0
HVT Dave

LocoNet on the Arduino Pro Mini

Geoff’s thread about the 17-function decoder has inspired me to learn about the Arduino.  The first application I have for the Pro Mini is on a test roadway for my Faller cars.  The road is built inside a circular HO and N scale test track and is currently powered by a Tam Valley Quad-pic.  On more than one occasion I have inadvertently reprogrammed the Quad-pic while programming a loco so connecting to LocoNet rather than the DCC track power is very appealing.

While waiting for my Arduino Pro Mini(s) (only ordered six) to arrive from China I have put together the following circuit diagram.  It shows typical connections for input/output.

20Out(1).jpg 

EDIT: Corrected a resistor value.

The schematic and PCB design for a LocoNet shield compatible with an Arduino Uno is available on the SPCoast website.  http://scuba.net/wiki/index.php/LocoShield  (the website appears to be down at the moment so you may have to try back later).   The code is available at http://sourceforge.net/projects/mrrwa/    I have redrawn the schematic to work with the Arduino Pro Mini.  It requires a comparator, an NPN transistor and some resistors.

I have chosen the LocoNet shield because 1- I have LocoNet and 2- it eliminates encoding the commands in the command station and decoding them at the Arduino, and 3- the biggie, it will provide feedback to JMRI. The test road uses servos, Hall Effect Sensors for detection, switches and LEDs.  One of the LEDs connected to pin 10 illuminates when the output is Hi and the other when the output is Lo.  On the control panel that will show which route is active.  This feature would also be useful for alternating flashing lights such as at a crossing.

The Arduino has so many possibilities.   I will keep you posted on my progress.

Dave

Dave

Member of the Four Amigos

 

Reply 0
Geoff Bunza geoffb

@barr_ceo

Hi,

Thanks for the info and suggestions-- very good! More to consider.

Best Regards,

Geoff

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Geoff Bunza geoffb

@John re: Pushbutton

Hi John,

Thanks. I had forgotten about that old trick. That will save a pin... very good indeed,

and completely do-able on the Pro Mini.

 

Best Regards,

Geoff

 

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Geoff Bunza geoffb

@Dave Re: Loconet

Hi Dave,

While not everyone uses Loconet (I do), I'd love to see you write-up your results and post it in the forum. I think others would enjoy seeing your work too.

Best regards,

Geoff

 

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Logger01

Arduino Expansion

John,

In some applications the I/O pins on the ATmega328 (Pro Mini) can be multiplexed, but for home brew projects usually not worth the hassle especially when off the shelf expansion solutions are available. Using only two of the Pro Mini's I/O pins (A4, A5) the Adafruit 16-Channel 12-bit PWM/Servo Shield - I2C interface would be one example (If the cost is to high you can build this circuit on a bread board for about $5). These designs are expandable, and still using only two pins similar I2C boards can be built to support various additional I/O functions (eg. http://SX1509 16 Output I/O Expander Breakout). The supporting software is free.

If you really need to push the I/O it would probably be easier to use one of the other Arduino platforms such as the Arduino Leonardo with twenty I/O pins or really pushing it with the Arduino MEGA with 54 digital input/output pins (of which 15 can be used as PWM outputs), 16 analog inputs. The Arduino versions of these boards can be moderately expensive, but I have seen clones go for ¼ of the list (similar to the Chinese Mini Pros).

Or just use additional Mini Pros.

 

Ken K

gSkidder.GIF 

Reply 0
Michael Tondee

Loconet and JMRI

So if I'm understanding correctly Dave, your circuit makes Geoff's decoder Loconet and JMRI compatible? If so, that sounds like the road I want to travel down.   Right now, I manually throw my turnouts  but since I have a dedicated notebook PC right by my Digitrax Zephyr, I have been intrigued by throwing turnouts and setting routes via JMRI but I just have not had the budget to invest in commercial hardware to do so.  This is looking like something I can afford to do though and since  I have the know how with electronic components  I'm getting excited about the prospects.

Michael

Michael, A.R.S. W4HIJ

 Model Rail, electronics experimenter and "mad scientist" for over 50 years.

Member of  "The Amigos" and staunch disciple of the "Wizard of Monterey"

My Pike: The Blackwater Island Logging&Mining Co.

Reply 0
John C H

10 servos on 2 channels

Geoff

Here is a link for setting an Arduino to control many servos with few channels, which leaves lots of room to do other things at the same time on the Arduino. 

http://diydrones.com/profiles/blogs/drive-10-servos-using-only-2

 

John Houghton

Collingwood, Ontario

 

 Canada 

Reply 0
HVT Dave

@ Michael - LocoNet and JMRI

Michael,

Yes, the circuit shown on my earlier post will connect to LocoNet and hence can be controlled by JMRI.  Using LocoNet should allow you to utilize the input capability of the Arduino to give feedback for such things as occupancy and turnout state.  Open source JMRI is a good fit to open source Arduino.

Geoff's decoder circuit does have the advantage that it will work with any DCC system, albeit sans feedback.

Regards,

Dave

Dave

Member of the Four Amigos

 

Reply 0
tomttt

Geoff very nice piece of

Geoff

very nice piece of work.

only new back in the game and love seeing thinking out side the box.

question

after in the loop part of sketch after

  if (FuncNum==1) {  //Function Group 1 F0 F4 F3 F2 F1
      digitalWrite( FunctionPin0, (FuncState&0x10) 4 );

And Im assuming that when you hit F1 that it write to functionPin 0,

can you put in a fade up command like

if (switch1State == 1) {
for(int fadeValue1 = 20 ; fadeValue1 < = 60; fadeValue1 +=50)
    // sets the value (range from 0 to 60):
    analogWrite(led1, fadeValue1); 
for(int FadeVaule = 60);

 

so if I hit F1 or any other how do i write it to do something other than on, off.

not quite sure where/ how to put it.

if you can give an example of code use just F1 turn a led on with fade.

from the the and with the other sketches i work it out.

Many Thanks

Tom

 

Reply 0
Reply