NORVI ARITA MEGA INDUSTRIAL APPLICATIONS #
Programming #
NORVI-ARITA-MEGA-M6 has a mini USB Port for serial connection with the SoC for programming. Any Arduino-supported programming IDE can be used to program the controller. Follow this Guide to programming NORVI Arduino-Based Controllers with Arduino IDE.
SoC: ATmega2560-16AU
Programming Port: USB UART
Digital Inputs #
Wiring Digital Inputs #
The digital inputs of NORVI-ARITA-MEGA-M6 can be configured as both a Sink and Source connection. The inverse of the Digital Input polar should be supplied to the common terminal.
Programming Digital Inputs #
Reading the relevant GPIO of ATMEGA gives the value of the Digital Input. When the inputs are in the OFF state the GPIO goes HIGH, and when the input is in the ON stage GPIO goes LOW. Refer to the GPIO allocation table in the Datasheet for the digital input GPIO.
#include <Wire.h>
#include <avr/pgmspace.h>
#define IN1 19
#define IN2 18
#define IN3 26
#define IN4 27
#define IN5 28
#define IN6 29
#define IN7 30
#define IN8 31
#define IN9 32
#define IN10 33
#define IN11 34
#define IN12 35
#define IN13 36
#define IN14 37
void setup() {
pinMode(19, OUTPUT);
pinMode(18, OUTPUT);
pinMode(26, OUTPUT);
pinMode(27, OUTPUT);
pinMode(28, OUTPUT);
pinMode(29, OUTPUT);
pinMode(30, OUTPUT);
pinMode(31, OUTPUT);
pinMode(32, OUTPUT);
pinMode(33, OUTPUT);
pinMode(34, OUTPUT);
pinMode(35, OUTPUT);
pinMode(36, OUTPUT);
pinMode(37, OUTPUT);
}
void loop() {
digitalWrite(19, LOW);
digitalWrite(18, LOW);
digitalWrite(26, LOW);
digitalWrite(27, LOW);
digitalWrite(28, LOW);
digitalWrite(29, LOW);
digitalWrite(30, LOW);
digitalWrite(31, LOW);
digitalWrite(32, LOW);
digitalWrite(33, LOW);
digitalWrite(34, LOW);
digitalWrite(35, LOW);
digitalWrite(36, LOW);
digitalWrite(37, LOW);
}
RELAY AND TRANSISTOR OUTPUTS #
Wiring Relay and Transistor Outputs #
Programming Relay/ Transistor Outputs #
Reading the relevant GPIO of ATMEGA gives the value of the Relay/ Transistor Output. Refer to the GPIO allocation table in the Datasheet for the Relay/ Transistor Output GPIO.
#include <Wire.h>
#include <avr/pgmspace.h>
#define O1 4
#define O2 5
#define O3 2
#define O4 3
#define O5 6
#define O6 7
#define O7 8
#define O8 9
#define O9 53
#define O10 10
#define O11 11
#define O12 12
void setup() {
Serial.begin(9600);
Serial3.begin(9600);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(53, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
}
void loop() {
digitalWrite(4, 0);digitalWrite(5, 0);digitalWrite(2, 0);
digitalWrite(3, 0);digitalWrite(6, 0);digitalWrite(7, 0);
digitalWrite(8, 0);digitalWrite(9, 0);digitalWrite(53, 0);
digitalWrite(10, 0);digitalWrite(11, 0);digitalWrite(12, 0);
delay(500);
digitalWrite(4, 1);digitalWrite(5, 0);digitalWrite(2, 0);
digitalWrite(3, 0);digitalWrite(6, 0);digitalWrite(7, 0);
digitalWrite(8, 0);digitalWrite(9, 0);digitalWrite(53, 0);
digitalWrite(10, 0);digitalWrite(11, 0);digitalWrite(12, 0);
delay(500);
digitalWrite(4, 1);digitalWrite(5, 1);digitalWrite(2, 0);
digitalWrite(3, 0);digitalWrite(6, 0);digitalWrite(7, 0);
digitalWrite(8, 0);digitalWrite(9, 0);digitalWrite(53, 0);
digitalWrite(10, 0);digitalWrite(11, 0);digitalWrite(12, 0);
delay(500);
digitalWrite(4, 1);digitalWrite(5, 1);digitalWrite(2, 1);
digitalWrite(3, 0);digitalWrite(6, 0);digitalWrite(7, 0);
digitalWrite(8, 0);digitalWrite(9, 0);digitalWrite(53, 0);
digitalWrite(10, 0);digitalWrite(11, 0);digitalWrite(12, 0);
delay(500);
digitalWrite(4, 1);digitalWrite(5, 1);digitalWrite(2, 1);
digitalWrite(3, 1);digitalWrite(6, 0);digitalWrite(7, 0);
digitalWrite(8, 0);digitalWrite(9, 0);digitalWrite(53, 0);
digitalWrite(10, 0);digitalWrite(11, 0);digitalWrite(12, 0);
delay(500);
digitalWrite(4, 1);digitalWrite(5, 1);digitalWrite(2, 1);
digitalWrite(3, 1);digitalWrite(6, 1);digitalWrite(7, 0);
digitalWrite(8, 0);digitalWrite(9, 0);digitalWrite(53, 0);
digitalWrite(10, 0);digitalWrite(11, 0);digitalWrite(12, 0);
delay(500);
digitalWrite(4, 1);digitalWrite(5, 1);digitalWrite(2, 1);
digitalWrite(3, 1);digitalWrite(6, 1);digitalWrite(7, 1);
digitalWrite(8, 0);digitalWrite(9, 0);digitalWrite(53, 0);
digitalWrite(10, 0);digitalWrite(11, 0);digitalWrite(12, 0);
delay(500);
digitalWrite(4, 1);digitalWrite(5, 1);digitalWrite(2, 1);
digitalWrite(3, 1);digitalWrite(6, 1);digitalWrite(7, 1);
digitalWrite(8, 1);digitalWrite(9, 0);digitalWrite(53, 0);
digitalWrite(10, 0);digitalWrite(11, 0);digitalWrite(12, 0);
delay(500);
digitalWrite(4, 1);digitalWrite(5, 1);digitalWrite(2, 1);
digitalWrite(3, 1);digitalWrite(6, 1);digitalWrite(7, 1);
digitalWrite(8, 1);digitalWrite(9, 1);digitalWrite(53, 0);
digitalWrite(10, 0);digitalWrite(11, 0);digitalWrite(12, 0);
delay(500);
digitalWrite(4, 1);digitalWrite(5, 1);digitalWrite(2, 1);
digitalWrite(3, 1);digitalWrite(6, 1);digitalWrite(7, 1);
digitalWrite(8, 1);digitalWrite(9, 1);digitalWrite(53, 1);
digitalWrite(10, 0);digitalWrite(11, 0);digitalWrite(12, 0);
delay(500);
digitalWrite(4, 1);digitalWrite(5, 1);digitalWrite(2, 1);
digitalWrite(3, 1);digitalWrite(6, 1);digitalWrite(7, 1);
digitalWrite(8, 1);digitalWrite(9, 1);digitalWrite(53, 1);
digitalWrite(10, 1);digitalWrite(11, 0);digitalWrite(12, 0);
delay(500);
digitalWrite(4, 1);digitalWrite(5, 1);digitalWrite(2, 1);
digitalWrite(3, 1);digitalWrite(6, 1);digitalWrite(7, 1);
digitalWrite(8, 1);digitalWrite(9, 1);digitalWrite(53, 1);
digitalWrite(10, 1);digitalWrite(11, 1);digitalWrite(12, 0);
delay(500);
digitalWrite(4, 1);digitalWrite(5, 1);digitalWrite(2, 1);
digitalWrite(3, 1);digitalWrite(6, 1);digitalWrite(7, 1);
digitalWrite(8, 1);digitalWrite(9, 1);digitalWrite(53, 1);
digitalWrite(10, 1);digitalWrite(11, 1);digitalWrite(12, 1);
delay(500);
}
void all_off(){
digitalWrite(4, 0);digitalWrite(5, 0);digitalWrite(2, 0);
digitalWrite(3, 0);digitalWrite(6, 0);digitalWrite(7, 0);
digitalWrite(8, 0);digitalWrite(9, 0);digitalWrite(53, 0);
digitalWrite(10, 0);digitalWrite(11, 0);digitalWrite(12, 0);
delay(500);
}
RS-485 COMMUNICATION #
RS-485 Wiring #
Driver | MAX485CSA |
TX | D14 |
RX | D15 |
Flow Control | D42 |
Programming RS-485 #
NORVI ARITA-MEGA series RS-485 connection uses a half-duplex mode of MAX485 transmitter with UART Communication.
#define RXD 14
#define TXD 15
#define FC 42
void setup() {
Serial.begin(9600);
pinMode(FC, OUTPUT);
Serial1.begin(9600, SERIAL_8N1,RXD,TXD);
}
void loop() {
digitalWrite(FC, HIGH); // Make FLOW CONTROL pin HIGH
Serial1.println("RS485 01 SUCCESS"); // Send RS485 SUCCESS serially
delay(500); // Wait for transmission of data
digitalWrite(FC, LOW); // Receiving mode ON
while (Serial1.available()) { // Check if data is available
char c = Serial1.read(); // Read data from RS485
Serial.write(c); // Print data on serial monitor
}
delay(1000);
}
Built-in OLED Display #
Display driver | SSD1306 |
Communication | I2C |
Module Address | 0x3C |
Resolution | 128 x 64 |
Refer to the GPIO allocation table in the Datasheet for the I2C GPIO of the OLED Display.
Library supported by the Adafruit_SSD0306 Library.
Wire.begin (SDA, SCL) is required to initialize I2C on the correct pins.
Programming OLED Display #
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0, 1);
display.print("ICONIC");
display.setCursor(0, 25);
display.setTextSize(1);
display.println("NORVI CONTROLLER");
display.println("K8");
display.println("12 DI|1 PWM|4 AI|7 RL");
display.println("ETHERNET | SD CARD");
display.display();
delay(5000);
display.clearDisplay();
display.setTextSize(0);
Serial.print("Initializing SD card...");
display.clearDisplay();
display.setCursor(0, 0);
display.print("Initializing SD card.");
display.display();
delay(2000);
}
void loop() {
display1();
delay(5000);
}
void display1() {
display.clearDisplay();
display.setCursor(0, 0);
display.println("Test Analog Inp");
display.println("");
display.display();
}
Built-in Buttons #
Button 1 Pin | D22 |
Button 2 Pin | D23 |
Button 3 Pin | D24 |
Button 4 Pin | D25 |
Programming Buttons #
#include <Wire.h> #include <avr/pgmspace.h>
#define b4 22 #define b3 23 #define b2 24 #define b1 25
bool but1 = 0, but2 = 0, but3 = 0, but4 = 0, blinknow = 0, valsChanged=0, changeWeb = 0;
bool b1pressed = 0, b2pressed = 0, b3pressed = 0, b4pressed = 0, configured = 0;
void readBut() {
if(digitalRead(b1)) {
while(digitalRead(b1)) but1 = 1; blinknow = 1;
}
else if(digitalRead(b2)) // right {
while(digitalRead(b2)) but2 = 1; blinknow = 1;
}
else if(digitalRead(b3)) // left {
while(digitalRead(b3)) but3 = 1; blinknow = 1;
}
else if(digitalRead(b4)) // up {
while(digitalRead(b4)) but4 = 1; blinknow = 1;
}
}
void setup()
{
pinMode(b1, INPUT);
pinMode(b2, INPUT);
pinMode(b3, INPUT);
pinMode(b4, INPUT);
Serial.begin(9600);
Serial.println("P1 ");
delay(2000);
}
void loop() {
delay(200);
}
Internal RTC #
RTC Chip | DS1307ZN+ |
Backup Battery Type | CR2450N-IB |
Interface | I2C |
I2C Address | 0x68 |
SCL Pin | D21 |
SDA Pin | D20 |
Programming RTC #
#include "RTClib.h"
RTC_DS1307 rtc;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
void setup () {
Serial.begin(9600);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running!");
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
}
void loop () {
DateTime now = rtc.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
Serial.print(" since midnight 1/1/1970 = ");
Serial.print(now.unixtime());
Serial.print("s = ");
Serial.print(now.unixtime() / 86400L);
Serial.println("d");
DateTime future (now + TimeSpan(7,12,30,6));
Serial.print(" now + 7d + 12h + 30m + 6s: ");
Serial.print(future.year(), DEC);
Serial.print('/');
Serial.print(future.month(), DEC);
Serial.print('/');
Serial.print(future.day(), DEC);
Serial.print(' ');
Serial.print(future.hour(), DEC);
Serial.print(':');
Serial.print(future.minute(), DEC);
Serial.print(':');
Serial.print(future.second(), DEC);
Serial.println();
Serial.println();
delay(3000);
}