I'm considering a mega for controlling a model railroad and have a couple of questions. Am I correct in that Arduino's memory is volatile and a sketch must be uploaded each time it is powered up? Also, can sketches be uploaded and interfaced by user PC applications without invoking the Arduino IDE? It would be useful to simply click on an icon and have the whole thing ready to go. Any links or references appreciated... ![]()
Am I correct in that Arduino's memory is volatile
EEPROM and Flash are not. SRAM is.
and a sketch must be uploaded each time it is powered up?
No.
Also, can sketches be uploaded and interfaced by user PC applications without invoking the Arduino IDE?
Interfaced is a meaningless word. Try something else.
You could compile, link, and upload a sketch without using the IDE, but why would you? So much simpler to just click the icon.
It would be useful to simply click on an icon and have the whole thing ready to go.
Would that be the "Write my code for me" icon? Yes, I can see where that would be handy.
The idea would be to code, link, test etc. a sketch using the IDE - Once working properly it would be either stored in the Arduino or in the PC, and invoked with the application running on the PC/laptop.
The Arduino would collect train locations and turnout positions data and convey it to the PC/laptop where it would be displayed and processed. In a later version, the PC would operate the trains on a timetable via relays and other devices connected to the Arduino.
stored in the Arduino
That's the usual way.
and invoked with the application running on the PC/laptop.
Another big fancy term that means nothing. What, exactly, are you planning to "invoke"? Why develop another application that does what the IDE does?
A lot of people have used one of my screw shield kits with a Mega to provide an easy way to attach wires:
http://www.crossroadsfencing.com/BobuinoRev17/
I have a couple of these left, then will shipping the 2nd card that has additional power & gnd terminals.
PaulS:
stored in the Arduino
That's the usual way.
So you're saying Arduino's sketch memory is non-volatile - and will retain the program while off? This is my main question...
and invoked with the application running on the PC/laptop.
Another big fancy term that means nothing. What, exactly, are you planning to "invoke"? Why develop another application that does what the IDE does?
Invoke usually means "load and execute" in a programming environment. From what I see the IDE only furnishes a small window for data from the Arduino. The PC/laptop app I'm developing displays the layout diagram and status of various blocks, along with some textual data. To do so, the PC must interface - oops, sorry - communicate with the Arduino to ascertain the physical status of block sensors. The sketch to do so, must therefore be invoked (loaded from somewhere) if it is not already in Arduino's memory.
The sketch is downloaded into Flash memory and runs after every Reset - typically from a reset button, or a power on reset. Read & output status's etc to the PC, or responding to PC queries with status.
You can easily write an Arduino program that allows the Arduino to communicate with a program written on a PC. So you could have a GUI on the PC with buttons to select signals or trains and the program could send data to the Arduino which the Arduino would interpret and operate the appropriate device. Equally the Arduino can collect data (e.g. train position) and send that back to the PC.
This demo shows a simple example of communication with a PC written in Python - but you could use any PC language you like.
I have a small model railway control system on my PC written as a web-server so the GUI appears in Firefox and can also appear on the browser on my smart phone.
The N-Gauge locos have 2.4GHz wireless transceivers in them that are also Arduino devices and the locos are powered by a small LiPo cell. They can send the battery voltage back to the PC.
...R
Thanks all - that helps me understand the device better.
It makes sense that it retains the programming - it would be a hassle to have to "boot it up" every time.
If anyone is interested, the model RR is on you tube here Kweek & Dirtee Railroad - Part 1 - YouTube
It's the old style layout with 11 blocks and runs plain DC trains. The Arduino would monitor occupancy of each block, set signals, and relay the info to the PC for display on a track diagram. That's phase 1...
It's the old style layout with 11 blocks and runs plain DC trains. The Arduino would monitor occupancy of each block, set signals, and relay the info to the PC for display on a track diagram. That's phase 1...
This may be the first case that I've actually seen where Firmata on the Arduino makes sense. Then, the PC can invoke functions, like digitalRead(), digitalWrite(), etc. directly on the Arduino, with the need to develop a different protocol. It doesn't really seem like the Arduino is making any decisions on its own, so lobotomizing it is OK.
It would take some trial and error to decide how much functionality to put into the Arduino - My initial thought was to relegate only low level functions to it like debouncing sensors, registering block conditions and responding to polls for the data. But given the processing power, it might be advantageous to include ATC functions (Automatic train control - hold a train while the next block is occupied) and doing the signal logic (R-Y-G signals indicating occupancy, turnout position, polarity/direction,...). This would allow running the trains with ATC, but without the PC attached.
Higher level functions like scheduling trains, routing and producing sounds are probably best left to the PC.
UncleWillie:
Higher level functions like scheduling trains, routing and producing sounds are probably best left to the PC.
I would do it like that.
If you need some sort of screen and menu system to use the Arduino without a PC attached the programming becomes a whole lot more complicated.
...R

