Forgot Login?   Sign up  
Tuesday, November 12, 2024

Forum Search

Keyword

Building and Programming a Micro Controller

More
15 years 8 months ago #2898 by Beverly56
So you've seen the photos of the micro controller in the Gallery. Here's the method Chris used to decide on what circuit boards to buy, his research methods, and programming methods. He is not a member of this board, so I am posting for him. Any and all questions will be relayed to him and I will give you his answers.....



After seeing Karin's Dizzyland video on YouTube, I thought it would be great to have my micro layout automated, so I asked Chris if he could make the train:

- go around the track X many times
- slow down and stop at a predetermined place
- start up again then go around the track some more
- and have all the appropriate train sounds to go with all the train's movements

He started out looking into what the current model train culture is using for electronics and stumbled onto the whole world of DCC, LocoNet and terminology like "chuffing". What the heck is "chuffing", he wondered?

Chris learned that the typical method for implementing a controlled train model would be to put DCC decoders in the loco (and tender if required) and then use a DCC controller to remotely control the loco speed and sound. This sounded like a great idea and would be pretty simple. I pointed him to a thread on [url=http://www.trainboard.com/grapevine/showthread.php?t=82441
]Z scale decoders[/url]. After reading the thread he was quite sure all he needed would be something like a DZ123 decoder for motor control and some sound decoder from Digitrax to integrate the sound set into the loco. Pretty simple, he thought.

Then we received our Starlight Express loco and caboose. The first thing we noticed was the thing was SMALL. Darn SMALL. Chris took it apart to see if the DZ123 would fit. There is approximately 0% space inside the loco, so he couldn't go the DCC path and needed to start thinking about other options.

He looked at the Soundtraxx Tsunami sound decoders but there was still the problem of putting them inside a loco with no space.

Chris had a short email conversation with DigiTrax tech support and learned that their sound decoders could operate in analog mode. That meant he could attach it to the track in a fixed location and the decoder would then make sounds that would be appropriate to the speed (voltage) of the train. That didn't make too much sense to him as he would still need something to control the speed of the train.

With his background in electronics and computers, he started looking at micro controllers. He was surprised to see the advancements that had occurred in the hobbyist market in the last ten years. There seemed to be a lot of community involvement behind the "parallax basic stamp" and the Arduino family of hobby boards.

After doing some research and poking around, he settled on doing something with an Arduino. The requirements were:

- computer control
- programmable over a USB cable
- power control (for speed)
- some form of sound playback
- an easy programming language

He ordered the following parts from Adafruit Industries to start building the system:

- Arduino w/Atmega328 (assembled)
- Adafruit Proto Shield for Arduino Kit
- Adafruit Motor/Stepper/Servo Shield for Arduino kit
- Adafruit Wave Shield for Arduino Kit

There were other places he could have gotten them from but two things came up:

- Adafruit is the designer/manufacturer of the Wave Shield kit
- Adafruit took PayPal

Another consideration for Chris was how much space will this computer take up? Since I is doing the initial work in Blue Styrofoam, we thought we would hollow out a space inside it just large enough for the computer parts. The only issue was that the Arduino boards are typically stacked like pancakes. This makes a three board combo about 1.5 -2.0 inches tall, and he thought there might not be enough room to do that. As it turns out, the stacked boards will work fine.

I also wanted to be able to disable computer control and use an external controller to run the train. Chris though this shouldn't be too much trouble. I also wanted the lights in the houses to operate when the computer is not operating the train and he thinks he can do that also.

While the parts were being shipped from Adafruit, he started searching for sounds and/or sound tracks that could be used for the Z scale model.

When he was going through the DigiTrax web site, Chris found good information on sounds. They have sound sets that can be upload into their sound decoders using a program called "Soundloader". He downloaded it and played for a while. However, what he really wanted was the sounds to be separate. So, being the geek he truly is, Chris spend an hour or two tearing apart br_44xx.sfk file from the Digitrax website. The file format is pretty simple once you look inside, and he got the sounds separated out to their original .wav files after a little work. He's not sure if he'll use the Digitrax sounds at all, but thought it was a good investment of time.

Chris also found an interesting sound website at Soundsnap . They have some pretty good steam loco sounds. He downloaded a few and thinks he will use them to construct the soundtrack.

Another good suggestion I found on the Digitrax web was using ACID Xpress for sound editing. He thought it seemed pretty cool and will probably use it to construct the soundtrack. He did some initial hack together to see how hard it was and found it quite easy.

I told Chris that the sounds had to be from German trains, and he went off to YouTube and searched for "Steam Train Sounds". I also suggested translating it to German and searching for "Dampfzug". Both produced some nice videos.

Chris spent an evening watching and listening to videos of trains and learned a lot about what he needed to do. One thing that really became apparent to him was the layering of sounds. There is the ambient noise, the clicky-clack of the tracks, the steam noises, whistles, clanking of connectors, the firebox being stoked. All these sounds are going to be layered together to produce a sound track.

This led him to the question: Will he program the motion of the train, and sync the sound to the motion, or will he compose a sound track then make the train move in sync with the sounds? He's leaning to mostly doing the soundtrack first and then making the train match the sound. He has the feeling it will be easier to hack the motion than hack the sounds.

Chris had the idea of putting a reed switch under the track somewhere before the stopping point and using a tiny magnet under the loco to trip the switch and tell the computer that where the loco was on the track. Something like the location transponders that DCC control have, but much simpler.

On March 7, Chris started assembling the Arduino boards. He was a little surprised that they came in kit form (except for the one that was listed as assembled), so he spent the evening assembling the proto shield and the wave shield. He said it was interesting that the assembly instructions are on the web. He had a laptop on the kitchen table displaying the assembly instructions while he was soldering parts onto the board.

Once assembled, he tried to talk to the board with the laptop. The software is all written in java and available for download from the Arduino website. Everything kept locking up on him and not working, so he called it a night and went to bed.

On March 8, Chris spent some time reading the Arduino troubleshooting FAQ. Nothing they had listed there helped him, so he finally resorted to the last option. - ask questions on the forums. As soon as he got there I found the answer he was looking for. Since the Arduino board purchased was a Duemilanove, he had used that as the board type in the software. The solution was to change the board type to a "Arduino w/ATmega328". The board was upgraded by the vendor he thinks. Once he did that, everything started working. He got the little "blink an LED" program running right now. In some ways, I'm pretty impressed that he's now got a flashing light out of a strange wet of unassembled little thingies.




I'll post updates from Chris when he provides them. Tonight he's run into a problem getting the sound baord to operate, but thinks it's not a big dea and will find the soluion.

I hope this is useful to those of you on the board with computer/electonics backgrounds :)

Please Log in or Create an account to join the conversation.

More
15 years 8 months ago #2902 by ausman2001
Replied by ausman2001 on topic Re:Building and Programming a Micro Controller
Hi Beverly and thanks for sharing yours experiences with us. Electronics is terror incognito (pun intended) for me, but I'm sure that it isn't for a lot of the members here.

While not wishing to teach my grandma to suck eggs, the one potential problem that crossed my mind was "Since I is doing the initial work in Blue Styrofoam, we thought we would hollow out a space inside it just large enough for the computer parts". Might heat dissapation be a problem? I know that when Marklin tried to go down the digital path with Z scale in 1988 that was what stopped them (putting decoders into very small locos). Of course the technologies have come a long way since then, so maybe it isn't an issue at all.

Please Log in or Create an account to join the conversation.

More
15 years 8 months ago #2904 by Beverly56
Replied by Beverly56 on topic Re:Building and Programming a Micro Controller
Gary,

I've asked Chris about the possibility of heat problems several times. He keeps telling me there shouldn't be a problem. In everyday situations we're probably going to be running the train for less than a half hour. But if we go to the local train show and run the locomotive for long periods of time, heat might well be an issue. I'll have to mention the long periods of time issue to him to see if he still has the same answer.

We're still in the planning stages of how the controller will be mounted beneath the foam. One great thing is that the glass cover came with a round wooden base, and the base has a 1/4" high lip. The foam will be mounted to the top of the lip, so there will also be a 1/4" high space under the entire foam area. We could drill a few holes in the bottom of the wooden base and raise the base with 1/8" to 1/4" felt pads. We were going to put the felt pads beneath the base anyway to help whole structure slide easily on tables, etc. When I spoke with Chris this morning about the mounting issue, he said he'd like about an extra 1/4" all around the controller so he can work with the wires, etc. I know that heat rises, so all the holes in the bottom might not do much to dissapate the heat. He and I will have to discuss this issue in greater depth. Thanks for bringing it up :)

Please Log in or Create an account to join the conversation.

More
15 years 8 months ago #2911 by ausman2001
Replied by ausman2001 on topic Re:Building and Programming a Micro Controller
The felt pads should also provide sound insulation, although wood is in itself a good insulator.

Please Log in or Create an account to join the conversation.

More
15 years 8 months ago #2923 by Beverly56
Replied by Beverly56 on topic Re:Building and Programming a Micro Controller
Gary,

I carved out the space beneath the foam today and gave it a couple of coats of paint to keep any foam bits from falling. The space about 4 or 5 times the volume of the controller, so there is a lot of room to do electrical stuff and other maneuvering and not be cramped.

I brought up the heat issue again. The controller had been on all day sitting on Chris' desk. He picked it up and each of us touched it. It was cool. But, wait! It was sitting in the open all day and wouldn't have a chance to heat up like it would if it was in a confined space. So I laid down a towel, put the controller on the towel and the foam over the controller, then wrapped the towel over the foam to make it relatively airtight. After about an hour, we took it out, and, yes, it was hot. Not burning hot, but hot enough for heat to be an issue if we ran the train for awhile.

The solution to the heat problem is that we will cut a 1 1/4" by 4 1/4" hole in the wood base and cover the hole with screen material to keep out most foreign matter. The controller will straddle the hole, plus there will be enough of the hole open on both sides of the controller to allow for some air movement - I think. The controller is 2 1/2" by 3" by 1 5/8" high, and it is raised by rubber feet by 1/4". I also raised the wood base by 1/4" rubber feet instead of felt. Rubber will keep the diorama from moving - keeping the whole thing from possibly landing on the floor.

Please Log in or Create an account to join the conversation.

More
15 years 8 months ago #2925 by TerryH
Beverly, consider drilling a hole in the foam above the controller to allow the heat to rise up and out the hole. Your houses and trees will hide the hole. Also, remember the dome will trap the heat inside so you may want to consider an exhaust fan under the controller blowing heat in an down and outward direction, IF necessary.

Please Log in or Create an account to join the conversation.

More
15 years 8 months ago #2941 by Beverly56
Replied by Beverly56 on topic Re:Building and Programming a Micro Controller
Hi Terry,

Because heat rises, the best way to get heat out is through the top as you suggest. I've been adding coats of plaster of Paris to my foam today, which is going to add even more inuslation around the controller. We can't test for heat dissipation until the plaster dries, Chris cuts the hole in the wood base, and I prep the wood before gluing on some screen material. We are going to enlarge the bottom hole to about 5 1/5" long which could be helpful.

If, after testing, heat is still a problem, I've been thinking about where I could drill a hole or two or three and not have it/them seen. I am working with a very small area under that glass dome. And then the area has several different levels where a variety of things happen. For instance, the inside diameter under the glass is 9 7/8". The inside diameter of the cork track bed is 7 5/8", which may make the cork bed seem very wide, but the cork bed also includes slopes all around the elevated track and cork. It's inside the 7 5/8" that the three houses stand, and each house is on a different elevation which reduces the useable area to an even smaller areas because there have to be slopes going to the various elevations.

Up inside the foam, there are two areas toward the back of the diorama where it would be best to drill holes, if needed. There will probably be trees and forest floor material in these areas, but even so, it's going to be pretty hard to disguise holes when the materials in Z scale are so small that they will probably fall into the holes. Even if I use screen to help cover the holes prior to adding landscaping material, the glue used to hold the materials down could clog the screen.

I'll let you know how the testing turns out.

Please Log in or Create an account to join the conversation.

More
15 years 8 months ago #2942 by TerryH
Beverly, you should only need one hole and it doesn't need to be big, maybe 1/4 inch and can be placed above the control unit. maybe in the center of three trees. That should hide it fairly well. Heat transfers just like cold through a tiny crack in a window or door, so the hole doesn't need to be big. You could use a straw and run it up inside a house and out the roof, making a vent stack on the roof. Lots of options to hide it if needed. Good luck and thanks for the update.

Please Log in or Create an account to join the conversation.

More
15 years 8 months ago #2943 by Fred
Beverly,
I've been thinking about this and I'm sure you have already thought of this-- have the holes vent out to inside the houses, the chimneys could be hollow to allow heat to go up the chimney, or have a door or windows open... I have no idea how much heat is going to be generated.. It might warp the houses if you use this method. you still have to get it out from under the glass. How bout a culvert that exits through the foam sides just under the outer perimeter (bottom) of the glass top. Maybe the heat can be diverted thru the "Stone" culvert.
Just thinking thru my hat.:blush:
Fred

Please Log in or Create an account to join the conversation.

More
15 years 8 months ago #2944 by Fred
Boy , I should read before I post. Sounds like Terry beat me to the punch and covered most of it. I use a knitting needle to put a long hole in the foam, for wiring. Then I insert a brass tube that allows the wires to be fed without stoppage-- maybe the same for hot air. I remember as a kid we had some Christmas decorations that fitted on the lights, as the heat built up, the decorations would spin, as they were balanced on a needle point. You might not be able to use this adaption on the present project, but maybe in the future.
Fred

Please Log in or Create an account to join the conversation.

More
15 years 8 months ago #2945 by Fred
Maybe the brass "vent pipe" could be a "Wishing Well". That would protect it from falling debrise while sceniking, etc. really pulling at straws here...
Fred

Please Log in or Create an account to join the conversation.

More
15 years 8 months ago #2951 by Beverly56
Replied by Beverly56 on topic Re:Building and Programming a Micro Controller
Terry and Fred,

My houses are all glued up tight to keep them light tight. Now, I'm thinking about heat build up inside the houses! The two easy houses each have a tiny light inside, and the advanced house has two lights. Darn! The chimneys are pieces of carved wood glued to the rooves, so I can't really do anything there, at least for now. You guys have got me thinking hard over this.

Fred,

I like the wishing well idea, though I'm not sure they have wishing wells in Germany, but they must have wells, or something similar. I'm going to take your idea and see what I can do with it. Good thought :)

Please Log in or Create an account to join the conversation.

More
15 years 7 months ago #2986 by TheWag
This looks very interesting. So much so my wife will probably give me a good tounge lashing when the starter kit arrives from adafruit. :dry:

Look forward to hearing more about the project.

Please Log in or Create an account to join the conversation.

More
15 years 7 months ago #2996 by Beverly56
Replied by Beverly56 on topic Re:Building and Programming a Micro Controller
TheWag,

:laugh: :laugh: :laugh: Glad to have inspired you :) What are your plans for the controller?



A quick update:

Last night, Chris managed to remove the front coupler from the locomotive and installed an itty bitty magnet where the spring and coupler were. Darn, and he managed to lose the spring and we searched for the little thing for a long time and did not find it :(

Anyway, the idea with the magnet in the locomotive is to trip a magnet detector thing (don't know what it's called) placed under the track so a light and a sound are made on the device he had the magnet detector hooked up to. Boy, I'm sure using all the technical terms here, aren't I :blink: The detector only picked up the passing magnet every three or so trips around the track, which wasn't to his satisfaction.

Tonight he's going to find out if slowing the train will make a difference in detecting the magnet, or if the magnet is detected exactly every three trips around the track. I don't know what his Plan B is with the magnet thing, but it is very important for the magnet to be detected. When it is detected, it will send signals to the controller which will make the locomotive either keep on at the present speed, slow down, stop, or speed up. Then there will be appropriate train sounds associated with whatever speed the train is going. To me, the task would be impossible. I'm so glad Chris is able to do these things :)

Please Log in or Create an account to join the conversation.

More
15 years 7 months ago #3190 by Beverly56
Replied by Beverly56 on topic Re:Building and Programming a Micro Controller


Last night we finally had a chance to set up the micro controller in the cavity between the wood base and the foam and plaster diorama. You can see in the photo that there is a fairly long hole cut into the base of the wood and that the controller straddles this hole. Also in the photo is a layer of screen material to help keep out (some) dust. The black line drawn on the wood is an outline of the cavity.

The controller was left on all night with the diorama placed over the wood base containing the controller. The whole set up was placed on my wood workbench instead of on the marble countertop which would have acted as a heat sink. Also, the glass cover was placed on top of the diorama for added heat retention if there was going to be any heat going up through the four house lighting holes.

This morning, after 10 hours, I removed the glass cover and diorama and found that the controller was warm - not hot at all - but warm. Yes! Another success is design! I was expecting a hot controller that this success is particularly sweet :)

The next heat test that has to be done is with the lights on in the houses. Chris has a hand held drill with a 1/16" drill bit. We did a test drill on one house between the chimney and the peak of the roof. The hole is small, but the location of the hole hides it from view. Once we get all of the houses drilled and the lights hooked up, whenever that will be, we'll test.
Attachments:

Please Log in or Create an account to join the conversation.

More
15 years 7 months ago #3201 by TheWag
Hey Beverly,
Glad to hear your smoke test didn't smoke! :woohoo: I'm thinking of using the unit as the brains to a quasi "computer" controllable layout. Speaking of witch, are you using the motor shield to power the loco or the PWM outs?

Well, for now I've got a few things to play with. Of course, to do some real testing I guess I'd need to build that "dream" layout I keep thinking of...and buy my first loco!! LOL. Maybe for Father's day. ;)

Keep me informed!
Ben

Please Log in or Create an account to join the conversation.

More
15 years 7 months ago #3204 by Beverly56
Replied by Beverly56 on topic Re:Building and Programming a Micro Controller
Ben,

Chris says he's planning to use the motor shield to power the track because he is unsure if the PWM outputs can generate enough current. Maybe he'll change his mind after a little testing.

Tell us a little about your dream layout :)

Please Log in or Create an account to join the conversation.

More
15 years 7 months ago #3886 by Beverly56
Replied by Beverly56 on topic Re:Building and Programming a Micro Controller
Just a quick update....

After some research as well as trial and error, it was discovered that the Arduino controller will not have the capability to do sound as we had planned. Chris says that if he had done more research prior to buying the Arduino boards he would have probably gone in a different direction to achieve the motion and sound capabilities that were on my wish list.

As it currently stands, there will be no sound with this layout, which is okay by me as long as we are able to get the locomotive running up to snuff. Unfortunately, the locomotive's brushes are worn and we figure it might be a good time, while replacing the brushes, that it's a good time to upgrade the motor from a 3 pole to a 5 pole. This way, we'll have a great looking locomotive that will also run well.

Once the locomotive has had its motor changed, Chris can then program the train to slow down before stopping, stop for a period of time, start up slowly and slowly gain speed, then go around the track for a pre-determined number of times before slowing down to stop again.

It might be awhile until the motor is upgraded. In the meantime, I'm still waiting for my unpainted Preiser figures to arrive so I can paint and add them to the micro diorama along with the final landscaping touches. During this downtime, I'm working on the Z PBL Challenge as well as doing some planning for our door layout. Yes, there is always a Z activity going on with us these days.

Please Log in or Create an account to join the conversation.

More
15 years 7 months ago #3890 by TerryH
Hi Bev, upgrading to a 5-pole motor is a good thing. Sorry to hear about limitations on the circuits. I'm sure Chris will come up with something. I got a manual sound controller as a gift, it is stand alone and could probably be easily programmed with a bit of circuitry. I'll look up the details on it and get back to you. Good luck with your PBL entry.

Please Log in or Create an account to join the conversation.

More
15 years 6 months ago #3923 by Beverly56
Replied by Beverly56 on topic Re:Building and Programming a Micro Controller
Terry,

We have four Marklin locomotives that have 3 pole motors. We're looking into upgrading all four to 5 poles.

As for sound on the micro diorama, well, it was a valiant effort on Chris's part to give it a try. I don't mind that he isn't able to do it. Not having it on his plate just gives him more time to work on our large layout ;) :)

A lot of Z projects are in limbo right now. I'm waiting for some unpainted Preiser people to show up so I can finish the last of the micro diorama's landscaping. I'm waiting for Alvaro's cars to arrive so I can work on my Z PBL Challenge diorama as well as the two teapot dioramas. Chris is waiting for word back from two possible sources of 5 pole motors and people who will do the conversions for us. The Marklin 8188 locomotive Chris is working with on the micro diorama isn't working correctly and it's better to wait until the locomotive is working perfectly before programming the motion.

I still have lots to do, though. We put together a box with large sheets of black electronics packing foam to transport the micro diorama and the glass cover. Just this morning I covered it with upholstry grade fabric to make it look a little more presentable. I used some really goopy silicone-type stuff to hold the fabric in place on the bottom. I'll take photos of it once the goop cures and I take the stack of books out of the box.

I've also got a cupboard full of German building kits to build. I'm a little bit intimidated by working with the plastic glue on those kits. Ah! I should just do one and get it over with :S

BTW, what are you thinking of doing for the Z PBL Challenge?

Please Log in or Create an account to join the conversation.

Time to create page: 0.503 seconds