Jump to content
 

Arduino accessory decoder experiments


Recommended Posts

Wow impressive! I didn't even know there was a dcc 'stop all' command (something else to google/rmweb search/youtube)..

 

Perhaps you can write an algoritm on the arduino to calulate the winning lotto numbers by flashing leds... Don't forget who gave you the idea!  :sungum:

Link to post
Share on other sites

  • 1 month later...

Eldavo (or anyone else) any chance of some detailed pictures of the arduino setup (I am not very good at understanding electronic circuits but I can copy what someone else has done) and the sketch to operate it. I would dearly love to create a multi servo system rather than peco type point motors.

Thanks in advance

Link to post
Share on other sites

Re how to trigger a relay. If you're using a switch to signal the Arduino giving either 5v or 0v to a pin, couldn't that same wire be used to trigger the relay? I guess you need latching relays if it is a momentary switch.

 

Also, what is happening with switch bounce in all these installations? Sorry, didn't read the code to see if there is some delay in there.

Link to post
Share on other sites

  • RMweb Premium

Re how to trigger a relay. If you're using a switch to signal the Arduino giving either 5v or 0v to a pin, couldn't that same wire be used to trigger the relay? I guess you need latching relays if it is a momentary switch....

Lots of very cheap compatible relay units available on eBay. Typically about 99p for a unit with 2 single pole relays. Considerably cheaper than buying a single relay, transistor and attendant bits!

 

Cheers

Dave

Link to post
Share on other sites

1) you can't use the output to control a relay directly, nor use the pin as input and output at the same time: it's one or the other. You can program the pin as input and in the loop change it to output to control the transistor that controls the relay, but then you loose the ability to detect the switch. And the loop has to have a time-limit so that the pin is reprogrammed as input. Not a good practice and frankly a bad idea.

 

2) switch debounce should be done with a small capacitor, easier by a considerable margin over s/w debounce :rolleyes:  Use 100nF across the switch terminals.

 

1. What if I had a pull-down resistor on an Arduino input pin, and that wire was also connected to the relay's operating pin (a 5v operated relay). There is also a switch on that wire, and the other side of the switch is connected to 5v. What would happen when you close the switch? Would both the relay pin and the Arduino pin get 5v or would one of them not trigger? If this doesn't work using a latching serial-in-parallel-out IC could be used if there are more than 2 or 3 relays and switches.

 

2. So just put the cap across the switch terminals and that's it? Pretty easy!

Link to post
Share on other sites

But conceptually, you could have a switch that triggered a relay, and the line between them could be attached to the input pin of an arduino, so you could trigger a software event by the action of turning the relay on. Given the high impedance of the input pins, you'd probably get away with it, but some kind of diode to dump the back emf when the relay was turned off might be a good plan.

 

But why bother?

 

If you use a switch to trigger a software event, it can output a driver signal to ine of those cheap eBay relays as part of the program, but this "costs" two I/O pins...

 

HTH

Simon

Link to post
Share on other sites

I have a board of 4 relays triggered by 5v which an Arduino can switch on/off. What I didn't realise is that they are activated by grounding them, not giving them 5v. They are optically isolated, but can still use the Arduino power to power the relays.

 

Anyway, while waking up this morning it occured to me that perhaps having a line with a pull-up resistor going to the relay and the Arduino pin, that can be switched to ground, might work. That way the Arduino can look for level changes on that pin, and the power for the relay isn't coming from the Arduino itself (even though it could), but from the power supply.

 

I'll try it soon. I'm just reluctant to add any more mess to my desk :(

 

Regards,

David.

Link to post
Share on other sites

  • RMweb Premium

...but can still use the Arduino power to power the relays....

I hope you don't mean powering the vcc/vin on the relay board from the 5volt ouput on the Arduino. There is only 400milliamps available from the Arduino voltage regulator to power the board and all it's outputs. It would be a far plan to provide a separate 5volt regulated power supply to both the Arduino and the relay board.

 

Personally I have played around with relays and various circuits with Arduinos and have a pile of dead/semi-dead Arduinos to prove it. Stick with the self contained relay boards and you are unlikely to have problems.

 

There is no reason you shouldn't use a switch to clamp the input of a relay board to 0volts and have an Arduino input monitoring the switch output. You could even have the Arduino switch the line to zero to override the switch. The provisos of using digital ports as both input and output as outlined earlier still stay.

 

Cheers

Dave

Link to post
Share on other sites

  • 3 months later...

I was thinking of using this setup for my turnouts and I may have a solution to the polarity of the turnout that doesn't require a relay to change polarity.

 

I was thinking of using a DPDT toggle switch with an ON-ON configuration.  This would have 6 pins on the switch, 3 of which you would use as input for the arduino.  The other three would be used to switch the frog polarity.  The two input pins of the toggle would be the two different polarities and the center would be wired to the the frog.  Since the toggle would be in one position or the other, the polarity would match the position of the switch.  When the switch is thrown, the polarity changes.

 

How would the arduino be set up to recognize a toggle being thrown one way or the other as input device?  I'm guessing only two pins of the toggle would be needed.

 

 

post-19799-0-05025800-1470070416.png

Link to post
Share on other sites

  • RMweb Premium

I was thinking of using this setup for my turnouts and I may have a solution to the polarity of the turnout that doesn't require a relay to change polarity.

 

I was thinking of using a DPDT toggle switch with an ON-ON configuration.  This would have 6 pins on the switch, 3 of which you would use as input for the arduino.  The other three would be used to switch the frog polarity.  The two input pins of the toggle would be the two different polarities and the center would be wired to the the frog.  Since the toggle would be in one position or the other, the polarity would match the position of the switch.  When the switch is thrown, the polarity changes.

 

How would the arduino be set up to recognize a toggle being thrown one way or the other as input device?  I'm guessing only two pins of the toggle would be needed.

I have used a similar approach on line no20 ie a dpdt switch one output to a arduino to control the point servo the second  to a cheap relay board from that auction site which control polarity of the point

 

 

post-1480-0-96316300-1459173711.jpg

 

 

nice and simple 

 

Nick

Link to post
Share on other sites

  • RMweb Premium

...How would the arduino be set up to recognize a toggle being thrown one way or the other as input device?  I'm guessing only two pins of the toggle would be needed.

Indeed you do only need two switch pins. Connect the common connection to 0v and the relevant other switch connection to a digital input pin on the Arduino. In the Arduino code setup() function set the digital port up as an input and do a digitalWrite to it with a value of HIGH to activate the internal pull up resistor. In your loop() function do a digitalRead and compare to LOW to recognise when the switch has been activated.

 

Cheers

Dave

Link to post
Share on other sites

How would the arduino be set up to recognize a toggle being thrown one way or the other as input device?  I'm guessing only two pins of the toggle would be needed.

The usual way with an Arduino is to use pinMode(myPin, INPUT_PULLUP); and arrange the switch to connect that to GND in one position. The pin will then read HIGH when the switch is open.

 

...R

Link to post
Share on other sites

  • 9 months later...

I went all the way through this thread (Sorry if I was blind), but couldn't find anything about how to connect an Arduino to a DCC Signal.

Then, I came across this website:  https://talkingtracks.com.au/

They have a free Download available that has a Circuit, a layout on Veroboard (I love that stuff), and construction notes.

 

On another page, they also compare the Arduino ProMini with, the Arduino Nano.  They say the Nano is better, because you can get Shields for it easily.

 

___

post-30665-0-16096400-1495394191.jpg

I got the attached picture off their website, and found it on eBay.  There is a Power Supply connected to the I/O Shield, that powers the Servos, so no issue with affecting the Arduino.

 

What's even better, is that with some servo extension leads, the whole thing can be done without soldering.

 

___

But, if you want to learn how to solder, they have that covered too.

Go to this page:  https://talkingtracks.com.au/TT_Technique_001.shtml

 

There are 4 YouTube videos that explain it all.  It's quite funny actually, there are videos from 2 people, that tell you to solder almost opposite ways.  These guys explain what's right, and it isn't either of the guys on YouTube, its a combination of both of them.

 

___

I know it sounds crazy, but you can actually connect up to 17 Servos to a Nano.  Most people think you need a PWM Output, but servo control is all done in Software, so any Digital Pin is fine, which includes A0 to A5.  It's the Arduino IDE that prevents you using A6 - A7 as Digital Outputs, not the MicroController itself.

 

The website talks about how people seem to want to get as many devices as they can to be controlled by a single Arduino.  They have a picture of a guy in the USA with 15 servos attached.  The wire tangle must be amazing.

 

Their preference is to have fewer devices connected, so that your wiring is easy.  If you have a yard with lots of points, then you could control more servos.  But, if your points are a long way apart, then does it make sense to run 15 or so long wires back to one Arduino.  They are really cheap these days (eBay is great for finding sellers).

 

___

Someone here talked about how the ProMini can't connect directly to a PC.  You need an interface.  I bought 2 of the USB interfaces, and neither of them worked.  Apparently, there is an Intellectual Property issue, and some clones get blocked by the Driver software.  On the other hand, the many Nanos that I've purchased just work.

omeone here talked about how the ProMini can't connect to a PC,  I bought 2 of the USB interfaces, and neither of them worked.  Apparently, there is an Intellectual Property issue, and some clones get blocked by the Driver software.  On the other hand, the many Nanos that I've purchased just work.

 
Link to post
Share on other sites

I went all the way through this thread (Sorry if I was blind), but couldn't find anything about how to connect an Arduino to a DCC Signal.

What Atmel microprocessor is on the red board in the photo? I think the surface-mount Atmega 328 has extra I/O pins compared to the DIP version which is used in the Uno.

 

...R

Link to post
Share on other sites

  • RMweb Gold

You can control up to 992 servos from 2 Arduino pins, using vast numbers of these 16 channel boards!

http://www.ebay.co.uk/itm/191740763065

 

I've got a couple of them to try on my DC layouts, but haven't used them yet.

 

 

Hmm, now this is interesting to me!  I presume the boards are either receiving a multiplexed signal or have some kind of addressing them?  Can anyone enlighten me further as to how you can get 992 servos connected - not that I want that many, but a couple of hundred yes!  I was thinking of a PIC or Ardunio set up to control them, but this is a different sphere totally!

 

Rich

Link to post
Share on other sites

Hmm, now this is interesting to me!  I presume the boards are either receiving a multiplexed signal or have some kind of addressing them?  Can anyone enlighten me further as to how you can get 992 servos connected - not that I want that many, but a couple of hundred yes!  I was thinking of a PIC or Ardunio set up to control them, but this is a different sphere totally!

 

Rich

This is one of the pages I found on using a single board.

https://www.hackster.io/jithinsanal1610/servo-motor-using-arduino-pca9685-16-chanel-module-d9666e

 

I did find some instructions on using multiple boards, but as I don't need 16 servos I didn't save the link. Googling for Arduino and PCA9685 should bring up plenty of useful stuff.

Link to post
Share on other sites

What Atmel microprocessor is on the red board in the photo? I think the surface-mount Atmega 328 has extra I/O pins compared to the DIP version which is used in the Uno.

 

...R

 

Sorry for not making it clear, but the "red board in the photo" is the I/O Shield, that you plug the Nano into.

 

The Nano has Input-Output Pins that go to the Blue Pins on the Shield.  And, the I/O Shield adds +5 Volts and Ground Pins beside it, so that it is compatible with a Servo Plug.  That's how you can get a Servo Extension Lead, and just plug that into the I/O Shield, and then the Servo into the Extension Lead.

 

This connects everything from the Nano to the Servo, with no Soldering.

Link to post
Share on other sites

  • RMweb Premium

You can control up to 992 servos from 2 Arduino pins, using vast numbers of these 16 channel boards!

http://www.ebay.co.uk/itm/191740763065

 

I've got a couple of them to try on my DC layouts, but haven't used them yet.

Wish I'd found those boards a year ago, would have saved me a ton of work. We are actually using I2C to communicate between Arduino boards. We've built an Arduino nano based board that does the same thing. Cost more in components than the whole board on eBay. Will be buying a few of those I think.

 

Cheers

Dave

Link to post
Share on other sites

Wish I'd found those boards a year ago, would have saved me a ton of work. We are actually using I2C to communicate between Arduino boards. We've built an Arduino nano based board that does the same thing. Cost more in components than the whole board on eBay. Will be buying a few of those I think.

 

Cheers

Dave

I'm glad I found them right at the start of my adventure with Arduinos :). I think I've now discovered most of the useful boards that are available, but no doubt there's something I'm not aware of that would have saved me time and money!

 

One thing I didn't know until reading this topic, is that you can store servo settings in the EEPROM. I was intending to do manual testing and write the settings into the software. Now I just need to learn to separate all the DCC gobbledegook from the stuff that's useful for DC, so I can pic out other good stuff from the DCC/Arduino topics! I'm going from DC to RC, and bypassing DCC!

Edited by BG John
Link to post
Share on other sites

  • 2 years later...

Hello to everyone...

due to COVID  lockdown constraint (I am in Italy!), I am refreshing this project.

I designed a PCB and mounted the board of the Servo decoder. If someone is interested, I can share the gerber files (or EAGLE project) I sent to the HK manufacturer to receive the boards. For the first order (5 boards), it is very cheap.

 

Bye :bye_mini:

 

Decoder Servo.jpeg

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