As this node will be fairly busy, I have decided to implement this with interrupts.  The interrupts come from one of three (3) devices: CANaerospace Bus interface, USB term, one (1) of 2 switches, each with two(2) posisstions.

 

CANaerospace Bus:

Hardware - Software Design:
  1. On of two switches, each with two positions.
  2. CANaerospace Bus
  3. TTY1(USB)
This node can respond to messages for ID#:
  • 0 IDS
  • 668-675: Fuel Tank in Quantity (US GAL)
  • 676-683: Fuel Tank Temperature (F)
  • 1301: Total fuel on board weight

 

Switches: To handle the 4 choices set P -Down and TEST - FILL. I will use a 7 to BCD priority encoder coupled to a Schmitt Trigger. I will use the following functions:

  1. void upTank up()
  2. void downTank down()
  3. void test() ::= Turns on all bits in both displays, waits about 30sec and then print(display) display1: BITE TEST,  display2 OK vxx
  4. fill( int curTank)::= Diplay1 curTank; Diplay2 Filled when fuel in curTank == #maxTank 75.0; etc.

 

Code Fragment:

int curTank =0;
i nt maxTank = 7;
void setup() {
pinMode( term, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(term), , CHANGE);
pinMode( switches, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(switches), switch, CHANGE);
pinMode( canbusInt, INPUT_PULLUP);}
attachInterrupt(digitalPinToInterrupt(intCanbus), canbus, CHANGE);

void loop(){
}

void switches() {
         switch() {
         case: 1 {
             upTank();
             break(); }
       case: 2 {
          Tank();
          break(); }
      case: 3 {
           fillTank();
           break(); }
       case: 4 {
             selfTest();
            break(); }
       default: ERROR
        }

void canbus() {
  if((canID=> 668) &&(caID <= 675)) { tank( canID, Quan); } // This is in  US GAL
   else if canD=> 676) &&(caID <= 683 ) { tank( canID, Temp); } // This is in F°
else{
switch( canID){
       case: 0 {
            node0(); { do something
             break;}
       case: 1301
            node1301(){ do something
             break;}
       default: { } // message not for this node
return ( FALSE ); } // #define FALSE 0

 

Reference:  CANaerospace Interface Specification; The default Node Identification Service (IDS) distribution are described in chapter V pages: 24/45

 

"Each CANaerpace unit must support at least the Identificacion Service (IDS) on Node Service Channel 0. This makes sure that a CANaerospace network can be scanned for attached units to determine their status, header type and identifier assignment. Note that within a CANaerospace network, other header types than the standard CANaerospace header and several identifier assignment schemes (including entirely user-defined ones) are supported. Whenever possible, it is strongly recommended to use the proposed standard header and identifier assignments, however." -- page: 11 par 2