Hi all. I am new to Arduino (don't have one yet) and I am not very knowledgeable in electronics, though I will have help available with that aspect of my project. (BTW, this is a hobby project; it is unlikely to become a commercial product.) I am proposing to build a custom-designed digital calendar-clock and time calculator. (Not for the Gregorian calendar - hence the need for the custom design.) It is meant to be mounted on a backboard and hung on a wall. I came across an article about the Arduino, and I thought I might be able to build a prototype of my instrument on such a board.
But I have a few doubts as to the Arduino's suitability for my purpose. If it is suitable, I would also welcome some advice as to what other components I might need. And, can anyone advise me on how the Arduino would stack up against the 8051 Development Board from PJRC that I saw at: PJRC Store
For I/O, I am proposing to use an LCD character-display module (4-line x 40 chars) and some buttons and/or a 3x4 keypad. I will also need to connect some kind of quartz-crystal time-base circuit. (I might be able to get this by cannibalizing a common, battery-driven, electronic clock movement.)
For the calculator function, this device must perform time-arithmetic in units having very large values using long and double-long integers.)
I have a software version of the calendar component running on a PC and the compiled version of the program (written in Power Basic) takes up 130KB on disk and I don't know if the software will fit onto the Arduino. So my first question is, can additional memory for program storage be added to the board, and could the program be run from there?
Would appreciate any advice on what I would have to do to interface with the timer-circuit that will keep the time, and what I would need to connect the I/O devices (LCD display and keypad).
There are many RTC (Real Time Clock) IC's you could use to get a very precise clock interfaced to aan Arduino bord in an easy way.
It is not possible to expand the 16 K program memory on the Arduino board. But you can not compare the size of a Power Basic binary file with the size of an Arduino file.
Interfacing LCD's and Keypads is relatively straight forward.
If the memory on the Arduino is to small for your project, you could look in to the Sanguino board. It works with the same software as Arduino (sligthly modified) but has 64k program memory an 4K RAM (if my memory serves me).
There is a library in the Arduino playground here Arduino Playground - DateTime that you may be able to modify for use as the basis for some of your date and time functions. It's easy to hook this up to an external clock (I use it with a re-purposed old DCF/MSF 'atomic' clock pcb).
Its surprising how much you can do even in just 16k of program memory, I wonder what kind of calculations you need to do, do you have link to more info on the kind of thing you are trying to make?
Thanks for the reply guys, and sorry for the delay in following up. Mem, in reply to your question, what I'm actually doing is programming the Jewish calendar (which is luni-solar). I don't have any example code that I can link to just yet, but I am considering releasing my code routines into the public domain. It just needs a bit of tidying up first and some general explanations to go along with it. When I have put something up, I'll post a link to it. I may indeed go with the Sanguino, just to reduce the possibility of running out of program space.
In relation to this, can anyone explain why there are three different types of memory on board the Arduino - flash memory (16K), SRAM (1K), and EEPROM (0.5K), and what the different types of memory are used for? (I gather from your reply about the Sanguino that the software for the embedded application is stored in flash memory, but it's not clear to me what the other two are for and whether any of them can be used by the program.)
Program code is stored in flash. It can only be modified when the sketch is uploaded to the arduino board.
Ram holds data used by the program, i.e. all the variables in your sketch.
EEPROM allows permanent storage of values that can be modified by the program. EEPROM values are maintained even when there is no power to the Arduino. It could hold information like dates for birthdays that you may want to send to the board over the serial link.
Looking forward to seeing the code. Don't worry if its not fully polished, this site as all about tinkering
Still feeling my way around here and plowing through the sea of documentation - I don't C so good. :-/ I have a few more quick questions. (Apologies if I'm asking stuff that is already explained somewhere -- you can just point me to the right place if you like.
MEMORY:
(From mem:) Program code is stored in flash. It can only be modified when the sketch is uploaded to the arduino board.
Ram holds data used by the program, i.e. all the variables in your sketch.
EEPROM allows permanent storage of values that can be modified by the program. EEPROM values are maintained even when there is no power to the Arduino. It could hold information like dates for birthdays that you may want to send to the board over the serial link.
Does the compiler control where stuff is stored? And if so, is it up to the programmer to explicitly tell the compiler where to store stuff, or does it decide this on its own based on the scope you assign to your variables?
IDE: If you don't have an Arduino board connected, can you test-run software in some kind of simulator? Seems to me this wouldn't be too hard to implement. It should certainly be possible for all code routines that operate independently of outside input. The output could just show up on a monitor window containing simulated pins. Outside input could be simulated by accepting input from the PC keyboard, and be echoed in the same monitor window on simulated input pins. It should even be possible to create a simulated LCD character display, but failing that, you could use print statements in the program and watch the output on the IDE's serial monitor .
LANGUAGE: All the functions I've seen so far in example code return only a single value (or nothing). What about parameters to a routine? Can they be used as pass-back parameters (i.e. are the contents passed by reference) so that the calling routine can get back multiple data items?
CIRCUIT DESIGN: My program (not yet written) will send output to a dot-matrix LCD character-display (probably a 4 x 40), and will respond to user input from 4 buttons. To save on input pins, could the button panel be wired up so that the buttons form a (conceptual) 2 x 2 grid, which is wired to just two Arduino pins, one indicating the row that went high and the other the column that went high?
SOFTWARE DESIGN: What is the best way for the program to monitor the buttons for user input? (a) Scan their state once through each iteration of the main loop, or (b) some sort of interrupt processing (Interrupts look daunting at the moment, I still have to come to grips with this.) (a) looks easier to write, but this thought bothers me: Say the program is busy doing stuff in response to a button press, and in the meantime there is another button press which is released before the program gets back to the part of the loop which scans the buttons. Is the last button-press lost because the program didn't see it in time, or is it retained by the board until the relevant pin is read?
HARDWARE: I thought I would need a RTC IC, but my electronics-expert friend had this to say about it:
I doubt that a RTC is necessary, as they were designed for computers that were too busy to do their own timing. You'll notice that all the development boards run on crystals, and are therefore highly accurate, and can be programmed to do their own timing. RTCs are expensive, and if necessary, a cheap watch would probably do the trick.
Hi Moongazer, I hope the following helps. Some of the answers are much influenced by my personal preference so I hope you get some other viewpoints and suggestions.
the compiler will only put variables in program memory ( flash) if the programmer tells it to using the progmem directive. Likewise EEPROM by using the EEPROEM library. All other variables are stored in RAM.
I have not seen a simulator for the Arduino environment although this would be a great project for someone. It is certainly possible, there are simulators that do what you describe that are used in similar environments. Here is one example although it doesn't understand the arduino specific abstractions: http://www2.tech.purdue.edu/ecet/courses/ecet309/Reference_Materials/Simulation_AVR_Studio_4.pdf
You can pass by reference by using pointers as arguments : Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos
This is one of the many arcane things you can do under the covers that is not highlighted in the Arduino documentation because the syntax and/or concepts are confusing to people new to the complexities of C and C++.
One way to do what you want with one or two pins is to use the analog inputs to determine which button is pressed by reading a voltage that is changed by resistors connected across the switches. There is a tutorial here: http://www.arduino.cc/en/Tutorial/TwoSwitchesOnePin
The appropriate technique for detecting switch presses depends heavily on the application, and the skill and personal preference of the programmer. If an application does loop many times per second then I much prefer to implement switch input by calling a routing that monitors the switch states on each pass of the loop. In all the many applications I have written for the arduino, I have never needed to use an interrupt for button input.
The arduino crystal is capable of keeping time to second or two per day. My desk clock is built using the software Arduino DateTime library in the playground and it is more accurate then the hardware RTC in my PC.
But a software clock needs to be reset if the power is lost, so if this is an issue you can get a battery backed up RTC for under $10
This may seem like a stupid question, but I just wanted to be sure about this: Is the flash memory volatile? I'm guessing it's non-volatile, because I read somewhere that the Setup() routine in your sketch is the first thing that gets executed when you connect power to the board. If flash memory is volatile, then the whole program, including the Setup() routine, will have been lost while the power was off. My intention is to use the Arduino to host a standalone, embedded application. It will be powered by battery and/or a power converter. At some stage though, you've gotta figure that the power supply to the board will be interrupted when someone turns off a switch at the wall or when the battery dies. I don't want someone to have to upload the sketch to the board again whenever that happens.
Oh, and the Australian distributor for Arduino products (littlebirdelectronics.com) seems to have gone out of business. For three weeks now, I've been trying to contact them by email, phone-message (now no longer possible) and fax -- all to no avail. It's like they just don't exist anymore (except for the website). So it looks like I'm going to have to find an overseas source to get one from. (I want the Sanguino.)
Another question:
I can't get a character LCD display module in large enough size to serve as a viable output device. (I can go smaller, which doesn't fit the design features that I want, or go for a quite expensive character display module, which then puts it in the same price bracket as the alternative idea below.)
Does anyone have any idea as to whether the following is technically feasible:
There are digital photo frames readily available locally here of the right size and shape that I would like for my text-display. Many of them are advertised as being capable of displaying text (.txt) files and some also have a USB port for connection to a PC. If I connected one of these to the USB port on the Arduino, could my sketch send text files to the photo frame via that connection?
The photo frame would have to be capable of automatically displaying a file that it receives over such a connection OR capable of responding to a software command sent with the file telling it to do so. Also, this has to work without human intervention, so it must do so without requiring someone to disconnect the USB cable in order to put the photo frame into display mode.
Assuming I can find a photo frame capable of this, is such control feasible from the Arduino's point of view via its USB port?
The flash memory is non volatile, your program will survive powercycling the arduini board. RAM of course is not, so anything stored in variables used in your program will be lost.
Using a pictureframe is probably not possible, but i depends on exactly how it works and whta is going on over the USB connecton.
Arduinos USB plug is really not a USB connection at all. It's a serial port in disguise. When you install the Arduino software you install a driver on the PC that imolements a virtual serial (COM) port on the PC, this is the port used to communicate with Arduino. So unless the pictureframe uses the same system you could probably not communicate with it from Arduino. It would be a cool thing to doo though
Why not see if you can find a discarded ancient but working laptop that has a screen the size you want. You could then write a program in something like Processing that displayed large text received over the USB port from the arduino (or run everything in Processing if you can ). Some clever frame-making could hide all but the screen so it didn't look like a laptop
It would depend on what Moongazer wanted to do. Perhaps the text is could be related to input from some sensors (for example a light sensor) that was easier to interface to the arduino than the laptop.
With the "old laptop" solution Arduino wold not be required, or have i misunderstood something ?
Exactly! And, although it would work, it would only be a solution if I was planning to never make any more of these clock-calendars. But this one based around the Arduino is supposed to be a prototype -- a kind of "proof of concept" to see if I can get it all working using components at least similar to what I would use in the future to (hopefully) make more of the same. The laptop solution wouldn't really serve that purpose. Although this is not likely to become a big scale commercial product, it does have an educational purpose (and a certain geek appeal) that would warrant producing at least a modest quantity of these. The inputs to the program would be from user button-presses (four buttons) and from regular time updates from the RTC.
Wanted a 4 x 40, dot-matrix, character-LCD, but in a large size so it would be easily visible in a large room. Had my eye on this one ... Lumex Inc. - An ITW Company, but they're not making it any more and there's no stock left anywhere. Only way to get it is to order a truckload of them from Taiwan and they'll reopen the production line. (There are similar ones about half that size on the same site. Could go with them if no other solution presents itself.)
This is an unusually large size. I have found only one other like it. It's listed at the very bottom of this page: powertipusa.com/lcdc.htm, but I found out that the one retailer who has any stock of them wants the equivalent of $242 (Australian) each and woulda cost me an addition $118 (Australian) in shipping charges. Woulda blown the budget completely outa the water.
In the end, I'll just have to go with what I can (affordably) get. (sigh.)