Well, for starters there are problems with the Ardunio CAN bus library, as ANY node in the system can be a master or a slave. Currently, the Arduino CAN supports a SLAVE - MASTER, relationship. On the MCP2515_CAN module, you have the following connection on the header, plus outputs Hight and Low. So with what little time I have remaining. I just will be sending and receiving messages via the USB port using CANaerospace formatted messages.

SIGNALMODULEMEGA PINICSPDefinition
MOSISI514Master Out / Slave In
MSOSO501Master Slave Out
SCLKSCK523System Clock
CSCS53Slave Select
INT

The Fuel Load Indicator has two switches:

1. UP / DOWN switches control which fuel tank is being filled or the current value of the selected tank. This is a circular list.

2. Fill controls the filling of the selected tank (see switch 1)

3. TEST position tests the system when selected both displays will turn on both displays.

After TESTING the upper display will display total fuel load in pounds, the lower display will display tank number and US Gallons.

There can be up to eight (8) tanks with CAN identifiers 668 - 675  with fuel total identifier at 1301. The Fule Load Indicator must also respond to IDS (node 0) Identification service. Requests a "sign-of-life" response together with the configuration from the addressed node.

 

Now back to the switches. I plan on using an SN74LS148 an 8 input to 3 BCD priority encoder. A nice feature of the encoder it has an extra output EO since all of the switches are pulled up EO = LOW, when a switch is energized EO = HIGH. The EO output is input to an SN74LS14 hex Schmitt-Trigger. The output of the Schmitt-Trigger is pin number 3 on the Arduino's Interrupt Pin.

AfterThought:

  • Please Note that pinInterrups value equals 3 and the name of the interrupt is ISR3.  This keeps things straight in my mind.
  • I could use bit manipulation:

valA = digitalRead (pinA );

valB = digitalRead (pinB );

valB << 2;

valC = digitalRead (pinC );

valC << 3;

testValue = valA + valB + ValC;

switches ( testValue );

 

// in setup
int pinInerrupt = 3;
int pinA = 22;
int pinB = 23;
int pinC = 24;
attachInterrupt(digitalPinToInterrupt(pinInterrupt),ISR3, CHANGE);

void ISR3() {
int valA;
int valB;
int valC;

valA = digitalRead( pinA );
valB = digitalRead( pinB );
valC = digitalRead( pinC );

if ( valC == 0 ) {
    switches ( 4 ); }
else if (valA == 0 && valB == 0){
    switches ( 3 );
else if (valB == 0 ){
    switches ( 2 ); }
else if ( valA == 0 ){
    switches ( 1 ); }
// in setup
#define UP 1
#define DOWN  2
#define TEST 3
#define FILL 4
int maxTanks = 8;
int curTank = 0;

void switches( int value ) {
    switch( value ) {
    case UP {
        if( curTank < maxTank ) {
            curTank++;
        else if( curTank == maxTank ) {
            curTank = 1; }}
    case DOWN {
        if( curTank = 1 ) {
            curTank = MaxTank;
        else curTank--; }}
    case TEST {
        test();}
    case FILL {
        fill( );}
}