First, a quick word about Arduino shields, in general:
Arduinos are wonderfully general platforms. True Arduinos, and some of the clones, have a standard set of connectors for interfacing the basic board with support circuits. Enterprising entrepreneurs and hyperactive hobbyists produce populated printed circuit boards which just "plug into" some or all of the 26 connection points. These boards are called "shields". They typically use some of the signals from the Arduino to drive useful components on the shield, and pass some or all of the signals on, either through "daisy-chain-able" connectors, or others. The shields often create something with extra capabilities, at the price of constraining some of the "generality" of the underlying Arduino.
The nuelectronics datalogging shield is typical of what I've just said. Shortly we will turn to the specifics of that board. Just before we do so, though, I would draw your attention to the "Shields" page of the Arduino playground where many, many shields are described.
Even if you are only at the "flash some LEDs" stage of mastering the Arduino, and you aren't doing anything "clever", you can use the following digital lines of the Arduino, without any concerns beyond the normal concerns, if you have one of the datalogging shields from nuelectronics plugged in...
The Analog lines, ADC 0-5.
Now... forgive me if you knew this... but ADC 0-5 are not just for analog inputs. They can be used to send out a PWM signal. They can also.... though not concurrently!... be used as digital lines. Just "talk to" Digital line 14, and whatever you say to it will "come out" on the pin you thought was Analog 0!
I'm pretty sure that Digital line 13 is also available, but best used for output only, as the main board has an LED (and current limiting resistor on it if your main board is typical.
You can plug things into ADC 0-5 (aka Digital 14-19) via the three and four pin connectors arranged "horizontally" around the shield, the connectors called P1, P2, P4-P9 in the nuelectronics documents, as shown on my "Naming of Parts" page in this collection of tutorials. (There doesn't appear to be a P3, by the way.)
Those signals are also available to you via the rows of vertical sockets along the sides of the shield, above the rows of vertical sockets along the sides of the Arduino... the sockets the shield plugs into.
Now don't get all excited! You can't plug one thing into, say, P4 and another into the socket for D14. You would just, ultimately, be making two connections to the same place! But in one project it may suit you to use P4, and in another you may prefer to use the vertical socket on the edge of the board.
Beware: The signals brought to P6-P9 are also brought to P1 and P2. The details are at my "Naming of Parts" page.
Also available: Digital line 2, Digital lines 7-10.
This section repeats what is implied by the previous section, but details are now provided, perhaps of interest some readers.
All of the 26 lines that pass to the shield from the Arduino pass onward to the rows of vertical sockets around the edge of the shield. Well... they would be, wouldn't they? But I'm telling you: they are. In case you weren't sure.
A detail... forgive me for looking "stupid", but I haven't got around to the "joys" of the ICSP pins yet. On the standard Arduino, and on the shield, there is a block of 6 pins (two rows of three) marked "ICSP". There is no direct connection from the Arduino to the shield to interconnect those pins, but, for all I know, they tap into signals which have names discussed elsewhere in this document. At the moment, I never connect anything to the ICSP block. I'll have to learn about those pins one day... but I'm not doing it today!
One more detail (for now): You will see "one wire" and "one wire interface" in the nuelectronics documentation. This is not always connected with "1-Wire" (a Dallas trademark) at all, and even when you are connecting a 1-Wire device to a nuelectronics "one wire" connection point, you won't often (ever?) get dragged into some of the more complex 1-Wire issues. If you want to know more, I've done another page about this source of possible confusion.
I won't promise that the following is comprehensive, but I think it is a pretty good attempt!
The "0:" at the start of the next paragraph tells you that I am talking about the two lines the Arduino calls "digital 0 and digital 1".
0 and 1: These lines are used by the Arduino for the serial link to the development platform. As such, in addition to providing the channel across which the Arduino's programs ("sketches") are uploaded, they are also the lines over which the serial monitor is implemented, i.e. the way you Serial.print("Hello World"); works. So I will leave them alone until I am really pressed to find an additional line to use!
2:As far as I know, this line is unused by the shield, and merely pass though in the vertical connectors at the edge of the board.
3, 4 and 6:These lines go to the real time clock (RTC) chip. I'd be inclined to leave them alone unless you really know what you are doing! D4 is not shared by the SPI and RTC circuits... don't be fooled by the Atmega pin names and the Arduino I/O line names.
5:This line goes to the circuits for the SD card, labeled "SD CS LV", it is the SD card chip select signal. I'd be inclined to leave it alone unless you really know what you are doing!
7-10:As far as I can see, these are unused by the shield, and merely pass though in the vertical connectors at the edge of the board.
11:This line goes to the circuits for the SD card; it is the SD card MOSI signal. I'd be inclined to leave it alone unless you really know what you are doing!
12:This line goes to the circuits for the SD card; it is the SD card MISO signal. I'd be inclined to leave it alone unless you really know what you are doing!
13:On a normal Arduino, this will be connected to an LED (and suitable current limiting resistor) on the main (Arduino) PCB. If you want to use the line as an output, you won't normally encounter difficulties. You can "wink" that main board LED to suit your needs or wants. But! It is also the SD card circuit's SCK, so I'd be inclined to leave it alone unless you really know what you are doing!
"Digital lines" 14-19: As previously mentioned, as is the general (Arduino) rule, these lines "co-exist" in the form of the "Analog lines" 0-5. See the general "how to use Arduino" information elsewhere on the web for all the details of that double identity. (As is also generally true, these lines can be used to output PWM signals, too. Again... see general references.) These six signals are also taken to the connectors P1, P2, P3-P6 at the board's edge. Wait a minute... 6 signals, 8 connectors, two of them carrying two signals?? Some of the signals go, in parallel, to more than one connector. See my page "Naming of Parts".
That covers the "main", "data" lines passed through the 26 connectors between Arduino and shield. Having come so far, we might as well polish of the remaining 5 interconnects:
Reset: If this line is brought low, the Arduino resets. There's a button on the shield which will bring the line low if you press it.
Ground/ Zero volts: Not a very exciting line, but essential to all your work.
5v: This taps into whatever is supplying the 5v to the Arduino's circuits. Beginner's beware: There are limits to how much you can ask this line to do. Run a few LEDs? No problem. Power a water fountain's pump? No. While we're on the subject of "power"... a) so that you can make Arduino design progress, learn the precise meaning of that, as used by electrical engineers, and b) know that there are limits to the power the pins from the Arduino can deliver.
"3v": This is fed 3.3v from an LD1117 regulator on the shield. Don't ask this to deliver much power.
Vin: This, as far as I know, is just a pass-through from the Arduino. I'm not aware of any connection between this and the circuits or connectors on the shield.
I hope you see the above as fairly comprehensive; I hope it answers questions you may have had.
I'll now turn to some questions you may not have thought to ask.
The chip at the heart of Arduinos is a beauty. It can do no end of clever things. Did you know there's a temperature sensor built into it, for instance? (No, it is not really very useful for getting more than an indirect and confused idea of the temperature of the environment around the chip. It is more for checking that the operating conditions the chip finds itself in are not leading to overheating.)
I have to confess that I am a long way from being expert in some of the advanced topics I am going to touch on... but I know enough to know that I know enough to be dangerous. I want to try to get you that far as well.
As long as you never use a library, and never use interrupts, you are safe. And you can do a great deal within those limitations. But I do mean as long as you don't use any library, including ones cited in pages related to this one.
That's not to say "never use a library".... but when you do, beware.
The chip at the heart of your Arduino, I'll call it "your processor" from now on, is blessed with some timers and it is capable of responding to interrupts. If you are unfamiliar with either term in an electrical engineering context, don't assume too much... electronics engineers have meanings for those words which may seem strange to people outside their fraternity. (Oh dear. Am I allowed to say that? There are lady engineers, after all. Their "club"?) "Real time clock" is a similar term. How many people would consider that "clock" implies a calendar". When is time not "real"? And then there's the "system clock", which knows nothing of the time of day. ENOUGH!!!
Not only does your processor have timers and interrupts, but both of them can be configured. Whenever your Arduino is reset, the behavior of the timers and interrupts goes back to a default state. But their behavior may not stay like that for long. This is where the libraries come in. Take, for example, the library which makes it easy to read signals from an infra-red remote control, which I recommend in my tutorial about using the TSOP1838 IR control signal sensor. What you do to read such a sensor on the Arduino's pin 14 is...
#include <IRremote.h> IRrecv irrecv(14); decode_results results; void setup() { Serial.begin(9600); irrecv.enableIRIn(); } void loop() { if (irrecv.decode(&results)) { Serial.println(results.value, HEX); irrecv.resume(); } }
Looks harmless enough! But the endeviling detail is the line irrecv.enableIRIn();
That line certainly takes you off into the interior of the IRremote library. It therefore may be altering the way your processor's timers are set up. It may be altering what interrupts your processor is paying attention to, and what it does when interrupted.
Don't Panic (Mr. Mannering)... these "maybes" are not necessarily going to make any difference to you. But, what if, say, you want your system to issue a certain PWM signal on line 15 if a certain signal is seen via the TSOP1838... and the IRremote software has done something to a timer or interrupt normally dedicated to generating PWM signals? Will something like this happen to thwart something you want to do? I hope not. I even suspect not. But you need to be aware of the possibility.
Please, please: Don't let those warning put you off either the Arduino or the datalogging shield. The possibilities are manageable, and you can do a lot before even entering the land of those possibilities. Just be aware that as you venture further from the world of the beginner there are more things to master if you want to be sure that everything (well, as many things as you can cover) is under control.
Your Arduino can write data to an SD card inserted into the datalogging shield. This much we know! I'm pretty sure we can also read data from the shield. Look at the web-page for the Petit FAT File System Module, and I'm pretty sure that only slight revisions are needed to what I presented in my tutorial about writing to the SD card in order to read from it.
The SD card circuits implement a Serial Peripheral Interface, aka "SPI". ("Interface" in this instance includes hardware and software considerations.) The Arduino data lines being used for the SPI (four lines) are set out in the earlier parts of this page.
There's a document about the SPI from the main Arduino site which may or may not interest determined investigators. That document speaks of MISO, MOSI and (only) two more signals. (The other two have names that are probably equivalent to the SC and SCK signals in the nuelectronics documentation.)
There's a lovely line in the psalms: "These things are too high for me". If digging into the code in a library is not "too high" for you, you could probably answer questions about the details of the SPI by looking into the sensor_pff library. Only that, and the avr/pgmspace, libraries are needed to get the nuelectronics shield to write to an SD card... but... there's a trick in my "only that". "That" (the sensor_pff library) will probably itself call libraries to implement the Petit FAT File System Module. But I think that you won't have to dig that deep. I think that the claiming of necessary lines will be done in the "top layers" of sensor_pff.
And now for a bit of Good News to finish off with: The nuelectronics shield does not need libraries to work with most of the sensors offered by nuelectronics- not even the DS18B20 temperature sensor. It does need to use a library to access the RTC and, of course, the SD card. But even in the case of the SD card there is good(?) news: You don't need the Arduino SPI libraries in addition to the sensor_pff library.... although I suspect that parts of them, or equivalent code, is buried in or called by the sensor_pff library. I put the question mark after "good" because in some ways, I prefer to work with "standard" libraries... but there are times when a "special" library is just fine, and I suspect that this is one of them!
If you need to ask, you don't need to know... I hope. But for my fellow obsessives, here is what I know about the 6 pin header labeled "ICSP". Note that this info is not verified by my own experiments.
I believe that the main reason this header is provided on the main Arduino boards, and on the shield is to give anyone who wants it an alternate, more direct way to program the Atmega at the heart of the Arduino.
In nuelectronic's excellent circuit diagram of the datalogging shield, downloadable from their site, the pins are said to carry the following signals. This agrees with a discussion of programming via the ICSP header on the Arduino.
Note: The pins are numbered thus, in both diagrams:
1 2 3 4 5 6
Signals on pins:
Note that on the datalogging shield, these same signals are involved with the SD card read/write provision. Some (all?) of them passing through 5v to 3.3v lefel conversions along the way. My guess? If you are using a 5v Arduino, then these signals, at the ICSP header are still at 5v. As I said: use of the ICSP is a thing "too high for me" at the moment... and I've never connected anything to those pins, for fear of disturbing things I'm doing elsewhere.
And so, as so often, there I will rather abruptly leave you. Please send some feedback, or at least click the "StumbleUpon" button at the top of the page?
-------------------
Further to the Arduino ideas the page you are reading now will take you to, I have posted a series of essays which try to help you become a better Arduino programmer and engineer... but, for the best result, you will have to buckle down and work your way through them in sequence. The "How To's" here can be accessed in whatever order you like.
Feel free to use this information in programming courses, etc, but a credit of the source would be appreciated. If you simply copy the pages to other web pages you will do your readers a disservice: Your copies won't stay current. Far better to link to these pages, and then your readers see up-to-date versions. For those who care- thank you- I have posted a page with more information on what copyright waivers I extend, and suggestions for those who wish to put this material on CDs, etc.
See the discussion near the bottom of the "top level" page covering the bulk of my Arduino contributions. There is information there, too, about things like "May I copy your material?", and the system of file names I am trying to work to.
If you visit 1&1's site from here, it helps me. They host my website, and I wouldn't put this link up for them if I wasn't happy with their service... although I was less than pleased the other day to have what I was doing interrupted by a telephone call from their sales team, trying to get me to extend my involvement. Sigh. Hardly a rare event, but I'd thought 1&1 were a bit classier that some of the people who have my telephone number.
Click here to visit editor's Sheepdog Software (tm) freeware, shareware pages.
Click here to visit the homepage of my biggest site.
Click here to visit the homepage of Sheepdogsoftware.co.uk. Apologies if the "?Frmar3ne1uses" I added to that link causes your browser problems. Please let me know, if so?
Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org
....... P a g e . . . E n d s .....