Jump to content
 

Arduino Applications and Programs


Simond
 Share

Recommended Posts

  • RMweb Premium
1 hour ago, Simond said:

I'm sure it shouldn't, and I guess you already checked, but is the buck failing to give sufficient current, causing a brown-out? 

 

Worth clipping your scope to the 5v rail?

 

fingers crossed

Simon

Looks like it must have been noise artefacts on the 5v rail. I already had a 100nf across both the TMC2208 & Arduino power inputs

Putting an extra 100uF Electrolytic across each seems to have cured the problem

 

I had tried two buck convertors early on as I was using a different one on the breadboard originally, although I removed it and used 5v instead.

I assume the paths the current was taken must have allowed noise to enter the Arduino power line, which were totally different when breadboarded.

 

Maybe I should now try the original setup using the Arduino to do the logic?

  • Round of applause 1
Link to post
Share on other sites

  • RMweb Gold
2 hours ago, melmerby said:

Looks like it must have been noise artefacts on the 5v rail. I already had a 100nf across both the TMC2208 & Arduino power inputs

Putting an extra 100uF Electrolytic across each seems to have cured the problem

 

I had tried two buck convertors early on as I was using a different one on the breadboard originally, although I removed it and used 5v instead.

I assume the paths the current was taken must have allowed noise to enter the Arduino power line, which were totally different when breadboarded.

 

Maybe I should now try the original setup using the Arduino to do the logic?

 

I thought noise comming from the Stepper might have been the cause I hadn't suspected the power supply. Yes you could try the sketch again.

 

Don

  • Agree 1
Link to post
Share on other sites

  • RMweb Premium
13 minutes ago, Donw said:

 

I thought noise comming from the Stepper might have been the cause I hadn't suspected the power supply. Yes you could try the sketch again.

 

Don

Could be the stepper, I suppose, although it won't be commutation noise like a normal motor.

According to Trinamic's data sheet the voltages to the coils don't switch hard on/off

I suppose it could be a current surge causing a rapid, but short lived dip in voltage when the states change.

Link to post
Share on other sites

  • RMweb Premium

I have now returned it to just Arduino based logic and have made a more permanent "upgrade" to the power feeds on the board.

The 1000uF reservoir capacitor is as close as I can get to the output of the buck convertor and I have replaced the temp electrolytics at the 5v supplies with 100uF Tantalum caps (they're a lot smaller!)

Also instead of having the direction from DCC go in-out of the Arduino from the opto coupler it is wired direct to the DIR Pin of the TMC2208 with a connection also to an Arduino input pin, the logic state is then read as part of the program.

 

Power up - absolutely perfect, it runs just as I wanted.

This is the sketch as is running now:

TraverserTest2A.ino

 

  • Like 2
  • Round of applause 1
Link to post
Share on other sites

  • RMweb Premium

Hers is a quick video showing my test set up to prove that it will work.

I had a shock when I first tried it as the RH microswitch was faulty and wasn't switching cleanly causing all sorts of problems.

Once replaced it does the job, just as required:

Video link

 

  • Like 1
Link to post
Share on other sites

  • RMweb Premium
22 minutes ago, Simond said:

What’s the noise?  Sounds like it might not be stepping cleanly?  Is it missing steps?

 

atb

Simon

I think that is the mechanics itself.

There are no proper bearings in the ally angles and it's quite noisy without the motor in situ

Link to post
Share on other sites

  • RMweb Premium

Now it all seems to in good order I shall start upgrading the traverser mechanism and use a proper lead screw and some decent bearings.

The original was a bit of a lash up that worked "straight out of the box" so got left but is rather noisy and inconsistent speed wise.

 

Link to post
Share on other sites

  • 1 month later...
  • RMweb Premium
On 26/02/2021 at 21:55, melmerby said:

Now it all seems to in good order I shall start upgrading the traverser mechanism and use a proper lead screw and some decent bearings.

The original was a bit of a lash up that worked "straight out of the box" so got left but is rather noisy and inconsistent speed wise.

 

 

On 26/02/2021 at 23:27, Donw said:

We look forward to seeing the final result.

 

Don

 

Here is a video lash up showing before and after

A bit late because my Pinnacle Studio Ultimate was not playing ball and kept blanking video when subtitles were on screen.

Manage to get it done though:

https://youtu.be/OAOcChd0UxY

Edited by melmerby
  • Round of applause 1
Link to post
Share on other sites

  • RMweb Premium
4 minutes ago, Donw said:

Thats very nice. What an improvement over the original. Full marks for sticking to you guns and sorting it out.

 

Don

It's been working perfectly since I installed it and it's the quietest power operated item on the layout.

When I first started I didn't know a stepper motor could be made to operate so quietly.

 

Maybe that Peco turntable sitting in the draw needs motorising........:yes:

  • Like 2
Link to post
Share on other sites

  • 1 month later...
  • RMweb Premium

Way back in April 2016 ffayolle posted work he'd been doing with software based interlocking. This is something that I'd be interested in investigating for a colleague's O gauge layout where the points and signals of one area are to be controlled from the DCC Concepts levers.

 

I haven't yet delved into ffayolle's code.

 

I'm fairly confident I could do all that is needed via relays but the Arduino seems that it would be a much smarter option.

 

There would be a maximum of 25 levers involved and upwards of 30 servos - some working crossovers, hence the two figures don't tally (and the track plan is yet to be finalised). As far as I can see this would require an Arduino Mega so that each lever has an input pin and each servo is connected via an output pin. The servo power would be via a dedicated power supply.

 

I have a few questions before I start down the path of considering an Arduino based implementation and wonder if anyone can answer these for me.

 

The positioning of the lever frame on the layout is such that it protrudes from the layout's front edge. Is there any way that the "frame" could be made to be plug based so that the "frame" can be removed when the layout is not in use?

 

One option that we're considering is to make some of the signals route based so that one lever may operate one of several servos depending on the route set by the points. I'm guessing this is likely to be addressed by software. Is that a correct assumption?

 

The crossovers use two servos operated by the same lever. My (very) limited knowledge of electronics makes me wonder how this could be achieved recognising that the limits of each servo's travel would need to be held within the Arduino's sketch. Am I correct in thinking that each servo would be linked to a different Arduino pin and the sketch's code would need "write" to both pins?

 

There will be two semi-permanent baseboards each around 8ft long. The servos will be surface mounted and all track power wires will be brought to the front edge of the baseboard where they will be connected to the track power bus so that there's no reason for anyone to delve under the layout once all is wired up. One of the baseboards has three points and no signals, the other all the remaining points and signals. There will be some lights on both boards so aside from track power and a supply for the lights there will only be the servo related wires linking the two boards electronically. I believe it is possible to link two Arduinos electrically. Is that correct and is it worthwhile introducing a second Arduino for the three servos involved? I seen mention of something referred to as I2C. is that an extra complication worth worrying about (and about which I currently know nothing)?

 

I suspect there will be further questions if we decide to follow this path so I'll express my gratitude now to those who can answer any/all of the above. Many thanks.

Link to post
Share on other sites

  • RMweb Premium

From my limited knowledge of Arduino usage.

Each Arduino controlled servo can have separate Max & Min settings, all you need to do is operatethe servos simultaneously, which isn't a problem, you just address both pins at once.

I have done this using the Arduino as a DCC accessory decoder, where each address operates one (or two) servo(s)

 

I2C is a common way of communicating with peripherals and I assume could be used to link two Arduinos, I don't know what the spec is regarding length of interconnection with it.

Edited by melmerby
Link to post
Share on other sites

  • RMweb Gold

Hi Ray 

First comment is using all the pins so that each lever or servo is connected to an individual pin will make it much more of an issue having it to plug.  I am imagining say three 25 pin connectors.

Using some kind of networkcan reduce the number of wires etc

I2C is one possible network and is used by Megapoints for his networked servo controllers. It is also used by Eazybus

CBUS is another network

These could make it much simpler to haave a plug in option.

 

Second comment is you are suggesting using a single processor to do all the work. It may make more sense to have the processing distributed

 

Suggestions 

 Using CBUS you need an input module(s) to connect to the levers usually the levers operate a microswitch. CANPAN

 You need output modules to drive the servos  probably 4 CANMIOs

 You would need a CANCOMPUTE to do the interlocking

The Canpan and the lever frame are mounted on a single removeable baord which just needs  4 wires to connect CANH,CANL, 0v and 12vsupply.

 

 

Using I2C would need quite a bit of coding and a processor at each servo to recognise  that a message it for it.

 

Based on seperate wires.

have the Levers  connected to suitable plugs to make the lever frame removable.

Have a Mega to receive the lever throws and run the interlocking however I would use the megapoints servo controllers or MERG servo drivers to control the servos from the mega a wire is run to each of the input of the servo controllers. The setting of the servos done at the controllers. For crossovers one wire goes to two inputs on the sevo controllers to allow them to be individually set.

 

Don

Link to post
Share on other sites

40 minutes ago, Ray H said:

Way back in April 2016 ffayolle posted work he'd been doing with software based interlocking. This is something that I'd be interested in investigating for a colleague's O gauge layout where the points and signals of one area are to be controlled from the DCC Concepts levers.

 

I haven't yet delved into ffayolle's code.

 

I'm fairly confident I could do all that is needed via relays but the Arduino seems that it would be a much smarter option.

 

There would be a maximum of 25 levers involved and upwards of 30 servos - some working crossovers, hence the two figures don't tally (and the track plan is yet to be finalised). As far as I can see this would require an Arduino Mega so that each lever has an input pin and each servo is connected via an output pin. The servo power would be via a dedicated power supply.

 

I have a few questions before I start down the path of considering an Arduino based implementation and wonder if anyone can answer these for me.

 

The positioning of the lever frame on the layout is such that it protrudes from the layout's front edge. Is there any way that the "frame" could be made to be plug based so that the "frame" can be removed when the layout is not in use?

 

One option that we're considering is to make some of the signals route based so that one lever may operate one of several servos depending on the route set by the points. I'm guessing this is likely to be addressed by software. Is that a correct assumption?

 

The crossovers use two servos operated by the same lever. My (very) limited knowledge of electronics makes me wonder how this could be achieved recognising that the limits of each servo's travel would need to be held within the Arduino's sketch. Am I correct in thinking that each servo would be linked to a different Arduino pin and the sketch's code would need "write" to both pins?

 

There will be two semi-permanent baseboards each around 8ft long. The servos will be surface mounted and all track power wires will be brought to the front edge of the baseboard where they will be connected to the track power bus so that there's no reason for anyone to delve under the layout once all is wired up. One of the baseboards has three points and no signals, the other all the remaining points and signals. There will be some lights on both boards so aside from track power and a supply for the lights there will only be the servo related wires linking the two boards electronically. I believe it is possible to link two Arduinos electrically. Is that correct and is it worthwhile introducing a second Arduino for the three servos involved? I seen mention of something referred to as I2C. is that an extra complication worth worrying about (and about which I currently know nothing)?

 

I suspect there will be further questions if we decide to follow this path so I'll express my gratitude now to those who can answer any/all of the above. Many thanks.

 

Frame with 25 pins.   The simplest plug/socket would be a D-sub in 25 way form.  That gives 25 pins, plus the shroud giving an earth, so covers your 25 levers.   There are cheap commercial "breakout" boards which give screw terminals to connect everything.  Or go up to the next pin size.  

 

Routes doesn't seem to quite fit with "lever frame", but if that's your aim, yes I'd do the routes in software.  

 

Cross-overs.  Could do them sequentially in code; one moves, then the other, or could move them both together.  Really is a software decision.  You probably do want them on separate pins, so you can fine tune the servo position for each of them.  

 

You can network Arduinos in many ways,  IC2 is one of numerous options.  There are serial protocols available.   But, you might want to experiment to see if its really worth it.   Depending on distances, three wires for the servos would be not really any different to a few wires for a bus linking arduinos together.   

 

 

There are ways of multiplexing inputs and outputs.   That reduces the pin-count needed on the Arduino, and would be pretty simple for your lever frame input side.  Whether its worth worrying about if a Mega has enough pins is a debatable question, but it could reduce the wires needed for your "plug in" connection to the lever frame. 

 

 

Link to post
Share on other sites

  • RMweb Premium

Ray,

I have adapted Fabrice’s Signal Box and Tokenless Block Instrument Code for my Moretonhampstead Layout.

 

I use an Arduino Mega connected to MERG CBUS via a MCP2515 CAN BUS Module and use MERG CANMIO-SVO’s to Drive the Servos. The Lever Switches are connected to the Arduino’s Inputs and the Servos are controlled by sending on/off messages to the CBUS.

 

The  whole Signal Box Module can be unplugged by using a 4 PIN XLR Plug / Socket.

Link to post
Share on other sites

  • RMweb Gold

Ray 

it might also be worth considering the Megapoints system I think you could use a multipanel connector to operate a number of the servo controller boards. the Multipanel connector could be located on the board with the levers and then plug into the rest. Best to send an email to Dave Fenton if you fancy going that route I am not sure if the route processor can handle interlocking

 

Don

Link to post
Share on other sites

  • RMweb Premium

Wow, and many thanks to each of you for such speedy responses. You must have all been typing your responses at roughly the same time. Much appreciated.

 

I'm fairly certain that the track layout is now determined. In an ideal world (from my point of view) it would make more sense to have one lever control one point/crossover/signal arm but I need to twist my colleague's arm to buy the extra levers! We have the points, servos and most if not all the signals. We do have a number of MERG servo4 kits from the present arrangement so we could re-use them.

 

I have yet to look in detail at Fabrice’s code so don't know if he has included an option to use one lever to operate two discs on the same fixing dependant on adjacent point setting. That's probably the only signal where it would be the preferable way of working.

 

I had thought of a 25 pin connector for the MEGA but wondered if anyone had any experience of anything else that didn't involve a plug & trailing cable - if only to stop the lead getting caught on something carelessly :o pushed under the layout.

 

It does seem as though I2C is probably extravagant with just the three points on the one board (and two of them are worked by the same lever). One Servo4 board should do the business there.

 

I appreciate that CBUS could be an option but the cost of the add-on bits doesn't compare with the cost of a MEGA. The Servo4 kits would hold the servo travel limits just leaving a single wire between MEGA and Servo4 and some fairly basic - If condition met . . . Set On/Set Off - coding I would have thought. We do have one servo elsewhere on the layout controlled by a Nano with travel limits hard coded but using the Servo4s would avoid that.

 

Do you think I'd need more than a single MEGA to handle the processing? Would it be fast enough to respond to two quick and successive lever operations?

Link to post
Share on other sites

  • RMweb Gold

If you are using the Mega  with the servo4  modules it will be plenty fast enough because all it has to do it to set a pin high or low.  You dont want to have travel limits coded into the Mega because it would make adjustment difficult.

The only time you may have to wait is where there was a level crossing or something like that and the signal cannot be pulled off until the gates are fully open .

One thing, this will not stop you pulling a lever when its action is locked that can be done one way is to have extra servos that operate to pysically stop a lever being pulled but adds extra costs and coding. With this I would suggest pulling a lever whose action is blocked should light a red LED on the lever frame. I would use a single LED for all levers to save on pins you know which one you have pulled.

 

Don

Link to post
Share on other sites

  • RMweb Premium
19 minutes ago, Donw said:

One thing, this will not stop you pulling a lever when its action is locked that can be done one way is to have extra servos that operate to pysically stop a lever being pulled but adds extra costs and coding. With this I would suggest pulling a lever whose action is blocked should light a red LED on the lever frame. I would use a single LED for all levers to save on pins you know which one you have pulled.

 

Don

 

Thanks Don.

 

I was contemplating using a single red flashing LED and probably a beep tone but the latter might be more of an annoyance than an aid.

 

Fortunately there's no (working) level crossing on this part of the layout; there's a non-working one in the garden (and long may it stay that way!  :D

Link to post
Share on other sites

Ray,

 

Have you considered using PCA9685 boards to drive the servos?  Each board can drive 16 servos and need a 5v. supply for the servo power.  The Arduino sends commandS over I2C hence only three wires to connect on a small umbilical from your panel.  The PCA9685 boards can be distributed around the layout with varying length servo cables to the relevant positions.

 

The Arduino will need to send the relevant command to control the sweep of the servo and this may need to be programmable in the first instance.  There are numerous examples on YouTube on how to set these boards up.

 

it would also be possible to have an Arduino in the control panel monitoring the levers, sending commands to an under baseboard Arduino which drives the servo boards.  In this way you could segment the logic into two section to make it simpler.

 

Regards,

 

Colin.

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

There is another consideration, servos are known for their tendency to jitter, due to received interference from other  electrical things in the area, like locos, on the analog signal wire to the servo. This is probably worse if the analog wires are long, and of course, an electrically noisy loco (eg old motor) will probably be much worse.
 

Perhaps local servo control would be appropriate, either more (eg Nano) Arduinos, or something like the boards suggested by Colin, either of which can be driven by I2C or other similar digital comms.

 

I used I2C to connect a Mega to a collection of Nanos to operate my points & other things on my Porth Dinllaen layout, but having done so, I regret that I did not go down the CAN route, and will probably do so at some point in future.  The I2C connection is a little unreliable over the 2m lead I’m using.

 

it would be relatively easy to fit a mega to your lever frame, and connect (and power) it via CAN. I think that’s where I’d be starting we’re I trying to do what you’re planning.

 

hth

Simon

 

 

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