Hallo,
würde gern den W5100 mit dem Mega zum laufen bekommen.
Das Problem ist das ich diese Pins dafür nutzen möchte:
PIN 50 = MISO
PIN 51 = MOSI
PIN 52 = SCK
finde grad nicht wo ich diese definieren kann...
Und dieses Sketch würde ich gern nutzen:
#include <SPI.h>
#include <Ethernet.h>
#include "Mudbus.h"
Mudbus Mb;
//Function codes 1(read coils), 3(read registers), 5(write coil), 6(write register)
//signed int Mb.R[0 to 125] and bool Mb.C[0 to 128] MB_N_R MB_N_C
//Port 502 (defined in Mudbus.h) MB_PORT
void setup()
{
uint8_t mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x51, 0x06 };
uint8_t ip[] = { 192, 168, 178, 70 };
uint8_t gateway[] = { 192, 168, 178, 1 };
uint8_t subnet[] = { 255, 255, 255, 0 };
Ethernet.begin(mac, ip, gateway, subnet);
//PWM Frequenz
//0×01 1 31.374 KHz
//0×02 8 3.921 Khz
//0×03 64 490.1 Hz // default
//0×04 256 122.5 Hz
//0×05 1024 30.63 Hz
//For Arduino NANO:
//http://playground.arduino.cc/Main/TimerPWMCheatsheet
//timer 0 (controls pin 13, 4)
//timer 1 (controls pin 12, 11)
//timer 2 (controls pin 10, 9)
//timer 3 (controls pin 5, 3, 2)
//timer 4 (controls pin 8, 7, 6)
TCCR1A = (TCCR1A & 0xF8) | 0x01;
TCCR0A = (TCCR0A & 0xF8) | 0x01;
TCCR0B = (TCCR0B & 0xF8) | 0x01;
TCCR2B = (TCCR2B & 0xF8) | 0x01;
pinMode(9, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(3, OUTPUT);
}
void loop()
{
Mb.Run();
//D9 Timer1A
analogWrite(9, Mb.R[3]);
//D6 Timer0A
analogWrite(6, Mb.R[2]);
//D5 Timer0B
analogWrite(5, Mb.R[1]);
//D3 Timer2B
analogWrite(3, Mb.R[0]);
}
Dieser Mega soll von Ip syscom gesteuert werden.
In dem Sketch müsste ich noch weiter Ausgänge Steuern per PWM.
Daher sind die 2-13 pins belegt...
Danach muss ich noch ein paar PIR´s einbinden.
Kriege grad aber das kleine W5100 net zum laufen.
Habt Ihr einen Tipp?
Danke euch schon mal!