Sea Vessel Switch Board

Sea Vessel Switch Board © Apache-2.0

An instrument board to control six relays on a sea vessel.

  • 328 views
  • 0 comments
  • 0 respects

Components and supplies

Apps and online services

About this project

On a ship built in 1980 we were about to bring the whole electric to today's standard. There was a switch board with old mechanical switches that did not look very good.

So we decided to build a new one, that could do:

  • Switch the Anchor Light
  • Switch the Position (Running) Lights
  • Make sure that either the Achor or the Position Light are switched on, not both
  • Switch the Bilge Pump
  • Switch the Fresh Water Pump
  • Switch both Windshield Wipers independently or start both

For this we use six relays, six push buttons with embedded LED and have all that controlled by an Arduino Nano V3.

Code

Sketch to control 6 relaysArduino
The project uses to OneButton Library.
The code makes sure that anchor and running light can never be both switched on. Either you're anchored or you're sailing. Both at a time is impossible...:-)
The will be an update to the code to stop the wipers only at an end position using current measuring.
/*
 Name:		FS_Panel.ino

 Panel with 6 Buttons with LEDs to control lights, pumps and wipers.
 Internal pullup reistors are used so we have to connect the buttons to a sink.

 Created:	03.07.2019 08:23:01
 Author:	Joerg Pauly
*/

// Get the OneButton Library and all the other stuff working
#include <EEPROM.h>
#include <OneButton.h>

// As the relays close on LOW we need inverted triggers: switching a relay to ON means pull it's pin to GND
#define ON LOW
#define OFF HIGH

// define the Button's pins
int pinAnchor = A0;
int pinRunning = A1;
int pinBilge = A2;
int pinWater = A3;
int pinWiperL = A4;
int pinWiperR = A5;

// define pins for LEDs and relais
int relAnchor = 12;		// D12
int relRunning = 11;	// D11
int relBilge = 9;		// D9
int relWater = 8;		// D8
int relWiperL = 7;		// D7
int relWiperR = 6;		// D6

// define pins for feedback from the wipers
int febWiperL = A6;
int febWiperR = A7;

// define BOOLs to state if a wiper is to be switched off
bool flWiperL;
bool flWiperR;

// Create Button Objects 
OneButton btnAnchor(pinAnchor, true);
OneButton btnRunning(pinRunning, true);
OneButton btnBilge(pinBilge, true);
OneButton btnWater(pinWater, true);
OneButton btnWiperL(pinWiperL, true);
OneButton btnWiperR(pinWiperR, true);

// Prepare the pins an attach the Buttons
void setup() 
{
	// Make the buttons INPUT
	pinMode(pinAnchor, INPUT_PULLUP);
	pinMode(pinRunning, INPUT_PULLUP);
	pinMode(pinBilge, INPUT_PULLUP);
	pinMode(pinWater, INPUT_PULLUP);
	pinMode(pinWiperL, INPUT_PULLUP);
	pinMode(pinWiperL, INPUT_PULLUP);

	// Make relais and LEDs OUTPUT
	pinMode(relAnchor, OUTPUT);
	pinMode(relRunning, OUTPUT);
	pinMode(relBilge, OUTPUT);
	pinMode(relWater, OUTPUT);
	pinMode(relWiperL, OUTPUT);
	pinMode(relWiperR, OUTPUT);

	// Set them all to OFF
	digitalWrite(relAnchor, OFF);
	digitalWrite(relRunning, OFF);
	digitalWrite(relBilge, OFF);
	digitalWrite(relWater, OFF);
	digitalWrite(relWiperL, OFF);
	digitalWrite(relWiperR, OFF);

	// attach buttons to callbacks
	btnAnchor.attachClick(OnAnchorPressed);
	btnRunning.attachClick(OnRunningPressed);
	btnBilge.attachClick(OnBilgePressed);
	btnWater.attachClick(OnWaterPressed);
	btnWiperL.attachClick(OnWiperLPressed);
	btnWiperR.attachClick(OnWiperRPressed);
	btnWiperL.attachDuringLongPress(OnWiperLongPressed);
	btnWiperR.attachDuringLongPress(OnWiperLongPressed);

	if (EEPROM.read(0) == 1)
	{
		digitalWrite(relWater, ON);
	}
	else
	{
		digitalWrite(relWater, OFF);
	}

	flWiperL = false;
	flWiperR = false;	
}

// the endless work of the MCU
void loop() 
{
	// check the buttons
	btnAnchor.tick();
	btnRunning.tick();
	btnBilge.tick();
	btnWater.tick();
	btnWiperL.tick();
	btnWiperR.tick();
	
	// check if a wiper is to be switched off
	// TODO: change to tendence current measuring
	if (flWiperL)
	{
		//int res = analogRead(febWiperL);		
		//if (res > 950)
		//{
			digitalWrite(relWiperL, OFF);
			flWiperL = false;
		//}
	}

	if (flWiperR)
	{
		//int res = analogRead(febWiperR);
		//if (res > 950)
		//{
			digitalWrite(relWiperR, OFF);
			flWiperR = false;
		//}
	}


}

// Here are the callback functions for the buttons

void OnAnchorPressed()
{	
	if (digitalRead(relAnchor) == OFF)
	{
		digitalWrite(relAnchor, ON);
		digitalWrite(relRunning, OFF);	
	}
	else
	{
		digitalWrite(relAnchor, OFF);
	}
}

void OnRunningPressed()
{
	if (digitalRead(relRunning) == OFF)
	{
		digitalWrite(relRunning, ON);
		digitalWrite(relAnchor, OFF);
	}
	else
	{
		digitalWrite(relRunning, OFF);
	}
}

void OnBilgePressed()
{
	if (digitalRead(relBilge) == OFF)
	{
		digitalWrite(relBilge, ON);
	}
	else
	{		
		digitalWrite(relBilge, OFF);
	}
}

void OnWaterPressed()
{
	// "Water" is the only channel that is switched on in normal condition.
	// As we want to have the relays in rest position on normal we have to invert it by using the LOW/HIGH system.	

	if (digitalRead(relWater) == LOW)
	{
		digitalWrite(relWater, HIGH);
		EEPROM.update(0, 1);		
	}
	else
	{
		digitalWrite(relWater, LOW);
		EEPROM.update(0, 0);		
	}
}

void OnWiperLPressed()
{	
	if (digitalRead(relWiperL) == OFF)
	{	
		digitalWrite(relWiperL, ON);
	}
	else
	{		
		flWiperL = true;		
	}
}

void OnWiperRPressed()
{	
	if (digitalRead(relWiperR) == OFF)
	{
		digitalWrite(relWiperR, ON);
	}
	else
	{
		flWiperR = true;
	}
}

void OnWiperLongPressed()
{
	digitalWrite(relWiperL, ON);
	digitalWrite(relWiperR, ON);
}

Schematics

Schematics of the Switch Board
This schematics show the main board carrying the Arduino Nano and the push buttons with LED. The relay breakboards (ie. Sundfounder) are connected via pins

Comments

Similar projects you might like

RFID-Controlled Light Switch

by stoica_c_florin

  • 2,574 views
  • 1 comment
  • 9 respects

RCar | Robots for All!

Project tutorial by Luís Rita

  • 8,047 views
  • 1 comment
  • 40 respects

Gear Indicator Project

Project tutorial by JorisH

  • 3,480 views
  • 3 comments
  • 8 respects

Arduino Sea Shells Light/Music Box

Project tutorial by behrooz66

  • 1,467 views
  • 2 comments
  • 7 respects

Leduindo - Smart Led Bike Lightning

Project tutorial by Marius Dima

  • 5,637 views
  • 1 comment
  • 21 respects

The Troll Switch

Project tutorial by Aitor Gamarra

  • 1,869 views
  • 3 comments
  • 7 respects
Add projectSign up / Login