Netcruzer Library API  V2.03
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
nz_encIncRot.h File Reference

Functions for an Incremental Rotary Encoder. More...

Go to the source code of this file.

Data Structures

struct  ENCROT_INFO_
 

Macros

#define ENC_INC_ROT_BUFSIZE   128
 

Typedefs

typedef struct ENCROT_INFO_ ENCROT_INFO
 

Functions

BYTE rotinc_init (ENCROT_INFO *pObj, BYTE portIdChA, BYTE portIdChB)
 
void rotinc_task (ENCROT_INFO *pObj)
 

Detailed Description

Functions for an Incremental Rotary Encoder.

Author
Modtronix Engineering
Compiler:
MPLAB XC16

Description

Functions for an Incremental Rotary Encoder

Configuration

The following defines are used to configure this module, and should be placed in projdefs.h. Note that all items marked [-DEFAULT-] are defaults, and do not have to be placed in projdefs.h if they contain desired configuration! For details, see Project Configuration.

// *********************************************************************
// --- Incremental Rotary Encoder Configuration (from nz_encIncRot.h) --
// *********************************************************************
//Circular Buffer size
#define ENC_INC_ROT_BUFSIZE 128 //[-DEFAULT-]
//Resolution in us, must be power of 2 value, ex. 8,16,32,64,128... Is used as timebase for storing time between events
#define ENC_INC_ROT_RESOLUTION 16 //[-DEFAULT-]
//Debounce time in us
#define ENC_INC_ROT_DEBOUNCE 8 //[-DEFAULT-]

Usage

To use this module, the following must be done:

  • Include nz_encIncRot.h in the c file it is used in.
  • Add nz_encIncRot.c to the MPLAB project, this is the main driver file.
  • The following additional files are required by nz_encIncRot.c, and must be added to the project: nz_netcruzer.c
  • In projdefs.h, do any nz_encIncRot configuration required. This is done by copying the configuration section from the nz_encIncRot.h files to projdefs.h.
  • In code, call rotinc_init() to initiliaze, and incrot_task() repetitively in main loop.
  • All DONE! Can now use this driver's functions!

Software License Agreement

The software supplied herewith is owned by Modtronix Engineering, and is protected under applicable copyright laws. The software supplied herewith is intended and supplied to you, the Company customer, for use solely and exclusively on products manufactured by Modtronix Engineering. The code may be modified and can be used free of charge for commercial and non commercial applications. All rights are reserved. Any use in violation of the foregoing restrictions may subject the user to criminal sanctions under applicable laws, as well as to civil liability for the breach of the terms and conditions of this license.

THIS SOFTWARE IS PROVIDED IN AN 'AS IS' CONDITION. NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

File History

2014-01-02, David H. (DH):

  • Initial version

Function Documentation

BYTE rotinc_init ( ENCROT_INFO pObj,
BYTE  portIdChA,
BYTE  portIdChB 
)

Initialization.

Parameters
pObjPointer to ENCROT_INFO structure
portIdChAThe "Port ID" connected to channel A of the encoder. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
portIdChBThe "Port ID" connected to channel B of the encoder. Is a number from 0 to 41, also known as the "Netcruzer Port Name".
Returns
The status of the Initialization, 0=Success, else error code
void rotinc_task ( ENCROT_INFO pObj)

Main Task

Parameters
pObjPointer to ENCROT_INFO structure

DS2482 Task, is called when Channel A causes an interrupt