Jump to content

Simond

Arduino Applications and Programs

Recommended Posts

Speed;  “it takes between 60 and 90 seconds to turn a full size loco 180 degrees”.

 

As I have some time this evening, I’m going to tidy up the program, implement the i2c and reset the step intervals between roads to suit the microstepping.  

 

In order to compensate for the quasi-random extra/missing steps, I’m going to make it automatically reset the zero position every time it turns clockwise across the photodetector, which implies that each road needs to be a stated number of steps from the zero point.  

 

Given the backlash in the gearbox, I’m wondering how much on an inconvenience it would be for the table to always turn clockwise (actually, always anti-clockwise might be more sensible, given the track layout).  This would imply that the zero would be reset on average every two loco movements - the back siding would be the only move that doesn’t cause a reset, but the following move would.

 

ok, to work!

best

Simon

  • Like 1

Share this post


Link to post
Share on other sites

Good news, at least in part, the i2c is working with the t/t as well as lights & points.

 

the turntable now initialises and the absolute positions of the roads are recognised, but the re-zeroing is not working.  It’s just fiddly programming to make it function properly now, all the difficult bits (well, bits I’ve never done before) all work.

 

more soon

 

:)

simon

  • Like 1

Share this post


Link to post
Share on other sites

Well, how things don’t work out.

 

I had everything working, and then a brief oops, a very brief short circuit, and a lot of bad language.  

 

This rather set the project back a bit.  :(

 

i had already decided that the whacking great relay board board was not ideal.  It does the job, and I’d programmed the Arduino to receive points commands from the control panel, and switch the points accordingly, but the relays took more current than the Tortoises!  That is, to put it mildly, daft.

 

so I decided to up my game, and have built this ;-

 

180E7E20-4FF5-452C-9A98-B9B1BA9D5E05.jpeg.12ed90def645e214fb5f26fad0418e2c.jpeg

 

on the left, one of 8 Tortoises.  Then a row of screw connectors, the top one of which is the +12 and zero volts pair, a row of bi-colour LEDs, a row of bridge rectifiers, two rows of double H bridges, and a pair of NOT gate chips each with 6 gates (of which I use 4).  Top right is a stabilised 5V source, mid right is an Arduino nano clone.

 

it’s unfortunate that the led is just switching, they’re more obviously red when the motor is reversed, green when normal.

 

What’s it do?  IN response to the i2c input, the Nano outputs a “High” on one of the pins, the Not Gate creates a corresponding “Low” and that pair are used as the inputs for the H bridge.  Repeat a further 7 times.  Use bridge rectifiers to reduce the load on the H bridges (probably unnecessary with Tortoises, due to the very low current) as I had them to hand.

 

why bother?  You can drive a Tortoise directly from an Arduino though it will be a bit slow at 5V, but it needs two pins per motor, which limits a Nano, particularly if you want to do anything else - the board means 8 motors can be driven from 8 pins, at 12 V, leaving 4 digital and all the analog pins free (though I’ll need A4 & A5 for the i2c link)

 

costs?  The chips were about 3 quid each, I had the rest of the stuff in my goodie box, so £25 maybe.

 

is it worth it?  Depends whether you want an Arduino controlled set of Tortoises.  I had the Tortoises, and so wanted to use them, if I hadn’t, I’d have used servos, which need only one pin each (plus 6 V supply & ground, of course) which is cheaper & simpler.  

 

More soon!

simon

  • Like 3

Share this post


Link to post
Share on other sites

Hi Simon,

Nice to see a bit of "Home Brew" using the Veroboard and a reduction in power consumption plus most importantly self satisfaction in having built it yourself.

  • Thanks 1

Share this post


Link to post
Share on other sites

Rapidonline are doing 30% off their Orangepip range of compatibles

Quote "Arduino2019" at checkout

  • Thanks 1

Share this post


Link to post
Share on other sites

Orange pip seems considerably cheaper than arduino - thanks for the heads-up.

 

I am currently using the Hobbytronics nano clones which are about a tenner

 

I’ll post an update on the story a little later today.

 

best

Simon

 

 

 

Share this post


Link to post
Share on other sites

I should have mentioned the offer is until Easter

12 hours ago, melmerby said:

Rapidonline are doing 30% off their Orangepip range of compatibles

Quote "Arduino2019" at checkout

 

Share this post


Link to post
Share on other sites
Posted (edited)

Ok, so something to report.  The project has gone on far longer than anticipated for a couple of reasons, but has now taken a concrete step forwards.

 

I originally set out to build a network of Arduinos in order to control the point motors, turntable and lighting dimmers from my control panel, without running out of connections in the 2 metre, 25-way,D-connector lead that I had.

 

i had already arranged Arduino control of the turntable, using a separate mini panel with 2 LEDs, (table parked, table turning) a centre off toggle switch (clockwise, stop, anti-clockwise) and a press button (manual control override), I used a Pro Mini, and an A4988BBVR stepper controller, it’s all detailed back in the mists of time on this thread.

 

i bought a 16 channel relay board off eBay, and 5 MOSFET dimmers, and some more Nano clones, and some weeks back, I got all three slaves (t/t, lights, and points) working on the test bench, using i2c control from the Mega 2580 that I had built into the control panel.  

 

Having got it all working, I did a very silly thing and tried to line up all the bits on the bench to see how I would mount them - I had not turned it off, and there was a brief short, which cost very little money (new stepper contoller) butlots of time, as I apparently scrambled the programs in at least one of the slaves, and so I reloaded them, and it didn’t work.

 

I only discovered that I had not saved the latest incarnation of the control program last week. I had therefore loaded an earlier, nearly-functional, and to all intents and purposes identical program into the system, which I believed was functional, because I’d proven everything worked...

 

So a a lot of effort went into fixing a non existent hardware issue, when a 30 seconds edit would, indeed, did, fix it.

 

Anyway, not all bad.  As I noted above, the relay board uses more current than the Tortoises it’s supposed to control, and that’s daft, so I built, and tested the solid state version.  It seems to work fine, I’m happy to provide schematics if anyone wants, similarly if anyone wants, I can get some proper pcbs made.

 

Its installed, and I could actually run locos for the first time in weeks last night!  

 

822608E1-B79F-4D27-B658-1B554204C7AD.jpeg.ca3a6dae570e7986512fd0ed519cbd04.jpeg

 

the small board with the green LED on the left provides the connection to the control panel, and the 12V input.  The ribbon cable running down to the Lenz boxes is the X-Bus.  The other ribbon cable is the i2c connection with +12 & GND for the control panel, and this will eventually connect to the middle board for the lights and t/t controller.

 

The empty board in the middle will be taken out and have the turntable controller & lighting dimmers fitted to it, and the right hand board is the new points controller.

 

The only concerns I have at the moment are a) I connected the points the wrong way round so what should be the left hand lever is the right & vice versa:  easy to fix by connecting the wires to the correct terminals, (they need tidying up anyway!) and b) the motors all power across and back as the system boots up. I think I can prevent this by making the “inhibit” pin high on the H-bridge chips.  I put the connection in for this, but haven’t tried it yet.

 

Jobs to do:

 

Turntable & Lights - programs are sorted, fit the hardware to the new board, and connect up.

 

Programming track relay needs reinstating.  The relay is a DPCO and connects the whole of the front siding and kick-back to the normal track, or programming output, dependent on the switch on the control panel.  It was physically interlocked with the crossover points to prevent a cross connection between the programming output and the rest o& the track (and other locos).  I think I will be happy with a software interlock for this, which saves a couple of connections under the baseboard.

 

Final connections to the control panel - the panel has a pair of 4mm sockets on the back, to connect to a test plank / rolling road.  These will be connected to the programming relay output, so I can program on the rolling road, bu5 switch back to normal DCC for running in, etc.  The X-Bus connections are not working to the control panel.  I suspect this is a wiring error.  

 

Make a nice turntable switch for the panel.  6 press buttons, in a circle.  But nicer looking than the prototype!

 

Make an attractive overlay for the panel, incorporating the trackplan.  Easy DTP job, print on paper, laminate.  Double sided sticky tape to install.

 

Future jobs.  

 

DCC decoder to Arduino, would allow switching from manual point operation to DCC.  Don’t need it on a loco shed, but when the shed is incorporated in the “master plan” layout of Porth Dinllaen, it may be very useful

 

Meanwhile, the end (of this bit of the project) is in sight!

best

Simon

Edited by Simond
  • Like 3

Share this post


Link to post
Share on other sites

Turntable controller slave built.  I’ve checked it for stray connections, whiskers bridging two (or more!) tracks on the Veroboard, and it’s all good, and the circuits appear to be consistent with my plan, so testing next...

 

44F171D3-01A4-4776-9050-88CF12732C6B.jpeg.55c8906e690a9ec938c997798ff8ce9c.jpeg

 

the six pins on the left are four for the stepper, zero volts supply, and the power for the steppers.  This can be up to 36V, I was using an 18V computer power supply, but it would be convenient to use the same 13V source that drives everything else including the trains - it’s got the current capacity - and it would save extra wiring.  We’ll see how the stepper works - if it’s a bit sluggish, it’s easy to re-connect the computer supply.

 

The left hand board is the Polulu 4988 with built-in regulated psu, which provides the 5V for the Arduino.

 

The right hand board is the Arduino Nano clone, £10.80 as of today on Hobbytronics (usual disclaimers).

 

the pins on the right are, from the top;

 

i2c SCL

i2c SDA

5V out. (Won’t be connected, to avoid parallel supplies)

GND.  

   These 4 pins match the i2c pins on the other boards

GND

5V out

Table zero position sensor input (capacitor to ground)

Bridge track polarity relay output

  These four pins go to the table, along with the four stepper supply)

 

Manual override button

CW switch

CCW switch

Green “table parked” LED

Red “table moving” LED

GND for the old control panel.

 

That’s about it.  Try out tomorrow.

 

best

Simon

 

 

 

 

 

  • Like 3

Share this post


Link to post
Share on other sites
Posted (edited)
1 hour ago, ianjeffery said:

you paid £10.80 for a Nano ?

A clone as well!

3 for £10.99 from Amazon

Edited by melmerby

Share this post


Link to post
Share on other sites

Thank you gentlemen.  I won’t do it again...

 

The said item is installed;

 

image.jpg.af48dc1be2e42b7bdf098deddd8486ba.jpg

 

Anmoyingly, it’s not working.  

 

Not getting fixed tonight :(

 

best

Simon

 

 

  • Like 1
  • Friendly/supportive 1

Share this post


Link to post
Share on other sites

And it still doesn’t work.  Right hacked off.  Going to do something else for a few days.  Duchess, I think.

 

:(

simon

  • Like 1
  • Friendly/supportive 2

Share this post


Link to post
Share on other sites

Well, a few days turned into a few weeks.  The turnout control has been fine.  After doing a stepper controller for Paul Ashton’s Moor St layout, I got my mojo back and decided to sort out my turntable.

 

What I discovered was that the Arduino Nano I was using had suffered in the oops to which I referred earlier.  One or both the i2c lines was damaged, and that pulled the bus down, preventing anything from working.  I popped in another Nano, and it works.  :)

 

I'm now re-drafting the sketch as it had grown like Topsy, and it’s got lots of stubs & other nonsense in it.  A refresh will be a great improvement.

 

Next step, sort out the lighting, which is where this all began.

 

best

simon

 

 

 

 

  • Like 2

Share this post


Link to post
Share on other sites

Good luck Simon.

 

Let us know how you get on - I for one would be interested in seeing the revised sketch :) - just starting to learn this arduino stuff.

Share this post


Link to post
Share on other sites

Thanks Andy, Ian,

 

will do

 

atb

Simon

Share this post


Link to post
Share on other sites

one way of getting rid of your small backlash problem would be to use a harmonic drive rather than a gearbox on the stepper.

  • Like 1

Share this post


Link to post
Share on other sites

yes, or indeed, to have been able to locate a suitable toothed belt, as it is trivially easy to cut a gearwheel on the laser  -though when I started this particular game, I didn't have a laser!

 

the drive I use has a built-in epicyclic gearbox, I hope that I will be able to compensate for the backlash by simply allowing x steps when reversing, but of course, this will only work if x is a constant.  If not, it will not be a big issue to simply turn anticlockwise every time.  Locos would come backwards into the yard on the coal road, drop their fire and fill their tender, be turned and come off the t/t on the bypass road, from there they go on shed.  anticlockwise would be the easiest for the crew.  Occasionally a loco would use the back road after coaling - again, anticlockwise gets them there the shortest way, and gets them out the shortest way too.

 

best

Simon

 

 

Share this post


Link to post
Share on other sites
On 10/06/2019 at 15:39, Simond said:

yes, or indeed, to have been able to locate a suitable toothed belt, as it is trivially easy to cut a gearwheel on the laser  -though when I started this particular game, I didn't have a laser!

 

the drive I use has a built-in epicyclic gearbox, I hope that I will be able to compensate for the backlash by simply allowing x steps when reversing, but of course, this will only work if x is a constant.  If not, it will not be a big issue to simply turn anticlockwise every time.  Locos would come backwards into the yard on the coal road, drop their fire and fill their tender, be turned and come off the t/t on the bypass road, from there they go on shed.  anticlockwise would be the easiest for the crew.  Occasionally a loco would use the back road after coaling - again, anticlockwise gets them there the shortest way, and gets them out the shortest way too.

 

best

Simon

 

 

Toothed belts available here:-

 

https://www.hpcgears.com/pdf_c33/12.88-12.89.pdf

 

BC

Share this post


Link to post
Share on other sites

Cheers chaps!

 

 

Share this post


Link to post
Share on other sites

Interesting thread. A bit intimidating for a total novice though. I spent yesterday playing with an Arduino Mega clone that I bought some time ago in a fit of enthusiasm for DCC++ but didn't pursue at the time.

 

Once I'd got bored with writing sketches to flash the on board LED in a variety of Morse code insults I started on the more serious exercise of working out how to use it to control a small end to end shuttle that I'm working on. 

 

I'd bought a cheap, Ebay motor shield at the same time. It's a Deek Robot Stepper (or Steppre, as printed on the board) Shield V1. 0, which is of a pattern that doesn't seem to be very common, based on my Google research. However, it seems to be based on the standard L293D chip, and I managed to find a schematic showing the relationship between the pins on the chip and the pins on the shield/Arduino.

 

The plan is to get an output from one of the motor channels that will start a train from rest, accelerate it to a given speed, decelerate it to a stop, then do the same in reverse and continue to repeat the sequence indefinitely. It's all going to be done by timing. I accept that train detection such as reed switches would be better, but this is a project utilising stuff I already have, and I don't have any reed switches and can't find the big bag of microswitches I used to have. I will, however, be putting diode protection on each end of the shuttle track to avoid any overruns. 

 

So far I've got a sketch that provides an automatic rising and then falling output on one or other pin of one of the motor outputs. Now I just have to combine one of each in sequence and get the two to loop repeatedly, which shouldn't be too hard. 

 

I'm hoping the current demand of the intended loco (basic, early 2000s Hornby 0-6-0) won't exceed the 0.6A max of the L293D. Load will be no more than 3 wagons so I'm not expecting it to be a current hog. 

 

So there we go. Very basic compared to the other projects described on this thread, but I'm enjoying myself and thinking ahead to what I might do with the technology in future. I'm away from my laptop at the moment, but when I finish the sketch I'll post it. 

Share this post


Link to post
Share on other sites
On 10/06/2019 at 10:05, Simond said:

Well, a few days turned into a few weeks.  The turnout control has been fine.  After doing a stepper controller for Paul Ashton’s Moor St layout, I got my mojo back and decided to sort out my turntable.

 

What I discovered was that the Arduino Nano I was using had suffered in the oops to which I referred earlier.  One or both the i2c lines was damaged, and that pulled the bus down, preventing anything from working.  I popped in another Nano, and it works.  :)

 

I'm now re-drafting the sketch as it had grown like Topsy, and it’s got lots of stubs & other nonsense in it.  A refresh will be a great improvement.

 

Next step, sort out the lighting, which is where this all began.

 

best

simon

 

 

 

 

Simon,

Any chance of the updated sketch, and maybe a wiring diagram??

 

Hope that's not too much to ask.....

 

BC

Share this post


Link to post
Share on other sites
8 hours ago, PatB said:

 

I'd bought a cheap, Ebay motor shield at the same time. It's a Deek Robot Stepper (or Steppre, as printed on the board) Shield V1. 0, which is of a pattern that doesn't seem to be very common, based on my Google research. However, it seems to be based on the standard L293D chip, and I managed to find a schematic showing the relationship between the pins on the chip and the pins on the shield/Arduino.

 

 

Seems to very similar to the Velleman KA03 but that  uses an L298D.

 

Couple of topics on the Arduino Forum (there are others):

https://forum.arduino.cc/index.php?topic=277150.0

https://forum.arduino.cc/index.php?topic=332397.0

 

Share this post


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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.