Joined: 14/01/2006(UTC) Posts: 1,802 Location: Wurttemberg
|
Hi all, First off, I'd like to mention that this not a completed project. It should be understood as a proof of concept. The reproduction requires at least some basic knowledge of how a RASPBERRY PI works and how to install and operate RASPBIAN JESSIE. A complete guide to this would go beyond the scope of a MÄRKLIN - forum, but there are many instructions on the net for every grade of previous knowledge. The pattern is also only just stuck together and fixed with some mounting adhesive tape.   The project has, however, one advantage: it is cheap. A camera ride, live broadcast over Wi-Fi is hardly to get cheaper. Introduced some weeks ago, there is a new model named RASPBERRY PI ZERO W (the "W" is important) available. The RASPBERRY PI ZERO is the little brother of RASPBERRY PI. It works with the same operating system as the normal RASPBERRY PI, but has a somewhat weaker processor and fewer connections. It costs only 11, - EUR. New on the “W”- model is, that it has BLUETOOTH and WIFI on board. The RASPBERRY PI ZERO is significantly smaller than the classic RASPBERRY PI. It is so small that it fits on a H0 car. If you cut about one millimeter on the side of the GPIOs (the two rows with the 40 contacts), it also fits into some H0 cars.  The original power supply is via a micro-USB plug from the side of the board, which would make it too wide for the operation on a H0-railway. But you can also supply the RASPBERRY via the 5V GPIO pins. To avoid confusion, I have soldered a male and a female pin into the relevant pins and a USB cable with appropriate plugs. The electric supply comes from a small power-bank. The power consumption of a RASPBERRY PI ZERO with camera is also below 250 mA during a video transmission with WLAN. With a 2000mAh - Powerbank it runs several hours. Since years, a camera which is connected directly to the RASPBERRY board is available. This camera can also be connected to the PI-ZERO W with a special cable. The camera used here is a older 5MP camera. There are currently also 8MP cameras available. Also, this camera is small enough for H0 - tracks. An expensive camera will certainly yield better images than a cheap one. You need: RASPBERRY PI ZERO W (the "W" is important) ~ 11 EUR A camera for the RASPBERRY PI from 10, - EUR, original cameras from the RASPBERRY FOUNDATION cost about 30, - EUR. An adapter cable for the camera for operation on the PI ZERO: ~ 3, - EUR (the normal cable from the RAPSBERRY PI does not fit). A micro SDHC card for the system. ~ 10, - EUR. (At least 16GB, in the class of Samsung Evo or SanDisk Extreme or better) A small power bank. From 5, - EUR. [/ List]
In sum, you can go well under 50, - EUR.
The software RPi Cam Control v6.3.1 is used to operate the camera and display the live images. A comprehensive guide to the installation is available here: http://elinux.org/RPi-Cam-Web-Interface. The software itself is available here: https://github.com/silvanmelchior/RPi_Cam_Web_Interface. Do not be deterred by the length of the article. The camera works when you reach "Step 5".
The installation script installs a web server (I took APACHE) on the RASPBERRY and the software that streams the video into the net. You can call the live camera image with each browser in your own WLAN under the IP address of the Raspberry. Also from the smartphone. Additional you can record single images and video sequences, also parallel to the video stream.
The screen looks like this:

And this is a reduced snapshot of the picture recording function:
 Original full size picture: https://dl.dropbox.com/s...0003_20170315_142653.jpg And here is a video clip. The youtube version is reduced in size and quality. The live broadcast does not have the same quality, but it mostly smooth with only small delays depending on the Wi-Fi – coverage.
Direct link to the original full size recording: http://www.zweikommazwei.de/raspi-video.mp4 As I mentioned before, this is not a finished project. With a relatively low programming and design effort, you could also add a lighting switchable via the web surface, or you can switch the RASPBERRY on and off via a function decoder. Theoretically, one could certainly teach the RASPBERRY itself to be the decoder. But that raises the question of effort and effect. But that would be a sporty project either.
Regards
MarkusEdited by moderator 24 August 2017 04:05:48(UTC)
| Reason: Fixed links - the automatic link service was adding a '.' at the end of the link.
|
 13 users liked this useful post by Markus Schild
|
Hackcell, hwestl, GlennM, xxup, Hax, Danlake, seatrains, madhu.gn.71, Bigdaddynz, Brakeman, dickinsonj, Webmaster, MikeR
|
|
Joined: 15/03/2003(UTC) Posts: 9,603 Location: Australia
|
|
Adrian Australia flag by abFlags.com |
|
|
|
Joined: 14/01/2006(UTC) Posts: 1,802 Location: Wurttemberg
|
Hi Adrian, It is available here: https://www.kiwi-electro...zero/raspberry-pi-zero-w I got mine from there. I tried to place an order as an Australian: It worked: Total incl. shipping was € 12,59 excl. VAT (shipping in a letter w/o tracking). Regards Markus
|
 3 users liked this useful post by Markus Schild
|
|
|
Joined: 04/05/2015(UTC) Posts: 777 Location: England, London
|
Originally Posted by: Markus Schild  Hi Adrian, It is available here: https://www.kiwi-electro...zero/raspberry-pi-zero-w I got mine from there. I tried to place an order as an Australian: It worked: Total incl. shipping was € 12,59 excl. VAT (shipping in a letter w/o tracking). Regards Markus Am I allowed a small ironic smile at the name of the supplier?
|
|
|
|
Joined: 15/03/2003(UTC) Posts: 9,603 Location: Australia
|
Awesome.. Thanks Marcus.
I have one on its way to me.. Unfortunately, they only let me buy one - I was keen to buy 4, but one is better than none..
Now I can try out this project - in a couple of weeks when it gets here.. |
Adrian Australia flag by abFlags.com |
|
|
|
Joined: 15/03/2003(UTC) Posts: 9,603 Location: Australia
|
Originally Posted by: Rwill  Originally Posted by: Markus Schild  Hi Adrian, It is available here: https://www.kiwi-electro...zero/raspberry-pi-zero-w I got mine from there. I tried to place an order as an Australian: It worked: Total incl. shipping was € 12,59 excl. VAT (shipping in a letter w/o tracking). Regards Markus Am I allowed a small ironic smile at the name of the supplier? Like nut grass - they are everywhere.. |
Adrian Australia flag by abFlags.com |
|
|
|
Joined: 23/07/2014(UTC) Posts: 8,508 Location: ENGLAND, Didcot
|
Originally Posted by: xxup  I can't find the Pi Zero on either RS or farnell here in the UK either, so they may not stock it at all. The Kiwi-Electronics site that the link was posted for also has a combination kit with the 8MP camera and special cable, although the camera price looks high at a little over Euro 30, considering farnell stock it for £25 one off and £22 three+ in the UK.
|
|
|
|
Joined: 15/10/2006(UTC) Posts: 2,319 Location: Washington, Pacific Northwest
|
The gold is to have a camera that can pivot into the curve like adaptive headlights so that roller-coster-head-snapping-cornering can be lessened. |
|
 1 user liked this useful post by Minok
|
|
|
Joined: 23/07/2014(UTC) Posts: 8,508 Location: ENGLAND, Didcot
|
Originally Posted by: Minok  The gold is to have a camera that can pivot into the curve like adaptive headlights so that roller-coster-head-snapping-cornering can be lessened. Yes, that has been my thought too, after watching many videos of model carried cameras.
|
|
|
|
Joined: 14/01/2006(UTC) Posts: 1,802 Location: Wurttemberg
|
Originally Posted by: kiwiAlan  Originally Posted by: Minok  The gold is to have a camera that can pivot into the curve like adaptive headlights so that roller-coster-head-snapping-cornering can be lessened. Yes, that has been my thought too, after watching many videos of model carried cameras. Hi all, Interesting idea. It would not be to difficult to measure the angle of the leading boogie and move the camera with a servo. I will think about that. Regards Markus
|
|
|
|
Joined: 31/12/2010(UTC) Posts: 4,000 Location: Paremata, Wellington
|
Originally Posted by: Markus Schild  Originally Posted by: kiwiAlan  Originally Posted by: Minok  The gold is to have a camera that can pivot into the curve like adaptive headlights so that roller-coster-head-snapping-cornering can be lessened. Yes, that has been my thought too, after watching many videos of model carried cameras. Hi all, Interesting idea. It would not be to difficult to measure the angle of the leading boogie and move the camera with a servo. I will think about that. Regards Markus Or find a way to bring an attachment up from the bogie to mount the camera onto so that it turns with the truck? |
Cookee Wellington  |
|
|
|
Joined: 14/01/2006(UTC) Posts: 1,802 Location: Wurttemberg
|
Originally Posted by: cookee_nz 
Or find a way to bring an attachment up from the bogie to mount the camera onto so that it turns with the truck?
Hi Cookee, I don't think that this does solve the problem. A camera which traces the rail exactly only will deliver a tagential view. But what we want is to look "inside" the curve. This picture shows what we would get (red) and what would be optimal (green):  Regards Markus
|
|
|
|
Joined: 15/10/2006(UTC) Posts: 2,319 Location: Washington, Pacific Northwest
|
Adaptive headlights use the steering wheel angle and possibly the vehicle speed to adjust the aim, but locos don't have that sort of guidance. One possibility is an accelerometer to detect yaw but for short curves which are quite common, you would still be reacting after the fact. Having an accelerator in a car ahead of the camera combined with a wider field of view on the lense may work. |
|
|
|
|
Joined: 14/01/2006(UTC) Posts: 1,802 Location: Wurttemberg
|
Hi,
I first thought that it could be a good idea to mount a boogie to a potentiometer. But the mechanical force to turn a potentiometer is to high. My second idea is to fit a small magnet at the coupler of the boogie and two hall - sensors above the magnet at the car to determine the direction. The Hall - sensors deliver a variable value which can be used to calculate an angle. Still testing.
Regards
Markus
|
 2 users liked this useful post by Markus Schild
|
|
|
Joined: 15/10/2006(UTC) Posts: 2,319 Location: Washington, Pacific Northwest
|
That does sound promising. You obviously cannot look into the curve until something has begun to turn, at which point you want to swing past the tangential view and cut the curve a bit (overshoot a bit) and likewise when things straighten out you need a slight lag before correcting back to straight ideally (dampening overshoot when entering straights). Of course all of this would make s-curves a nightmare, but we cannot worry about those cases.. though a trip through a rail yard into a station would be an adventure. Dampening the effect by speed (so very slow speed doesn't result in as much movement) might be a desired effect. |
|
 1 user liked this useful post by Minok
|
|
|
Joined: 10/02/2006(UTC) Posts: 3,997
|
just don't use sharp curves. Looks awful from above and they look awful from the cab. No amount of clever feedback and predictive gadgetry will fix the video. |
|
|
|
|
Joined: 15/10/2006(UTC) Posts: 2,319 Location: Washington, Pacific Northwest
|
Markus, Can you go into a bit more detail on the camera your using, and its differences to the Pi Foundation camera? Quote:
- A camera for the RASPBERRY PI from 10, - EUR, original cameras from the RASPBERRY FOUNDATION cost about 30, - EUR.
- An adapter cable for the camera for operation on the PI ZERO: ~ 3, - EUR (the normal cable from the RAPSBERRY PI does not fit).
The Pi Foundation cameras can be had, as you say, for around $30 (from adafruit), and comes with a cable that plugs into the Pi Zero W, as seen in the following Adafruit site image:  Which camera did you use and which cable? Why? Is it the size of the Pi camera or its cost or some other technical aspect that motivated the selection of an alternate camera? |
|
|
|
|
Joined: 14/01/2006(UTC) Posts: 1,802 Location: Wurttemberg
|
Hi Minok, I use a camera sold by the RASPBERRY FOUNDATION about three years ago. It is named "ver 1.3" and was a 5MP model, now they sell "V 2.1" which is 8MP. I think a more modern camera will even get better pictures. The picture shows the normal cable for the regular PI - models on the left and the special cable for the PI ZERO (side inserting into the ZERO) on the right:  I bought the cable at the kiwi- shop in the Netherlands linked above. The cable shown above with the camera does not fit into the slot of the ZERO. Regards Markus
|
 1 user liked this useful post by Markus Schild
|
|
|
Joined: 15/10/2006(UTC) Posts: 2,319 Location: Washington, Pacific Northwest
|
Originally Posted by: Markus Schild  Hi Minok, I use a camera sold by the RASPBERRY FOUNDATION about three years ago. It is named "ver 1.3" and was a 5MP model, now they sell "V 2.1" which is 8MP. I think a more modern camera will even get better pictures. The picture shows the normal cable for the regular PI - models on the left and the special cable for the PI ZERO (side inserting into the ZERO) on the right:  I bought the cable at the kiwi- shop in the Netherlands linked above. The cable shown above with the camera does not fit into the slot of the ZERO. Regards Markus Ah, ok. They now (Adafruit, for example) sell kits that have the camera The new 8mp version) and cable to the Pi Zero W: https://www.adafruit.com/products/3414, that have a very short cable. Or, as we don't need the case, one can just buy the longer cable for $US 6 ( https://www.adafruit.com/products/3157) (or add the longer cable to ones order)..  I'm looking at the LSM303D accelerometer on the Pimoroni Enviro pHAT for Raspberry Pi Zero as an option for getting yaw data in turns. |
|
 2 users liked this useful post by Minok
|
|
|
Joined: 15/03/2003(UTC) Posts: 9,603 Location: Australia
|
I can play now that my PI Zero W has arrived down under..  I managed to get the camera cable locally.. |
Adrian Australia flag by abFlags.com |
 1 user liked this useful post by xxup
|
|
|
Joined: 03/06/2013(UTC) Posts: 431 Location: Melbourne, VIC, Australia
|
Hi All, I'm thinking about giving this a go for a display project, but it would need to run independently for long periods of time, so battery power supply wouldn't be an option. How hard would it be to get the necessary 5V source from track power via a slider? I know very little about electronics, but I guess this would require a capacitor as well the necessary voltage step down and rectification to DC. I assume that it would be too much power to draw from one of the AUX supplies on a decoder? (Please excuse if this is a really dumb question  ) - H. |
- Herman |
|
|
|
Joined: 15/03/2003(UTC) Posts: 9,603 Location: Australia
|
You could do this, but track power is not typically very clean due to problems like dirty tracks and wheels. Of course, you can improve things by complicating the design of the transformer to include capacitors or rechargeable batteries to provide the power when then voltage drops.
Depending on their size, these battery packs last for hours. How much recording time do to really want out of this great solution? Buy two battery packs and swap them out once per day. |
Adrian Australia flag by abFlags.com |
|
|
|
Joined: 03/06/2013(UTC) Posts: 431 Location: Melbourne, VIC, Australia
|
Originally Posted by: xxup  You could do this, but track power is not typically very clean due to problems like dirty tracks and wheels. Of course, you can improve things by complicating the design of the transformer to include capacitors or rechargeable batteries to provide the power when then voltage drops.
Depending on their size, these battery packs last for hours. How much recording time do to really want out of this great solution? Buy two battery packs and swap them out once per day. It'll need to run by remote control for a week at a time. |
- Herman |
|
|
|
Joined: 15/03/2003(UTC) Posts: 9,603 Location: Australia
|
I was just thinking that it would be a noble project for an Electronics Engineer on this forum to come up with a design for a reliable and compact Track supply to 5V project.. |
Adrian Australia flag by abFlags.com |
|
|
|
Joined: 15/10/2006(UTC) Posts: 2,319 Location: Washington, Pacific Northwest
|
If what you need is 5vdc then take the track power and pass it through a small rectifier and capacitor to a 5vdc converts that will convert the track power down and get you consistent power over a range of input voltages glu might get from the track. The rectifier and 5v regulator are both Integrated Circuts go can buy off the peg and as well as the capacitors. Cobbling together a small supply that lives off of the track power would be easy enough, assuming the system draws a low enough currents to not exceed the booster of track power's capacity. I expect they are lots of sample circuit designs online for such a very common thing.  You might need to change the part used to match the input voltage range you get from track power, i.e. The Min and max voltages you get from the track. |
|
 1 user liked this useful post by Minok
|
|
|
Joined: 14/01/2006(UTC) Posts: 1,802 Location: Wurttemberg
|
Hi Herman,
Look at eBay for small, ready made step-down boards for 5v. They are very cheap. You can connect them with a rectifier to the slider. So you can charge the battery while running the train. I wouldn't try to run it without a battery. The raspi needs a very stable power supply.
Regards
Markus
|
 1 user liked this useful post by Markus Schild
|
|
|
Joined: 18/11/2015(UTC) Posts: 221 Location: Brisbane,Australia
|
Another option is to add a supercap ( 1Farad 5.2 volts) to the output of the 5 volt rectifier. I have done this and it is very effective. Note the 7805 is linear and could get a bit warm depending on the voltage applied and the current draw. I prefer small switch mode regulators now as they are thumb nail size and will handle 800 mA to an amp. Slightly larger ones will handle 2 amps. Howard.
|
 4 users liked this useful post by ixldoc
|
|
|
Joined: 02/02/2017(UTC) Posts: 695 Location: England, South Coast
|
Originally Posted by: Markus Schild  Originally Posted by: cookee_nz 
Or find a way to bring an attachment up from the bogie to mount the camera onto so that it turns with the truck?
Hi Cookee, I don't think that this does solve the problem. A camera which traces the rail exactly only will deliver a tagential view. But what we want is to look "inside" the curve. This picture shows what we would get (red) and what would be optimal (green):  Regards Markus As one who owned a Citroen DS for many years I'd suggest a quick look at how its swivelling lights worked. It was a system of wires and springs that when understood was extraordinarily obvious. OK so it didn't pre empt what the driver was about to do but at times it seemed so.
|
 3 users liked this useful post by Michael4
|
|
|
Joined: 02/02/2017(UTC) Posts: 695 Location: England, South Coast
|
Progress here, our son has made the beginnings of one of these for me and it works. I won't post any results yet, at the moment trailing cables get tangled with catenary. He has yet to write some simple short cuts for my Mac so I know what I am doing.
As to the issues with the view on corners it seems to me that the camera should be mounted on the forward bogie (or truck) of the wagon so that it turns with the first wheels, that may mean that it will turn sooner and reduce the vertiginous effect of being dragged round a corner.
I was going to put the whole thing in a battered old tin coach but on reflection this might not be a good idea...
We'll see, it is quite a lot of fun!
|
|
|
|
Joined: 05/12/2008(UTC) Posts: 1,809 Location: Crozet, Virginia
|
Originally Posted by: Michael4  As to the issues with the view on corners it seems to me that the camera should be mounted on the forward bogie (or truck) of the wagon so that it turns with the first wheels, that may mean that it will turn sooner and reduce the vertiginous effect of being dragged round a corner. I believe that the bogie mount idea should work very well. I do this stuff for a living and I think that the idea of a pot, some adaptive algorithms and some servos to aim the camera sounds like fun. When we work for the US government that is exactly what we would do, using a whole team of software/electrical/mechanical engineers and techs. But I am the poor customer here and really, what we actually require is to just see things from the perspective of being on the train. And how could that get any better than panning with the motion of the front of the wagons on the track? That is the same perspective that a loco engineer would have after all. I think that the art of building a good electro-mechanical system is understanding when a simpler mechanical solution works just as well as a complex software solution does, even if we don't get the fun of doing it electronically. BTW the Pi write up is excellent Michael and makes it much more likely that I will find the time to try this fun project myself. Thank You. |
Regards,
Jim
I have almost all Märklin and mostly HO, although I do have a small number of Z gauge trains!
So many trains and so little time. |
|
|
|
Joined: 02/02/2017(UTC) Posts: 695 Location: England, South Coast
|
Jim,
Don't send any credit my way, it was Marcus who inspired us to have a go! Your comment about 'the art of building' etc makes me start thinking about a Citroen approach again.
|
|
|
|
Joined: 05/12/2008(UTC) Posts: 1,809 Location: Crozet, Virginia
|
Originally Posted by: Michael4  Don't send any credit my way, it was Marcus who inspired us to have a go!
Good point Michael, my mistake. It was indeed Marcus who I intended to thank for the information and inspiration on doing this cool project. Originally Posted by: Michael4  Your comment about 'the art of building' etc makes me start thinking about a Citroen approach again. Excellent - be sure to let us all know how that goes if you decide to do it!  |
Regards,
Jim
I have almost all Märklin and mostly HO, although I do have a small number of Z gauge trains!
So many trains and so little time. |
 1 user liked this useful post by dickinsonj
|
|
|
Joined: 02/02/2017(UTC) Posts: 695 Location: England, South Coast
|
Ignoring the image quality for now (the protective film is still over the camera's lens) This is a first effort with the vidtrain being towed rather than pushed. The 'helter skelter' effect is still there on corners but there is a long way to go... OK so my layout looks like a scrapyard.
|
 4 users liked this useful post by Michael4
|
|
|
Joined: 02/09/2017(UTC) Posts: 1 Location: Groningen, Groningen
|
i tried something similar last year, but with a bigger model RasPi, this is way more portable, if you have a large goods wagon you could make a dedicated one :)
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.