Forgot Login?   Sign up  
Saturday, November 30, 2024

Forum Search

Keyword

Arduino [or other uCPU] controlled.....

More
11 years 9 months ago #15145 by TheWag
Replied by TheWag on topic Re: Arduino [or other uCPU] controlled.....

markm wrote: I've looked at both sites, and a few others, plus 3 or 4 books. While I wouldn't discourage anyone from using them, they all look a lot alike with the same examples and similar commentary and they all seem to miss the fact that programming a microcontroller is different than a microprocessor (PC) and the subilites they miss can make a big difference in the success of a program.


There is part of the difference. The "Arduino" method is to remove complexity. Make it more "accessible" to the masses. Don't get caught up in technicalities. That is also why there IDE is designed for a setup and loop and removes the main() construct. It is interesting to lurk on the dev list and see how they try to hide the complexity.

Personally I hate the way the IDE is designed and use my own makefiles.

I'm also curious as to your example. I'm curious as to why you'd prefer one method of the other on the uC. You mention a lot of experience. I'd love some pointers from a master.

Ben

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

More
11 years 9 months ago #15152 by markm
"Everything should be made as simple as possible...but no simpler" - Einstein

Ben,
I'm impressed with what the Arduino people have done in putting a wrapper around the Atmel software and hardware, but there are fundamental differences between development of a computer program and a uC project:
For the uC you are building and debugging the software and hardware at the same time. If the project doesn't work you can be hard to debug.

Microcontrollers have limited resources and you always need to keep that in mind. In the case of the UNO I have, that limit is 31K of program memory, 2K of volatle data memory and 1K of non-volatle data memory.

So I'm a strong advocate of defensive programming and like to see it taught as a basic concept.

As far as the examples, the int led = 13; code creates a read/write variable, 2 bytes in length that can be modified anywhere in the program, which defines a device pin that can range from -32K to + 32K, which is a bit silly.

So unless your intent is to change the pin number in the program, its much safer to add the const , and make the variable read-only. The compiler will complain if you accidently try to change the variable.

Add the unsigned to eliminate the possiblity of negative pins numbers.

Change the varible size from int to byte which limits the range of the pin number to 0-255. This also reduces the blink program size from 1084 bytes to 1076.

So the optimum code for blink would be
const byte led = 13;
While not a perfect solution it does eliminate a lot of potential errors.

The #define does a string substitution of "13" for "led" everywhere in the program before compile,which can be useful but can make a real mess if not used carefully and I would advise beginners to avoid it.

I don't think the defensive programming concepts of making numbers no bigger than necessary and making the number read/write only when you intend to change them difficult, although I'd like to hear opinions about this explaination.

Mark

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

More
11 years 9 months ago #15156 by Zcratchman_Joe
Replied by Zcratchman_Joe on topic Re: Arduino [or other uCPU] controlled.....

markm wrote: ...although I'd like to hear opinions about this explaination.
Mark

Mark,

I believe there’s a time for “tight” (concise) code, and a time for “right” (proper) code. What I mean by this, is that when programming with size/memory constraints, tighter code, that may be a bit dangerous, may be needed over what might be a more proper way to do things.

In this example, your code not only tightened things up, but also righted what could be considered improper coding for the intended purpose.

Re: Ben’s post previous to this one mentioning an IDE. It’s been mentioned elsewhere in this thread about things sounding like “geekspeak”. A lot of non-technical folks might have only heard the term IDE when referring to a type of hard drive or CD/DVD-ROM (Integrated Drive Electronics) which would make no sense in the context it was used here (Integrated Development Environment). [Don’t take offense Ben, “geekspeak” is used throughout this thread and I only used IDE because of its many meanings.]

When we’re talking about techy stuff on a non-techy forum, we have to remember that the people that ask for the help here are more than likely clueless to the meaning of the majority of what the tech-savvy people are discussing. It’s easy to write about things with terminology we might be used to using, but more than likely there’s another way to say the same thing (using the long drawn out boring terminology that others might just understand.) It’s something to keep in mind anyway.

Joe

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

More
11 years 9 months ago - 11 years 9 months ago #15157 by Kelley
Replied by Kelley on topic Re: Arduino [or other uCPU] controlled.....
I still cannot believe I started this topic :blink: So if I get my hands on one of these whizdoodles,I could get someone to program it to make turn on blinky lights and bells? ;) ;)
Thanks guys for talking this out. I am wondering if you all could set something up and show what hard ware to get, how to wire it up and how to program it here.
I have some lighted cross bucks, and they will be used on double tracks. I would like to activate them, have them blinking (simulated incandescent) and a bell go off and on automatically.
These little processors things could be their own forum topic, and would be useful for a LOT of people. I appreciate you guys replying and all the feedback!

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

More
11 years 9 months ago #15161 by Zcratchman_Joe
Replied by Zcratchman_Joe on topic Re: Arduino [or other uCPU] controlled.....

Kelley wrote: ...I am wondering if you all could set something up and show what hard ware to get, how to wire it up and how to program it here...

Kelly, actually someone has already done “just about” what you ask. Please carefully read through and try the tutorial I suggested earlier ( www.ladyada.net/learn/arduino/index.html ). It tells you exactly what you asked for here and after you get through, say Lesson 3, you could try cut and pasting in the code Mark posted earlier (post #15081). By then you’ll have learned a bit on your own as well, and all for a total cost of around $75.00 including the Arduino (but not any tools you may need and probably already have anyway). Then, for a start, you can Google “Arduino sketches for model railroading”. You’ll find there are websites and forums devoted to such things for when you get stuck, plus by then I’m sure there are others here that can help you. :)

Joe

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

More
11 years 9 months ago #15188 by markm
Kelly, all,
Since I'm planning to do a crossing signal with detection and block control, I'd be willing to document the project and discuss it here if there is interest. I would suggest people look at the ladyada site LED chapter to get a feeling for what will be needed in construction skills supllies and equipment before getting involved.

I haven't mention my current project yet. It's a Christmas animation. A small train goes around a 24" oval passing by a small mountain village with a station. Using a 24 hr fast clock, every so often, a semaphore stops the train at the station for passengers. As 5PM rolls around, the lights flicker on at the town square with a lighted Christmas tree, come on at the station and in the local houses. As time passes the lights go out in the station and on in the stationmaster's quarters, the fires are lit and die down, which the bedroom light coming on and going out. Using the night, when the train is going to stop at the station, the lights go back on in the station quaters and in the station proper, after the train leaves, the lights go out. As "morning" arrrives lights in the houses come on as the "sun comes up" all lights go out.

Mark

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

More
11 years 9 months ago #15189 by Kelley
Replied by Kelley on topic Re: Arduino [or other uCPU] controlled.....
I have a drawing of a train order board in z scale that someone was going to try and etch, but never got back with me. It is teeeeny tiny. There is enough of those push pull kind of servos around to make it work.

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

More
11 years 7 months ago - 11 years 7 months ago #15470 by elafargue
Replied by elafargue on topic Re: Arduino [or other uCPU] controlled.....
I just came across this forum topic by chance: I have actually just designed a Z-Scale train controller that uses an Arduino. The controller drives one loco with speed regulation, and controls up to 16 Maerklin turnouts. The user interface is a web page, which means that you can control your train from your desktop, ipad, or even mobile phone, I made the design responsive.

Since the project took a not so insignificant amount of time, I have decided to document it on my blog, at www.aerodynes.fr
, in a series of about 12 articles, that describe the whole thing, from hardware design all the way to the HTML5 web app. Everything is published on github as well.

Attached, a few screenshots of the interface, hoping this be interesting for some of you!
Attachments:

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

More
11 years 7 months ago #15472 by stonysmith
Replied by stonysmith on topic Re: Arduino [or other uCPU] controlled.....
Thanks for posting this!
I need to go back and try the LM293 again.

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

More
11 years 3 months ago #16027 by stonysmith

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

More
10 years 6 months ago #17198 by CreatorLes
Replied by CreatorLes on topic Re: Arduino [or other uCPU] controlled.....
Hi, I'm new here and caught this thread right off. I have done some Arduino programming of the little ATtiny85 Arduino chip. It's an 8-pin DIP package so with power, ground, and reset you are left with 5 pins to control interface circuitry. It has analog and digital in, plus digital out including pulse width modulation on some output pins. That's not a lot of I/O, but the chip is small so it only costs $2 each in small quantities.

One approach to automation of a railroad would be to avoid the ratsnest by using a communications bus with lots of the little wonders on it. Each one can be programmed with an address so that the master Arduino chip that humans communicate with through knobs and switches can send out commands and receive sensory input all using just four wires (power, ground, and two for I2C communication). Then you just program this little guy for your traffic light and this little guy runs a pair of swithches, etc. etc. to your heart's content.

I actually was going to start a music biz using these little wonders but it didnt' work out so now I've got 100+ little breakout boards for the chip that would give us three holes for each pin so solder resistors and wires, etc. I'd be happy to send some out for just the cost of postage, no charge, if someone or few folks would like to tinker with them. They do require a small $20 programmer board as well and the software to program them is free though a teeny bit tricky to install as I recall.

If interested, please give a shout!

Les

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

More
8 years 9 months ago #17995 by Kelley
Replied by Kelley on topic Arduino [or other uCPU] controlled.....
I cant believe I have been gone for 2 years. But anyways, I seen online something about some new super mini computers that will be sold for 15 dollars. Anyone know what I am talking about and can they be used for our purposes ??

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

More
8 years 9 months ago #17996 by soccrdad30
Replied by soccrdad30 on topic Arduino [or other uCPU] controlled.....
Kelley,

I know there are a handful of guys that are into programming the Arduino's. To what degree, I don't know.

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

Time to create page: 0.313 seconds