Difference between revisions of "Initializing the Microcontroller"

From media_wiki
Jump to: navigation, search
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
  
 
Tools needed for programming the Power-Failure-Logger:
 
Tools needed for programming the Power-Failure-Logger:
'''USBTiny''' or '''USBasp''' Programmer (refer to '''AVRDude Class''' for more information on Programmers)
+
  '''USBTiny''' or '''USBasp''' Programmer (refer to '''AVRDude Class''' for more information on Programmers)
 
   Any '''RS232 to USB''' interface. I used the Silicon Labs Prolific CP210x USB to UART Bridge.  
 
   Any '''RS232 to USB''' interface. I used the Silicon Labs Prolific CP210x USB to UART Bridge.  
 
   Digital volt meter   
 
   Digital volt meter   
 
  
 
'''Setting up the ATMega328 chip'''
 
'''Setting up the ATMega328 chip'''
 
 
 
   Unplug any USB Power before programming the Microcontroller.  
 
   Unplug any USB Power before programming the Microcontroller.  
 
   Plug the '''USBTiny''' Programmer into the '''AVR-ISP 6 pin header''' '''J7'''.
 
   Plug the '''USBTiny''' Programmer into the '''AVR-ISP 6 pin header''' '''J7'''.
   Place the jumper across '''J8''' to use the USBTiny 5 volt power. Make sure no other power source is connected!   
+
   Place the '''Jumper''' across '''J8''' on the Power-Failure-Logger PCB to use the '''USBTiny''' 5 volt power. Make sure no other power source is connected!   
   Using AVRDUDE Validate the USBTiny is communicating with the Power Fail Module Microcontroller
+
   Using '''AVRDUDE''' Validate the '''USBTiny''' is communicating with the Power Fail Module PCB.
    
+
   Type the following command in the Windows terminal.
   '''avrdude -c usbtiny -p m328p -v'''
+
   '''avrdude -c usbtiny -p m328p '''<BR>
    
+
   Connected and Working properly should match this picture. 
   Trouble shooting any connection issues to the microcontroller refer back to the '''AVRDude Class'''. The link is below.   
+
  [[File:AVRDude-Read.PNG |550px]] <BR>
 
+
   Trouble shooting any connection issues to the microcontroller refer back to the '''AVRDude Class'''. The link is below.
 +
  If you get the following error message in AVRDUDE see trouble shooting.
 +
  '''avrdude: initialization failed, rc=-1'''
 +
'''Trouble shooting'''
 +
USBTiny does not connect with the ATmega Chip. Check the following:
 +
Is a '''Jumper''' connected across '''J8'''.   
 +
'''ATMega328''' chip is plug in correctly into the socket.
 +
'''USBTiny''' is powered on.
 +
'''USBTiny''' is visible in '''Device Manager''' under '''LibUSB-Win32 Devices'''
 +
'''Setting the Microcontroller to 16MHz'''
 
   The Microcontroller is set to '''1HMz''' and needs to be changed to '''16 MHz Default'''
 
   The Microcontroller is set to '''1HMz''' and needs to be changed to '''16 MHz Default'''
   Using AVRDude enter the follow command to set the fuse bits on the Microcontroller.
+
   Enter the following AVRDude command to set the fuse bits on the Microcontroller.
 
 
 
 
 
   '''avrdude -p m328p -c usbtiny -v -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFF:m'''   
 
   '''avrdude -p m328p -c usbtiny -v -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFF:m'''   
 
    
 
    
   When completed make sure the microcontroller matches these settings:
+
   Validate the fuses are now set correctly by using the following '''AVRDUDE''' command:
+
  '''avrdude -c usbtiny -p m328p -v '''<BR>
 +
  Make sure the microcontroller matches these settings:
 
   '''avrdude: safemode: hfuse reads as DE'''
 
   '''avrdude: safemode: hfuse reads as DE'''
 
   '''avrdude: safemode: efuse reads as FF'''
 
   '''avrdude: safemode: efuse reads as FF'''
Line 33: Line 39:
 
   For more information about using AVRDude refer back to this link  
 
   For more information about using AVRDude refer back to this link  
 
   ==[[ AVRDUDE Class]]==
 
   ==[[ AVRDUDE Class]]==
 +
 +
'''ADD SD Card Reader'''<br>
 +
Insert '''SD Card Reader''' module into the '''Power Logger PCB''' at '''J6'''. <br>
 +
Make sure the '''Arduino IDE''' has the following libraries installed before programming the board:
 +
#include <SPI.h>              // SPI Interface that the SD card module will use.
 +
#include <SD.h>              // Library for the SD card.
  
Next step '''Setting up the DS3231 RTC'''
+
[[File:SD-Card-Power-Fail.PNG |350px]]
  
==[[Setting Time and Date for the DS3231 RTC]]==
+
'''Next step:''' Setting Time and Date for the DS3231 RTC. Click on link below
  
 +
==[[ Power Fail Logger by Microrusty ]]==
 +
==[[Initializing the Microcontroller]]==
 +
==[[Setting Time and Date for the DS3231 RTC]]==
 +
==[[ Programming Power Fail Logger with Arduino IDE]]==
 +
==[[Installation and use]]==
 
----
 
----
==[[ Power Fail Logger by Microrusty ]]==
+
==[[ Main Page ]]==

Latest revision as of 21:45, 17 August 2021

Tools needed for programming the Power-Failure-Logger:

 USBTiny or USBasp Programmer (refer to AVRDude Class for more information on Programmers)
 Any RS232 to USB interface. I used the Silicon Labs Prolific CP210x USB to UART Bridge. 
 Digital volt meter  

Setting up the ATMega328 chip

 Unplug any USB Power before programming the Microcontroller. 
 Plug the USBTiny Programmer into the AVR-ISP 6 pin header J7.
 Place the Jumper across J8 on the Power-Failure-Logger PCB to use the USBTiny 5 volt power. Make sure no other power source is connected!  
 Using AVRDUDE Validate the USBTiny is communicating with the Power Fail Module PCB.
 Type the following command in the Windows terminal.
 avrdude -c usbtiny -p m328p 
Connected and Working properly should match this picture. AVRDude-Read.PNG
Trouble shooting any connection issues to the microcontroller refer back to the AVRDude Class. The link is below. If you get the following error message in AVRDUDE see trouble shooting. avrdude: initialization failed, rc=-1

Trouble shooting

USBTiny does not connect with the ATmega Chip. Check the following:
Is a Jumper connected across J8.  
ATMega328 chip is plug in correctly into the socket.
USBTiny is powered on.
USBTiny is visible in Device Manager under LibUSB-Win32 Devices

Setting the Microcontroller to 16MHz

 The Microcontroller is set to 1HMz and needs to be changed to 16 MHz Default
 Enter the following AVRDude command to set the fuse bits on the Microcontroller.
 avrdude -p m328p -c usbtiny -v -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFF:m  
 
 Validate the fuses are now set correctly by using the following AVRDUDE command: 
 avrdude -c usbtiny -p m328p -v 
Make sure the microcontroller matches these settings: avrdude: safemode: hfuse reads as DE avrdude: safemode: efuse reads as FF avrdude: safemode: Fuses OK (E:FF, H:DE, L:FF) avrdude done. Thank you. For more information about using AVRDude refer back to this link ==AVRDUDE Class==

ADD SD Card Reader
Insert SD Card Reader module into the Power Logger PCB at J6.
Make sure the Arduino IDE has the following libraries installed before programming the board:

#include <SPI.h>              // SPI Interface that the SD card module will use.
#include <SD.h>               // Library for the SD card.

SD-Card-Power-Fail.PNG

Next step: Setting Time and Date for the DS3231 RTC. Click on link below

Power Fail Logger by Microrusty

Initializing the Microcontroller

Setting Time and Date for the DS3231 RTC

Programming Power Fail Logger with Arduino IDE

Installation and use


Main Page