element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
NexGen Flight Simuator NexGen: Multi-Purpose Color Display (F/A-18C/D MPCD): Hardware / Software Interface II
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: phoenixcomm
  • Date Created: 27 Mar 2021 9:26 PM Date Created
  • Views 592 views
  • Likes 3 likes
  • Comments 2 comments
  • mcp23017
  • nexgen flight simulator*
  • interrupt driven switches
  • interface
  • arduino
  • fa18mfcu-bezel
  • canbus
Related
Recommended

NexGen: Multi-Purpose Color Display (F/A-18C/D MPCD): Hardware / Software Interface II

phoenixcomm
phoenixcomm
27 Mar 2021

image

I have been down this road before but now I have the final solution. I found it in my old Motorola M6800 Applications Handbook, section 5-1.1.2 NonEncoded Keyboards. It used a PIA or Peripheral Interface Adapter, but since I am using an Arduino I need a part that will do the same thing.  So I will replace the PIA with an MCP23017 16-bit I/O expander.  As you can see I drive the data lines Data-0, and 4 with a high. When there is no key closure nothing happens but if a key is pressed 1) the active line is seen on its corresponding sense data lines Sense-0, 4  and there will be a signal change on the interrupt line.  Switch definitions are as follows: TOP SW1 - 5, RSide SW6 - 10, Bottom: SW11  - 15, and LSide: SW16 - 20;

image

** note I have to vet this code?!

int keyLookup () {

    for ( int i = 0; i < 5; i++ ) {

        if ( i = HIGH ) {

           for ( int j = 0; j < 4; j++ ) {

                if ( j == HIGH ) {

                   return ( MCP[i][j][0] ); }}}

 

        

 

Let me walk you through this.

  1. GPB will be the output and a one written into GPB0, 1, 2, 3, 4
  2. BPA0, 1, 2, 3, and 4 are inputs.
  3. interrupts are enabled
  4. On a key press, the high from the row is now on the associated column
  5. The NOR gate will change states
  6. use a for loop to scan the column for the hi
  7. disable the interrupts
  8. use a for loop to scan the row for the high while only looking at the column from above
  9. You should have the row and column.
  10. Since the column and row are now known we can do a lookup for the code to output
  11. GPB will be the output and a one written into GB0, 1, 2, 3
  12. //start over
  13. interrupts are enabled.
  14. // rinse and repeated

 

 

bezel.h

volatile int row;

#canNode 1

#define NodeID  82

#define ISR21 21

#define ISR22 22

struct mcp23017{

int io[5][5][1] = {

{ 0, 0, 1 }, { 0, 1, 2 }, { 0, 2, 3 }, { 0, 3 , 4},{ 0, 4, 5 },

{ 1, 0, 6  }, { 1, 1, 7 }, { 1, 2, 8 },  {1, 3, 9 }, {1, 4 10 },

{ 2, 0, 11 }, { 2, 1, 12 }, { 2, 2, 13 }, {2, 3, 14 }, {2, 4, 15 },

{ 3, 0, 16 }, { 3, 1, 17 }, { 3, 2, 18 },  {3, 3, 19 }, {3, 4, 20 };

}

 

typedef   struct mcp23017 MCP;

 

 

// CANbus

#define STANDARD_CAN_11BIT      1

 

 

#define can_tx  2           // tx  D2

#define can_rx  3           // rx  D3

 

 

 

 

void loop() {

//null

}

keys.h

// top left &

//counter-clockwise

#define SW1    1
#define SW2    2
#define SW3    3
#define SW4    4
#define SW5    5
#define SW6    6
#define SW7    7
#define SW8    8
#define SW9    9
#define SW10  10
#define SW11  11
#define SW12  12
#define SW13  13
#define SW14  14
#define SW15  15
#define SW16  16
#define SW17  17
#define SW18  18
#define SW19  19
#define SW20  20

#include keys.h

#include bezel.h

 

void setup () {

// Can assignments

   #if STANDARD_CAN_11BIT

   #define CAN_ID_PID          0x7DF

   #else

      #define CAN_ID_PID       0x18db33f1

   #endif

 

//MCP23017

    mcp.begin();

  // Assign pins MCP23017

  int pin; // for MCP23017

 

  for( pin = 0; pin < 16; pin++ ) {

    if( pin < 5 ) {

        pinMode(pin, OUTPUT);}

    else if( pin > 8 & pin < 13 )

        pinMode(13, INPUT);

    else;

  Wire.beginTransmission(0x20);

  Wire.write(0x00); // IODIRA register

  Wire.write(0x00); // set all of port A to outputs

  Wire.endTransmission();

 

 

  Wire.beginTransmission(0x20);

  Wire.write(0x01); // IODIRB register

  Wire.write(0x00); // set all of port B to outputs

  Wire.endTransmission();

 

}

void ISR21 () {

   int col;

   for ( col = 0; col < 5; col++) {

     if( mcp.digitalRead( col ) == HIGH {

       column = col; }}

void ISR22 () {
// is my NodeID?

 

// is this heartbeat?

disable ISR22;

heartbeat( NodeID );

enable ISR22

}

heartbeat (int nodeID ){

tx message node status

}

Note: the part where this uses CANaerospace has been DEPRECATED as I am now using an Ethernet Shield for communications. Please see Part iii - CAH March 21, 2023

  • Sign in to reply
  • rishabhghoshal
    rishabhghoshal over 4 years ago

    This is amazing !

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • neuromodulator
    neuromodulator over 5 years ago

    You probably meant volatile instead violate

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube