Jump to content
 

DavidB-AU

Members
  • Posts

    3,105
  • Joined

  • Last visited

Everything posted by DavidB-AU

  1. The advantages will become clear as the tutorials progress. These are the absolute basics to get people going. One example might be interlocking, e.g. you can create a simple program which will not allow a signal to be set to exit a siding when the points are against the train. This is easier to do in software than in hard wired electronics. Cheers David
  2. Now let's add a green LED adjacent to the red one and connect it to GPIO25 (pin 22). Now create a new file called ledtest2.py and enter the following: import RPi.GPIO as GPIOimport time# Set up GPIO25 (pin 22) as outputGPIO.setup(22, GPIO.OUT)while 1: # Turn green LED on GPIO.output(22, False) time.sleep(1) # Turn green LED off GPIO.output(22, True) time.sleep(1) Run the program as root. pi@raspberrypi ~$ sudo python ledtest2.py If all goes well, the green LED will flash on and off. Quit the program by hitting CTRL-C. Now let's get a little more complicated. Create a new file called ledtest3.py and enter the following: import RPi.GPIO as GPIOimport time# Set up pins 18 (GPIO24) and 22 (GPIO25) as outputGPIO.setup(18, GPIO.OUT)GPIO.setup(22, GPIO.OUT)while 1: GPIO.output(18, False) # Turn red LED on GPIO.output(22, True) # Turn green LED off time.sleep(1) GPIO.output(18, True) # Turn red LED off GPIO.output(22, False) # Turn green LED on time.sleep(1) Run the program. pi@raspberrypi ~$ sudo python ledtest3.py The LEDs should now flash between red and green.
  3. Now let's set up a simple circuit with a resistor and a red LED. The resistor is between the 3.3V rail and the anode (long leg) of the LED. The cathode of the LED is connected to GPIO24 (pin 18). The value of the resistor isn't critical but should be in the range of 300R-1K. I used 470R because I had plenty to hand. This is what it looks like on the breadboard. Now to control the LED from the RPi. GPIO must be run as root so after the prompt (pi@raspberrypi ~$) type sudo python. pi@raspberrypi ~$ sudo python python will start and display something like this. The >>> is the prompt. Python 2.7.3 (default, Jan 26 2013, 11:20:46)[GCC 4.6.3] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> First import the GPIO package. >>> import RPi.GPIO as GPIO Then set up pin 18 (GPIO24) as output. >>> GPIO.setup(18, GPIO.OUT) By default the GPIO pins are HIGH (3.3V). Bu setting them LOW, it drops to 0V and allows power to flow. To do this, set the pin to "False". (This is not the only way to do this. More on this later.) >>> GPIO.output(18, False) This will turn the LED on. To it off, set the pin as HIGH by making the setting "True". >>> GPIO.output(18, True) You can repeat these GPIO.output settings until you get bored. Exit the python shell by hitting CTRL-D. Controlling the LEDs by typing python commands every time will get tedious, so instead we'll write a little program to automate it. Open a new file called ledtest1.py with your favourite text editor. I use nano (long time users of Linux may recognise this as a cut down version of pico) so the command is: pi@raspberrypi ~$ nano ledtest1.py Add the following. The items after the hash (#) are comments which are not processed and can be left out if desired. However it is good programming practice to ad comments so you remember what each command or block of commands is intended to do. import RPi.GPIO as GPIO # Imports the GPIO packageimport time # Imports a timer packageGPIO.setup(18, GPIO.OUT) # Set up header pin 18 (GPIO24) as outputwhile 1: # Starts a loop GPIO.output(18, False) # Turns the LED on time.sleep(1) # Waits for 1 second GPIO.output(18, True) # Turns the LED off time.sleep(1) # Waits for 1 second Save the file and close the editor. Again, GPIO must be run as root so from the Linux command line type: pi@raspberrypi ~$ sudo python ledtest1.py The LED should now flash on and off, changing about every 1 second. It may not be exactly 1 second as the RPi is doing other things in the background which may affect the timer. Quit the program by hitting CTRL-C.
  4. This is the first of hopefully a series of tutorials on using a Raspberry Pi to do what modellers often do with more mundane devices such as switches. These are aimed at the modeller rather than the serious hardcore programmer or electronics hobbyist, but does assume a basic knowledge of electronics and assumes you have already set up your RPi and installed the RPi.GPIO package. I won't go into that here - if you have any trouble see the Raspberry Pi or Adafruit forums. Note that my RPi is running Raspbian (Debian Linux). This is not the only operating system available but I haven't looked at the others. I have also attached the Adafruit GPIO breakout kit and breadboard sitting on a Pi Dish. I connected one positive rail to 3.3V (pin 1), the other positive rail to 5V (pin 2) and the negative rails to 0V/GND (pin 6). This is not the only way to do things but I found it convenient.
  5. Videos from different people of vintage Alcos on the Australia Day Newcastle Flyer. Cheers David
  6. BRM001 on its load test (1130t up Cowan Bank) and on its first revenue run. The BRM is basically the same as the CFCLA VL class, a new frame around a reconditioned EMD engine, alternator and traction motors with Wabtec QES-3 traction control. What is unusual is it was built in-house by Southern Shorthaul for its subsidiary Consolidated Rail Leasing. Cheers David
  7. 9 classic bulldogs in a light loco movement from Melbourne to Ettamogah. At 0:24 you'll see the effect of mudholes. On paper they are going to storage, but rumour has it they will be used on a new grain contract. Cheers David
  8. Vintage bulldogs delivering new coal hoppers. http://www.youtube.com/watch?v=FlAd8MFgJhg Cheers David
  9. Two wheat trains in the Adelaide Hills, combined after the first train stalled on wet rails. Cheers David
  10. As was rumoured, the next 2 of the Aurizon C44aci locos have turned out as the ACC class for use in Western Australia. ACC6030 and ACC6031 continue the numbering of the 6020 class. http://www.youtube.com/watch?v=OvuoN-jPO5E Cheers David
  11. Even they are small compared to the coal trains in the lower Hunter Valley. Sometimes up to 90 x 120t hoppers. Cheers David
  12. In the spirit of London to Brighton... Kiama to Sydney in 14 minutes. http://www.youtube.com/watch?v=YBbgEZWL7xY And Sydney to Newcastle in 13 minutes. http://www.youtube.com/watch?v=78r9rMqtj5c Cheers David
  13. Lenin, Stalin, Khrushchev and Brezhnev are all travelling together in a railway carriage in outer Kazakhstan. Unexpectedly the train stops. Lenin suggests: "Perhaps we should call a subbotnik so that workers and peasants can fix the problem." Stalin puts his head out of the window and shouts, "If the train doesn’t start moving, the driver will be sent to a Siberian gulag!" But the train doesn't start moving. Khrushchev then suggests "Let's take the rails behind the train and use them to construct the tracks in the front." But still the train doesn't move. Brezhnev then says, "Comrades, Comrades, let's draw the curtains, turn on the gramophone and pretend we're moving."
  14. Has anybody done a 325 in the old Royal Mail livery? Cheers David
  15. I'm originally a Victorian! Cheers David
  16. Shame I was in the wrong state. Cheers David
  17. Pacific National 7BM4 intermodal departing Acacia Ridge, Brisbane. QR National 7BM7 waiting in the background. http://www.youtube.com/watch?v=8PDsDy9tX88 Cheers David
  18. Narrow gauge coal and minerals in tropical North Queensland. http://www.youtube.com/watch?v=x4a76G5ImJw Cheers David
  19. Diggers Rest on the Bendigo line north of Melbourne with only 10 days left until the end of V/Line diesel commuter services to Sunbury. The wires have just been commissioned and electric Metro services commence on 18 November. The loco-hauled Sunbury trains are not top and tailed, the coaches have multiple unit cables throughout and the locos are running in multiple, like a poor man's HST. http://www.youtube.com/watch?v=aCD-oYeC4yc Cheers David
  20. Is this the one? http://www.sixbellsjunction.co.uk/60s/681103lc.html Cheers David
  21. A seaman meets a pirate in a port, and talk turns to their adventures on the sea. The seaman notes that the pirate has a peg leg, a hook, and an eye patch. The seaman asks, "So, how did you end up with the peg leg?" The pirate replies, "Arrr, matey, we was in a storm at sea, and I was swept overboard. Just as me men were pulling me out, a shark bit me leg off." "Wow!" said the seaman. "What about your hook?" "Well," replied the pirate, "We were boarding Spanish galleon and battling with swords. One of the scurvy dogs cut me hand off." "Incredible!" remarked the seaman. "How did you get the eye patch?" "A seagull dropping fell into me eye," replied the pirate. "You lost your eye to a seagull dropping?" the sailor asked incredulously. "Arrr," said the pirate. "It was me first day with the hook."
  22. A teddy bear is working on a building site. He goes for a tea break and when he returns he notices his pick has been stolen. The bear is angry and reports the theft to the foreman. The foreman smacks his forehead and says "Oh, I forgot to tell you! Today's the day the teddy bears have their pick nicked.”
  23. A couple of little coal trains. http://www.youtube.com/watch?v=D7uiNcAkeL8 http://www.youtube.com/watch?v=Bs9zw7dOzhs Cheers David
  24. A late follow up. There is a surprisingly amount of interest in suburban electrics at the moment, in both HO and N. A lot happening in NSW at the moment in both scales. If the range of Melbourne suburbans can eventually be expanded to include the Hitachi, Harris (maybe even loco-hauled H cars?), Tait and Swing Door eras this could be just as popular. Cheers David
  25. Some more from the West since the pics were so popular. First a narrow gauge iron ore train with GE power, then some of the world's heaviest trains with EMD power. http://www.youtube.com/watch?v=Bf8gRTpfesc http://www.youtube.com/watch?v=0NNYDIpM71w& Cheers David
×
×
  • Create New...