Jump to content
 

Arduino Applications and Programs


Simond
 Share

Recommended Posts

  • RMweb Gold
11 hours ago, melmerby said:

If its power Mosfet output transistors it probably doesn't need excessive heatsinking.

Power is only dissipated if there's current flowing through a resistance and power Mosfets have very low ON resistance (possibly 0.01 ohm), control would be PWM so the Mosfet would be either on or off

Even the full 43A (at 100% drive) through 0.01ohm would only dissipate 18.5W (43*43*0.01)

With 5A only 0.25W.

 

That was meant to be a joke remark hence the Joker. I have seen it confirmed by someone that continuous use at 5A was not a problem. 

Don

Link to post
Share on other sites

  • RMweb Premium
On 23/08/2020 at 22:39, Donw said:

 

That was meant to be a joke remark hence the Joker. I have seen it confirmed by someone that continuous use at 5A was not a problem. 

Don

I sort of half thought that but decided to explain about Mosfets for those not in the know.

I'm not sure how you would heat sink those devices if you did want to control 43A:scratchhead:

Link to post
Share on other sites

I've been messing about using cheap servos as point motors and I have some experience using the Attiny44A to drive them. The general idea is to make them as reliable and inexpensive as possible whether controlled manually or through automation. More here:
https://www.rmweb.co.uk/community/index.php?/topic/121357-no-twitch-servos/

and more to follow.

 

It's possible to drive a large number of servos from a single ATtiny44A but recently it occurred to me that as they are so inexpensive it might be a better idea to distribute several of them on a layout to reduce wiring while also improving reliability. I was wondering how practical it could be for others to try these methods for themselves. I'm happy to keep sharing my code but that's no much use for someone who doesn't have the means to program an ATtiny44A. Then I found this:

 

https://www.instructables.com/id/Program-an-ATtiny44458485-with-Arduino/

 

I have not tried it but it seems it's possible to program the Attiny with an Arduino. I do have an earlier Arduino clone (not the UNO) and if I can summon up the energy I'll give it a shot to see how it goes.

 

(Up until now I've been using an AVRisp to program the ATtiny44A)

 

Link to post
Share on other sites

3 hours ago, AndyID said:

(Up until now I've been using an AVRisp to program the ATtiny44A)

 

If it can be programmed with the AVRisp then it should be programmable with an Uno acting as the ISP. I program the Attiny84, 45 and 1634 with the Uno as ISP. The Arduino IDE includes a program called ArduinoISP.

 

...R

  • Thanks 1
Link to post
Share on other sites

  • 2 months later...
  • RMweb Premium

I have just finished reading through this thread. Many thanks for all those who have contributed.

 

My electronics knowledge is negligible and my brain seems afraid to improve that status! I have done some programming over the years with much of the recent stuff in VBA where I managed to solve a number of problems to make the (macro) user's life a little easier.

 

You may therefore judge from the foregoing that some of what has been said on here has sailed way over my head! Anyway, to business......

 

I'm reasonably confident from what I've read that the Arduino can be coded to respond to a dedicated dcc accessory address. The action that I'm hoping to achieve is that said Arduino can then illuminate the appropriate of two (colour light) signal LEDs and also drive a DPCO relay that will be used for switching dcc track power on/off to a couple of sections of track. One of the track sections will incorporate the Lenz ABC braking circuitry.

 

I can achieve this with an off the peg (colour light) signal accessory decoder using the output through a transistor (on a piece of Veroboard) to operate the relay on a separate PCB where one of the relay's changeover outputs is fed through a home-made (Lenz style) braking module also on a piece of Veroboard. No Arduino in sight!

 

My main objective is to achieve the above using as few separately mounted boards as possible which is where the ability to piggy back stuff onto the Arduino seems to be the solution. Is this achievable?

 

Where does one find what add-on/plug-in boards are available?

 

Many thanks.

Link to post
Share on other sites

  • RMweb Premium

If you search for "Arduino relay shield" you will find a number of options including both "shield" modules that plug onto an Arduino Uno and also very cheap relay units that can be driven from any Arduino with the minimum of wireing.

 

Cheers

Dave

 

Link to post
Share on other sites

indeed, you might well drive a relay shield with a transistor (well, another transistor, since they are already so equipped) and it may well then talk listen to your accessory decoder without the Arduino.  Indeed, it may not even need the transistor.

 

eBay is your friend...  starting from £2.45

 

hth

Simon

Link to post
Share on other sites

  • RMweb Premium

Thanks for those pointers. That looks like one element sorted save that the relays look to be single pole so I'll need the multi channel versions.

 

I assume that that board/shield simply plugs onto the Arduino?

 

That would just leave the home-made Lenz ABC braking module (BM1) to be catered for presumably as a separate board. Could that be "plugged into" the Arduino so that only one set of fixings are required for the hole assembly?

 

Would I be right in thinking that using an eight channel module would allow me to have up to four pairs of relays driven by an Arduino Nano and recognising 4 different accessory addresses? Although slightly deviating from the purpose of this thread it would seem that provided all 4 track sections are located in the same power district, I'd only need a single pseudo BM1 with an input from the overall track power source and individual outputs to each set of relay pairs. Does that sound correct?

 

The Arduino obviously requires a power source. I believe this is a bit flexible voltage wise although non of the relay shields that I'm looking at on eBay indicate their working current. Can the dcc accessory bus be used as that power supply source and is it with or without a separate board.

 

Please excuse the questions, the working system, which could see two or three of the circuits driven by a single Arduino, needs to be located in a weatherproof box outdoors and minimising the box size is also high on the requirement list if it is possible.

 

Thanks once again for the help so far.

Link to post
Share on other sites

In principle what Ray describes will work. 

 

I'd make sure the "power" to the relays is from the power source, not via the Nano - Nano's have a very low current output and can go "pfff" rather easily.  If using a Uno or Mega, then power from the processor board is substantially higher.  

 

Powering from DCC can be done, needs a rectifier (four fast-recovery diodes as a bridge rectifier), and then voltage regulator to bring the volts down to suitable for the Nano and the power to the relay bank.  Whether that's two regulators (one for Nano, one for relays) or one is a fine detail on the power requirements. 

 

Using DCC power is an expensive way of getting power - each Amp of DCC power costs a lot of pounds in the cost of boosters.   If you've got an excess of DCC power, then its fine, the power is already paid for, but otherwise a DC power-brick is a lot cheaper.  

 

   

- Nigel

  • Thanks 1
Link to post
Share on other sites

  • RMweb Premium

Thanks Nigel

 

There are two 12v supplies one feeding from opposite ends of the layout towards the middle so that's probably the way to go.

 

The Uno has an input power connector, that bit I've seen. Is that power line taken through to the Relay board or does the relay board have another power input connector?

 

I'm hoping that with only a 12v supply on the layout we could connect the two boards direct to that supply and not have to build our own voltage drop down circuit.

Link to post
Share on other sites

A Uno/Mega has the power input socket, which takes at least up to 12v, a genuine Uno/Mega can handle more volts, though not recommended.   I tend to run them on about 7.5 to 8v.    On the pins on a Uno/Mega there are "Vin" (ie. what you're putting in), 5v and 3.3v.   You can power relays from there.  

 

If you have 12v relay coils, I'd power them direct from the 12v supply, no point going via Uno.  If you have 5v relay coils, then can use the 5v on the Uno/Mega.   

Connect the ground from the relay board and the Uno/Mega together, and to the ground (0v) of the DC power supply.   

 

- Nigel

  • Thanks 1
Link to post
Share on other sites

I’d recommend powering the relays separately, they are hungry when on, and if you end up with a brown out once in a blue moon, it’ll be because several are imposing a load the Arduino can’t handle.  
 

78xx regs are cheap as chips if a bit inefficient, I’d go that way hell, you could buy a wall wart for each relay block, though you’d then need lots of 13A sockets...  I guess you can’t win :)

 

Link to post
Share on other sites

1 hour ago, Simond said:

 

78xx regs are cheap as chips if a bit inefficient, I’d go that way hell, you could buy a wall wart for each relay block, though you’d then need lots of 13A sockets...  I guess you can’t win :)

 

 

It's sad when the thing you are plugging in costs less than the thing you are plugging it into :)

 

  • Funny 1
Link to post
Share on other sites

  • RMweb Premium
3 hours ago, Simond said:

 
 

78xx regs are cheap as chips if a bit inefficient, I’d go that way hell, you could buy a wall wart for each relay block, though you’d then need lots of 13A sockets...  I guess you can’t win :)

 

Buck convertors are virtually as cheap and are typically 95% efficiency and can be set to any voltage required.

I've been using them for Arduino projects.

I paid £6.50 for 10 including postage. (£3.63 before post)

 

 

Edited by melmerby
  • Agree 1
Link to post
Share on other sites

  • RMweb Premium

I'm hoping that we'll only need a maximum of four relays at any one location but I take the point.

 

Daft question; Do the relay boards/shields have provision for their own power supply?

 

Another maybe not so daft question; I need to add a few components between the track power input and one of the relay's set of switch contacts. Is building them on a veroboard or similar the only option?

 

Thanks once again for all the info people keep adding.

Link to post
Share on other sites

Most of the off-the-China-boat relay boards have a row of pins: VCC, pins for each relay, ground.  The VCC takes the volts "in " to operate the board (5v or 12v depending on board specification).  Ground is 0V.  The switch pins go to the control circuit (switches, or Arduino) which connect the pins to ground to activate the corresponding relay. 

There is often (usually) a second jumper on the board which, if installed, connects the relays to the VCC.  Remove the jumper and relays are independent of the power to the input transistors/opto-couplers.  With jumper removed, the second DC power goes into one pin of the jumper to power the relays.  

 

Build other circuits any way you like.  Vero-board is one option.

 

 

 

Link to post
Share on other sites

  • RMweb Premium

Thanks Nigel

 

The "other" circuit is the pseudo BM1 module which will be linked at one end to one rail of the dcc track supply and at the other end to the normally closed contact of its associated relay so its just the five diodes and presumably a screw terminal for the track power input.

 

I'd like to think that the output from the BM1 could be via a plug-in type connection but I suspect the the relay board uses screw terminals for connections to the switch contacts so a loose wire link is probably the easiest option.

 

Thinking about it, the track power input will also need to go to the other relay's normally open contact so the input to the BM1 could come from there. I suppose I could hardwire the links and make sure the BM1 end of the hardwiring is built into our BM1s as standard to facilitate a quick swap-out in the event of a failure.

Link to post
Share on other sites

  • RMweb Premium
8 hours ago, Simond said:

I confess to never having used them, but will look into them next time.

 

could you post a link please?

 

ta

Simon

These are the ones I bought:

https://www.aliexpress.com/item/4000259403990.html

 

6 preset voltages or fully adjustable by making/breaking pcb links

  • Thanks 1
  • Informative/Useful 1
Link to post
Share on other sites

  • 2 weeks later...
  • RMweb Premium

I am a newbie to servos and Arduino, and as such I seem to be thinking of applications for them faster than I can work out how to do them.

 

I particular, I am adding a few simple animations to my layout, barriers, gates, this sort of thing. I have a bit of a stumbling block: writing non-blocking software. Supposing I have a function to sweep a servo, and this takes four seconds to do its action, I have no idea whether it is possible to use the same function concurrently (if this is the right word), to move another servo. In fact, right now I don't even know how to make such a function non-blocking and let me still call a duplicate function part-way through its activity to move the additional servo. 

 

Could anyone suggest how to tackle this? I am happy to accept the Arduino can do anything I want, but is restricted by the abilities (and capabilities) of its programmer. At the end of the day, if the animations are blocking, I am sure I can still work out a nice display. So this isn't a critical thing to me. But I'd still like to have a go, or at least decide it is just too difficult.

 

Many thanks,

- Richard.

Link to post
Share on other sites

It is probably neither the most elegant, nor the most economical solution, but Arduino clones are so cheap that you could fit several, perhaps one per servo, and have a master controller issuing instructions to these slaves at the appropriate timing to coordinate the movements as you desire.

 

hth

Simon

  • Thanks 1
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...