Sunday 6 May 2012

Arduino and Shift Registers - How Fast Is It?

I'm currently driving my test layout using an old Arduino Diecimila and a L298 dual motor controller shield from DFRobot.

This simply won't cut it in the long run. I will need to run more motor controllers and I want some flexibility around how to mount the motors - not as a shield. I found some very nice cheap controllers on DealExtreme for the outrageous price of $6.70 each. For this you get a full dual motor driver which can also be used for steppers. Only problem is it takes 6 lines to drive (3 per motor) instead of the 4 of the Shield. I need to drive the PWM direct from the Arduino. However, the direction logic now uses 2  lines per motor, not just 1, so I will need to use more shift registers to handle this to keep as many other I/O pins as possible free on the Arduino.

I now have a total of 48 bits of output from shift registers driven by 2 3 pin interfaces. Thats for bits of output for only 6 pins.

The real issue for me is how fast I can hammer the pins on a shift register from an Arduino. It turns out, pretty fast. Fast enough to do basic PWM with an LED.


You can see that the LED on the top left is pulsing in brightness. The LED on the right is simply flashing on and off as a heart-beat.

This is a nice little 24-bit setup. Looks like I can run 2 lots of 24-bits very effectively.

Next time I will test 48 bits from 3 pins on the Arduino.

How about 8 points per Arduino?

So I have constructed my nice point motor controller using servo motors and an Arduino - very nice, thank you.

However, now I have a layout that needs to control 8 points, not 4. I also have limited I/O lines on the main controller so dedicating 8 to driving the point controller is just too much.

I decided to control all 8 points from a single Arduino and use the serial port to control the position and calibration of the points. I still use a pot to control the calibration process because it's just so intuitive.

This posed quite a few challenges. Firstly, don't try doing this with an Arduino Diecimila - you need a newer system than that - I used a Freetronics TwentyTen (discontinued) but the Eleven will be fine as well.

The other consideration is POWER. Yes, sorry but it's not going to work from USB and it's not even going to work well from a PC power supply without a little help. Yes, I'm talking about large capacitors and even a diode for return current.

Have a look at the photos below...

 


Rethinking the Baseboard

I've built my railroad on a special purpose table built in my basement. Unfortunately with all this rain the plywood I have been using has warped and I can see bulges and swellings all over the place.

I considered using Foamcore board but it is very expensive and, lo and behold, it warps as well. Check this out:



















That's 5mm foamcore. Of course the thicker foamcore uses less card vs foam so it is far less inclined to warp. However, it's expensive - about $13/A2 sheet.

So I'm left with heavier plywood or...how about just plain polystyrene sheets?

I noted some on eBay for $15 each but of enormous dimension - 2400 X 1200 X 25mm.

Yes, 2 of these will just about do it. One for the baseboard and one for the scenery, ramps etc.