このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。

翻訳前ページへ


Reading RTC in nuElectronics Data Logger 保護物,者 for Arduino - ar3ne1rtc HOME  »  ARDUINO MAIN PAGE »  HINTS AND HOW-TOs »  NuELEC DATALOG  t.o.c.

Reading the RTC in the nuElectronics Datalogging 保護物,者

Page's URL: Ar3Ne1Rtc.htm



This tutorial shows you how to 接近 the 保護物,者's real time clock, its DS1302. Don't be 脅すd by the "DS"... yes, this is a 半導体素子 from Dallas's 1-wire family, but you don't have to を取り引きする the usual 1-Wire programming things. You DON'T need the general Arduino "OneWire" library.

N.B. This guide is a little 天然のまま for the moment. But the code at the 底(に届く) WORKS... once you have 任命する/導入するd the "sensor_pff" library which (機の)カム from nuElectronics on your system. At 3/13, the nuElectronics 場所/位置 had been unreachable for some time. I have put a copy of the "sensor_pff" library, as a .zip とじ込み/提出する, on my 場所/位置 for you to download. I didn't look at it very closely, if you see things in it I should not be 分配するing, please let me know. (I've no 疑問 the contents are 安全な and decent... but there may be copyright 問題/発行するs?) (I've done 公式文書,認めるs on how to 追加する libraries, if you are unfamiliar with that. Don't worry, it isn't hard, (I did it!) and won't "mess up" your Arduino 開発 環境. ). If there are elements of this guide which are hard to follow, or seem wrong(!), do please 接触する the author and complain!

A 詳細(に述べる): 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 装置 to a nuElectronics "one wire" 関係 point, you won't often (ever?) get dragged into some of the more コンビナート/複合体 1-Wire 問題/発行するs. Don't get me wrong... I like 1-Wire... it is powerful. But to get everything you can from 1-Wire gets 危険に の近くに to Serious Work. The nuelectonics datalogging 保護物,者 lets you use some of the (marvelous) 1-Wire 装置s, e.g. the DS18B20 気温 sensor, without the work! (I've written a 簡潔な/要約する 公式文書,認める about the use of the 条件, if you want to read more.)

The nice people at nuElectronics have given you さまざまな libraries you can "#含む" in your code, which make reading the RTC 半導体素子 REALLY 平易な... compared to what you'd be doing if it was be 接近d 経由で 1-Wire 議定書s.

Don't worry too much about the "libraries" thing. As I について言及するd earlier, I've written a separate guide to Arduino ソフトウェア library use for you. The nuElectronics datalogging 保護物,者 doesn't need libraries in general, but some of the things you may want to use on it, or through it, do 要求する libraries, the RTC 存在 one of them.

In this "How To", we'll do a program which reads (and 陳列する,発揮するs) the date and time (and day of week) (警察などへの)密告,告訴(状) which is inside the RTC 半導体素子 in the datalogging 保護物,者. You may find that it was 始める,決める to the 訂正する date and time before it was shipped to you, but we will do a "始める,決める the clock" program in an associated "How To", just in 事例/患者.

A word about "day of week": This is (警察などへの)密告,告訴(状) from the RTC 半導体素子 to tell you if it is Monday, Tuesday, Wednesday, etc. I believe it will always be one of 1,2,3,4,5,6 and 7 (but it might be 0-6). It is "独断的な"... You can call Thursday "1", if you want to! The RTC 半導体素子 just, every midnight, 追加するs 1 to the value it returns for DOW, going 支援する to 1 after 7 (or is it 支援する to 0 after 6? One or the other. Simples, anyway.)

Have a little skim through the …を伴ってing program, put it in your Arduino, start it running, and then open your serial 監視する. You should get lines like....

6-7-2010, Day of week: 2. Time is 0:19:30
6-7-2010, Day of week: 2. Time is 0:19:31
6-7-2010, Day of week: 2. Time is 0:19:32
6-7-2010, Day of week: 2. Time is 0:19:33

... although the date or time may be wrong. But the time should go up, in real time. (And the date, if you watch long enough!)

I may be misusing the 条件, but 耐える with me?

When you 遂行する/発効させる....

ds1302.gettime(&rtc);

... you 原因(となる) a 記録,記録的な/記録する 指名するd "rtc" to be filled with data.

Once you have done that, elements built into the 記録,記録的な/記録する can be 接近d as illustrated in the デモ program, e.g. iDOW=rtc.wday fills the variable "iDOW" with something taken from he wday element of the rtc 記録,記録的な/記録する.

公式文書,認める that the 指名するs of the elements of the 記録,記録的な/記録する are 決定するd inside one of the とじ込み/提出するs you #含むd. You can't (easily) change the ".wday" part. You can 蓄える/店 the value from rtc.wday in whatever integer variable 控訴s you. You can even change the "rtc" part of the 指名する. 早期に in the program, the line....

RTC rtc;

... said "We're going to have a 記録,記録的な/記録する (fancy variable, with elements) ("記録,記録的な/記録する" may not be やめる 訂正する for C, and "elements" is used in the general sense) called "rtc". Before you read the next 宣告,判決, bring to mind that in Arduino-speak "rtc" and "RTC" are DIFFERENT things. "rtc" will be of type "RTC", which the compiler must know about, if this line is to be 収集するd. Happily, the compiler was told about data type "RTC" in one of the #含むd とじ込み/提出するs.

(Sorry... remember: This guide is in 草案 form, AND the code DOES WORK!)

We could have used a different 指名する for the 記録,記録的な/記録する, e.g., we could have had....

RTC MyRtcRecord

... in which 事例/患者, later in the program we would have said...

iYr=MyRtcRecord.year;

... to fill our variable iYr from the "year" element of the type RTC 記録,記録的な/記録する, which would have been filled with a call to....

ds1302.gettime(&MyRtcRecord);

Where is the real time clock 半導体素子?

Something you might have wondered about: How does the ソフトウェア know where to find the DS1302? How, where is it connected into the 回路・連盟s? (You can have 延長するd answers to the latter question at my guide to the signal line usage.) The ソフトウェア library we are using by having...

#含む <DS1302.h>

...at the start of our code was written ASSUMING that the RTC 半導体素子 is connected to the Arduino 経由で 数字表示式の lines 3,4 and 6. This will be the 事例/患者 if you have plugged the 保護物,者 into, say, a Diecimila... but be sure to connect it that way if you are, for instance, using a ModernDevice RBBB. There is no 平易な way to re-割り当てる the interface. The 保護物,者 will also need connecting to the RBB (or other clone) 5v and 0v lines for the RTC to work. The 保護物,者 has the 残り/休憩(する) of the things the RTC needs, as part of the 保護物,者... 含むing a 殴打/砲列 to keep 確かな 回路・連盟s alive when the Arduino is dead. You don't have to re-始める,決める the RTC each time the datalogging 保護物,者 is 力/強力にするd up. Whew.

公式文書,認める also, if you know a bit about 1-Wire 半導体素子s, that you don't need to know the DS1302 半導体素子's unique 1-Wire ID.

/*FirstRTC
vers: 6 July 2010

Simple, simple 実験(する) of 接近 to DS1302
in nuelectonics.com datalog 保護物,者*/

#含む <DS1302.h>
#含む <mmc.h>
#含む <RTC_define.h>

DS1302 ds1302;
RTC rtc;

無効の 体制/機構() {
Serial.begin(9600);
//9600 to match the data 率 存在 used by the
//serial 監視する on my system, which is 始める,決める to
//the Arduino default. (見本 code published
//by nuElectronics used a faster baud 率.)

Serial.println("Welcome to RTC reader....");
}

無効の 宙返り飛行() {

int iYr,iMth,iDay,iDOW,iHr,iMin,iSec;

ds1302.gettime(&rtc);//As usual: the 事例/患者 of letters 事柄s.

iYr=rtc.year;//Must be put into "int" type variable... byte won't do.
iMth=rtc.month;//The "rtc" part is chosen by the programmer of this code.
iDay=rtc.mday;//Day of month, e.g. Christmas's is "25"
iDOW=rtc.wday;//Day of week... 0,1,2...6. Or is it 1,2,3...7?
iHr=rtc.hour;//What comes after the "." is defined within the
iMin=rtc.min;//code 含むd with #含む, above. Not easily changed.
iSec=rtc.sec;

//Yes... what is in next 封鎖する IS done crudely. I know.
//The point is to show you where things are... not to be
//clever with printing to the serial 監視する!
Serial.print(iDay);Serial.print("-");//Print Jan 2nd, 2010 as 2-1-2010
Serial.print(iMth);Serial.print("-");
Serial.print(iYr);Serial.print(", Day of week: ");
Serial.print(iDOW);Serial.print(". Time is ");

Serial.print(iHr);Serial.print(":");//Then the time
Serial.print(iMin);Serial.print(":");
Serial.print(iSec);
Serial.println();//and start new line


延期する(1002);//Will print the time ALMOST once per second. Once
//in a while, the DISPLAY will, skip, leave out a second, i.e.
//jump, say, from 12:13:14 to 12:13:16... but the time 報告(する)/憶測d
//will always be 訂正する.

}


"Time" to go....

I hope that gave you what you (機の)カム here for? If it did, please use the "StumbleUpon" button at the 最高の,を越す of the page? Let me know if there are bits needing work. 接触する 詳細(に述べる)s below.


My tutorials about programming for the Dallas 半導体 1-Wire (tm) 半導体素子s, as used on a MicroLan (tm), have been moved to here.. Those tutorials are written for Delphi (language) programmers, but they 含む/封じ込める much (警察などへの)密告,告訴(状) that would 適用する to other language 環境s. I also 持続する pages which introduce MicroLans and explain the 金物類/武器類.


-------------------

See Also: The Arduino programming course from Sheepdog Guides:

その上の to the Arduino ideas the page you are reading now will take you to, I have 地位,任命するd a 一連の essays which try to help you become a better Arduino programmer and engineer... but, for the best result, you will have to buckle 負かす/撃墜する and work your way through them in sequence. The "How To's" here can be 接近d in whatever order you like.


Feel 解放する/自由な to use this (警察などへの)密告,告訴(状) in programming courses, etc, but a credit of the source would be 高く評価する/(相場などが)上がるd. If you 簡単に copy the pages to other web pages you will do your readers a disservice: Your copies won't stay 現在の. Far better to link to these pages, and then your readers see up-to-date 見解/翻訳/版s. For those who care- thank you- I have 地位,任命するd a page with more (警察などへの)密告,告訴(状) on what copyright 権利放棄s I 延長する, and suggestions for those who wish to put this 構成要素 on CDs, etc.






編集(者)の Philosophy

See the discussion 近づく the 底(に届く) of the "最高の,を越す level" page covering the 本体,大部分/ばら積みの of my Arduino 出資/貢献s. There is (警察などへの)密告,告訴(状) there, too, about things like "May I copy your 構成要素?", and the system of とじ込み/提出する 指名するs I am trying to work to.


   Search this 場所/位置 or the web        力/強力にするd by FreeFind
 
  場所/位置 search Web search
場所/位置 地図/計画する    What's New    Search

The search engine is not intelligent. It 単に 捜し出すs the words you 明示する. It will not do anything sensible with "What does the 'could not 収集する' error mean?" It will just return 言及/関連s to pages with "what", "does", "could", "not".... etc.
In 新規加入 to the (警察などへの)密告,告訴(状) about the nuElectronics data 保護物,者 of which this page is part, I have other 場所/位置s with 構成要素 you might find useful.....

Tutorials about the 解放する/自由な database which is part of the 解放する/自由な Open Office.
Sequenced 始める,決める of tutorials on Pascal programming and electronics interfacing.
Some pages for programmers.
Using the 平行の port of a Windows computer.

If you visit 1&1's 場所/位置 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 いっそう少なく 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 延長する my 関与. 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.



広告 from page's editor: Yes.. I do enjoy 収集するing these things for you... hope they are helpful. However.. this doesn't 支払う/賃金 my 法案s!!! If you find this stuff useful, (and you run an MS-DOS or Windows PC) please visit my freeware and shareware page, download something, and 循環させる it for me? Links on your page to this page would also be 高く評価する/(相場などが)上がるd!

Click here to visit editor's Sheepdog ソフトウェア (tm) freeware, shareware pages.


And if you liked that, or want different things, here are some more pages from the editor of these tutorials....

Click here to visit the homepage of my biggest 場所/位置.

Click here to visit the homepage of Sheepdogsoftware.co.uk. 陳謝s if the "?Frmar3ne1rtc" I 追加するd to that link 原因(となる)s your browser problems. Please let me know, if so?

Click here to visit editor's pages about using computers in Sensing and 支配(する)/統制する, e.g. 天候 logging.



To email this page's editor, Tom Boyd.... Editor's email 演説(する)/住所. Suggestions welcomed! Please 特記する/引用する the page's URL, "ar3ne1rtc.htm".

Click to check for W3.org HTML validity tester Page has been 実験(する)d for 同意/服従 with INDUSTRY (not MS-only) 基準s, using the 解放する/自由な, 公然と accessible validator at validator.w3.org. Mostly passes.

AND passes... Click to check CSS validity


One last bit of advice: Be sure you know all you need to about spyware.

. . . . . P a g e . . . E n d s . . . . .