Sample Listing Program DS1307 Using BASCOM AVR. Read on Scribd mobile. Bascom Avr Programming. ATmega32(L) Summary (file size: 536295, 21 pages, revision Q, updated: 02/2011) ATmega32(L) Complete (file size: 5968932, 346 pages, revision Q, updated: 02/2011). DS1307; LCD-Treiber PCF8577, 2x32 Segmente; Temperatursensoren. Available Formats. Download as TXT, PDF, TXT or read online from Scribd. Flag for inappropriate content. Save Save Sample Listing Program DS1307 Using BASCOM AVR For Later. 0% found this document useful (0 votes) 1K views 5 pages. DS1307 with bascom-avr. Have someone been working with DS1307 in bascom-avr or have some links to such stuff. The DS1307 in this example is connected directly to two of the I/O ports on a DS5000 microcontroller and the 2-wire handshaking is handled by low-level drivers, which are discussed in this application note. DS1307 Description The DS1307 Serial Real Time Clock is a low-power, full BCD clock/calendar plus 56 bytes of nonvolatile SRAM. Tutorial Jam Digital dengan RTC DS1307 Menggunakan Bascom AVR. DS1307 merupakan IC Real Time Clock (RTC) yang dapat diakses dengan mikrokontroler menggunakan komunikasi serial I2C. Berikut ini saya beri contoh untuk menampilkan RTC DS1307 pada LCD dan Hyperterminal menggunakan Bascom AVR. Dengan adanya RTC ini maka kita dapat menampilkan.
We keep getting requests on how to use DS1307 and DS3231 real-time clock modules with Arduino from various sources – so this is the first of a two part tutorial on how to use them. For this Arduino tutorial we have two real-time clock modules to use, one based on the Maxim DS1307:
and another based on the DS3231:
There are two main differences between the ICs on the real-time clock modules, which is the accuracy of the time-keeping. The DS1307 used in the first module works very well, however the external temperature can affect the frequency of the oscillator circuit which drives the DS1307’s internal counter.
Ds1307 Bascom Programming
This may sound like a problem, however will usually result with the clock being off by around five or so minutes per month. How to turn microphone on macbook pro. The DS3231 is much more accurate, as it has an internal oscillator which isn’t affected by external factors – and thus is accurate down to a few minutes per year at the most. If you have a DS1307 module- don’t feel bad, it’s still a great value board and will serve you well.
With both of the modules, a backup battery is not installed when you receive them – it’s a good idea to buy a new CR2032 battery and fit it to the module.
Along with keeping track of the time and date, these modules also have a small EEPROM, an alarm function (DS3231 only) and the ability to generate a square-wave of various frequencies – all of which will be the subject of a second tutorial.
Connecting your module to an Arduino
Both modules use the I2C bus, which makes connection very easy. If you’re not sure about the I2C bus and Arduino, check out the I2C tutorials (chapters 20 and 21), or review chapter seventeen of the book “Arduino Workshop“.
Ds1307 Bascom Programmer
Moving on – first you will need to identify which pins on your Arduino or compatible boards are used for the I2C bus – these will be knows as SDA (or data) and SCL (or clock).
- On Arduino Uno or compatible boards, these pins are A4 and A5 for data and clock;
- On the Arduino Mega the pins are D20 and D21 for data and clock;
- And if you’re using a Pro Mini-compatible the pins are A4 and A5 for data and clock, which are parallel to the main pins.
DS1307 module
If you have the DS1307 module you will need to solder the wires to the board, or solder on some inline header pins so you can use jumper wires. Then connect the SCL and SDA pins to your Arduino, and the Vcc pin to the 5V pin and GND to GND.
DS3231 module
Connecting this module is easy as header pins are installed on the board at the factory. You can simply run jumper wires again from SCL and SDA to the Arduino and again from the module’s Vcc and GND pins to your board’s 5V or 3.3.V and GND. However these are duplicated on the other side for soldering your own wires.
Both of these modules have the required pull-up resistors, so you don’t need to add your own. Like all devices connected to the I2C bus, try and keep the length of the SDA and SCL wires to a minimum.
Reading and writing the time from your RTC Module
Once you have wired up your RTC module. enter and upload the following sketch. Although the notes and functions in the sketch refer only to the DS3231, the code also works with the DS1307.
There may be a lot of code, however it breaks down well into manageable parts.
It first includes the Wire library, which is used for I2C bus communication, followed by defining the bus address for the RTC as 0x68. Free lightroom for macbook. These are followed by two functions that convert decimal numbers to BCD (binary-coded decimal) and vice versa. These are necessary as the RTC ICs work in BCD not decimal.
The function setDS3231time() is used to set the clock. Using it is very easy, simple insert the values from year down to second, and the RTC will start from that time. For example if you want to set the following date and time – Wednesday November 26, 2014 and 9:42 pm and 30 seconds – you would use:
Note that the time is set using 24-hour time, and the fourth paramter is the “day of week”. This falls between 1 and 7 which is Sunday to Saturday respectively. These parameters are byte values if you are subsituting your own variables.
Once you have run the function once it’s wise to prefix it with // and upload your code again, so it will not reset the time once the power has been cycled or micrcontroller reset.
Reading the time form your RTC Is just as simple, in fact the process can be followed neatly inside the function displayTime(). You will need to define seven byte variables to store the data from the RTC, and these are then inserted in the function readDS3231time().
For example if your variables are:
… you would refresh them with the current data from the RTC by using:
Ds1307 Bascom Programme
Then you can use the variables as you see fit, from sending the time and date to the serial monitor as the example sketch does – to converting the data into a suitable form for all sorts of output devices.
Just to check everything is working, enter the appropriate time and date into the demonstration sketch, upload it, comment out the setDS3231time() function and upload it again. Then open the serial monitor, and you should be provided with a running display of the current time and date.
From this point you now have the software tools to set data to and retrieve it from your real-time clock module, and we hope you have an understanding of how to use these inexpensive modules.
You can learn more about the particular real-time clock ICs from the manufacturer’s website – DS1307 and DS3231.
This post brought to you by pmdway.com everything for makers and electronics enthusiasts, with free delivery worldwide.
To keep up to date with new posts at tronixstuff.com, please subscribe to the mailing list in the box on the right, or follow us on twitter @tronixstuff. Make crack with baking soda.