manufacturer of I/O-rich SBCs, operator interfaces, handheld instruments, and development tools for embedded control low cost single board computers, embedded controllers, and operator interfaces for scientific instruments & industrial control development tools for embedded control order our low cost I/O-rich embedded control products embedded controller manufacturer profile single board computers & embedded controllers development tools & starter kits for your embedded design operator interfaces with touchscreens and graphical user interface plug-in expansion modules for digital & analog I/O C language & Forth language integrated development tools, IDE single board and embedded computer accessories embedded controller enclosures, bezels, environmental gaskets
Table of Contents

Introduction

Digital I/O Wildcard Hardware

Connecting To Mosaic Controller

Selecting the Digital I/O Wildcard Address

Current Capability of the Digital Output Lines

Protecting the Input and Output Pins

Connecting to the Field Header

Digital I/O Wildcard Software

Setting the Direction of the I/O Lines

C Code to initialize the Digital I/O Wildcard

Forth Code to initialize the Digital I/O Wildcard

Controlling the I/O Lines

C Code to control the Digital I/O Wildcard

Forth Code to control the Digital I/O Wildcard

Digital I/O Wildcard Schematics (pdf)

Digital I/O Wildcard User Guide

<< Previous | Next>>

Controlling the I/O Lines

Once you have set the direction of the I/O lines, you can read and set the I/O lines like the other digital I/O ports on the Mosaic controller.

C Code to control the Digital I/O Wildcard
#define OUTPUT_HIGH 1
#define OUTPUT_LOW 0
 
#define NIBBLE_0_ADDR 0xC000 // Lines 0-3.
#define NIBBLE_1_ADDR 0xC001 // Lines 4-7.
#define NIBBLE_2_ADDR 0xC002 // Lines 8-11.
#define NIBBLE_3_ADDR 0xC003 // Lines 12-15.
#define NIBBLE_4_ADDR 0xC004 // Lines 16-19. Inputs only
 
#define LINE_0 1
#define LINE_1 2
#define LINE_2 4
#define LINE_3 8
#define LINE_4 1
#define LINE_5 2
#define LINE_6 4
#define LINE_7 8
#define LINE_8 1
#define LINE_9 2
#define LINE_10 4
#define LINE_11 8
#define LINE_12 1
#define LINE_13 2
#define LINE_14 4
#define LINE_15 8
 
void Control_DIO ( uchar mod_num, uint nibble_addr, uchar line, uchar state )
// Sets I/O line of specified nibble to the appropriate state (high or low).
// Valid module (ie Wildcard) numbers are 0-7.
// Valid nibble addresses are NIBBLE_0_ADDR to NIBBLE_3_ADDR.
// Valid lines are LINE_0 to LINE_15
// Valid states are OUTPUT_HIGH or OUTPUT_LOW
{
  EXTENDED_ADDR module_addr;
 
  module_addr.sixteen_bit.page16 = mod_num;
  module_addr.sixteen_bit.addr16 = nibble_addr;
 
  if(state) // set line high
  {
   SetBits( line, module_addr.addr32 );
  }
  else // set line low
  {
   ClearBits ( line, module_addr.addr32 );
   }
 }
 
uchar Read_Nibble ( uchar module_number, uint nibble_addr )
// Reads the current state of the Digital I/O nibble.
// Valid module numbers are 0-7.
// Valid nibble addresses are NIBBLE_0_ADDR to NIBBLE_4_ADDR.
// Returns an unsigned character whose least significant nibble represents
// the four I/O lines. For example, if nibble 1 is read and a 1 is returned
// (0001 in binary), then line 4 is high and lines 5-7 are low. If 12 is
// returned (1100 in binary) after reading nibble 3, then lines 12 and 13 are
// low and lines 14 and 15 are high. The four most significant bits of the
// returned byte do not matter.
{
  EXTENDED_ADDR module_addr;
  uchar nibble_status;
 
  module_addr.sixteen_bit.page16 = module_number;
  module_addr.sixteen_bit.addr16 = nibble_addr;
 
  nibble_status = FetchChar( module_addr.addr32 );
 
  return( nibble_status );
}

<< Previous | Next>>


Home|Site Map|Products|Manuals|Resources|Order|About Us
Copyright (c) 2006 Mosaic Industries, Inc.
Your source for single board computers, embedded controllers, and operator interfaces for instruments and automation