This is a library to use HV507 boards as a switching circuitry which is a module used with an electrical stimulator made by kaji-lab.

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers KajiLabHV507B.h Source File

KajiLabHV507B.h

Go to the documentation of this file.
00001 /** HV507 boards' utilities
00002  *
00003  *  This program is for using HV507(Shift Register Chip Circuit) for
00004  *  electric stimulation. The base Program had been written by Kajimoto Hiroyuki.
00005  *
00006  *  \file   KajiLabHV507B.h
00007  *  \Author Akifumi TAKAHASHI
00008  *
00009  *  \date   2015/Jul/16th Ver.1
00010  *  \date   2018/Fall Kajimoto-sensei was promoted to Professor!!!
00011  *  \date   2018/Nov/27th Ver.2 Simplified as a pure channel switching program.
00012  */
00013 #ifndef MBED_HV507DRIVER_H
00014 #define MBED_HV507DRIVER_H
00015 
00016 #include "mbed.h"
00017 
00018 /*  --------------------------------------------------------------------------------------------------------
00019  *  HV507 Function table
00020  *  --------------------------------------------------------------------------------------------------------
00021  *  Function        Input                                           Output
00022  *                  Data    CLK     !LE     !BL     !POL    DIR     Shift Reg       HV Out          Data Out
00023  *                                                                  1       2~64    1       2-64
00024  *  ========================================================================================================
00025  *  All on          X       X       X       L       L       X       *       *~*     H       H-H     *
00026  *
00027  *  All off         X       X       X       L       H       X       *       *~*     L       L-L     *
00028  *
00029  *  Invert mode     X       X       L       H       L       X       *       *~*     !*      !*~!*   *
00030  *  --------------------------------------------------------------------------------------------------------
00031  *  Load S/R        H or L  up      L       H       H       X       H or L  *~*     *       *~*     *
00032  *
00033  *  Store data      X       X       down    H       H       X       *       *~*     *       *~*     *
00034  *    in latches    X       X       down    H       L       X       *       *~*     !*      !*~!*   *   
00035  *
00036  *  Transparent     L       up      H       H       H       X       L       *~*     L       *~*     *
00037  *    latch mode    H       up      H       H       H       X       H       *~*     H       *~*     *
00038  *  --------------------------------------------------------------------------------------------------------
00039  *  I/O Relation    DIOA    up      X       X       X       L       Qn ->   Qn+1        -           DIOB
00040  *                  DIOB    up      X       X       X       H       Qn ->   Qn+1        -           DOIA
00041  */
00042  
00043  /**    HV507 class
00044   *
00045   *     With this class you can deal a HV507 board'''s''' as one object
00046   */ 
00047 class HV507
00048 {
00049 public:
00050     /** Constructor
00051      *
00052      *  \param (const int arg_num_of_board = 1) the number of Hv507 board.
00053      */
00054     HV507(const int arg_num_board = 1);
00055     
00056     /** HV507 initialization
00057      *
00058      *  This is curried in constructor.
00059      *  In this function, all output pins are set as L (ALL GROUND),
00060      *  and Porarity (POL) is set to 1 (nomal mode; in other words, 
00061      *  data in latches of HV507 is reflected to output as is.
00062      *  If POL = 0, the output is inverted data (inverse mode).
00063      */
00064     void init();   
00065     
00066     /** Set a stim bit.
00067      *  
00068      *  Set one high bit (1) this is regarded as stim bit.
00069      */
00070     void setHtoSR();
00071     
00072     /** Set a ground bit
00073      *  
00074      *  Set one low bit (0) this is regarded as ground bit.
00075      *  If shifting the register many times, it is recommended to use 
00076      *  shiftSRBits_by().
00077      */
00078     void setLtoSR();
00079     
00080     /** Function to shift data only index-incresing-direction
00081      *
00082      *  \param (int arg_num_shifting) stimulation point
00083      */
00084     void shiftSRBits_by(int arg_num_shifting);
00085     
00086     /** Fill all with zero (ground)
00087      */
00088     void clearSR();
00089     
00090     /** Function to define ONE stimulation point
00091      *
00092      *  \param (const int arg_ch) the pin number supposed to be a stim pin.
00093      */
00094     void setCh(const int arg_ch);
00095     
00096     /** Function to store data in shift register to latches.
00097      *
00098      *  This is called in setCh. But if you need to use other function to deal
00099      *  the shift rester, you should call this function to output the data.
00100      */
00101     void updateLatches();
00102     
00103     void DEBUG_ALLPIN_ON();
00104     void DEBUG_ALLPIN_OFF();
00105     
00106 private:
00107     //  HV507 Logical Pins
00108     //  Logical Pins Array = (DIOB, CLK, LE, BL, POL)
00109     DigitalOut  m_DIOB; ///< Pin to transfer Data input to HV507 
00110     DigitalOut  m_BL;   ///< Pin to transfer signal !BL(not-Blaker)
00111     DigitalOut  m_POL;  ///< Pin to transfer signal !POL(not-Pole signal)
00112     DigitalOut  m_CLK;  ///< Pin to transfer signal Clock
00113     DigitalOut  m_LE;   ///< Pin to transfer signal !LE(not-Latch Enable)
00114     
00115     /** The number of all pins including in Hv507 boards.
00116      * This is culculated in a constructor
00117      */
00118     const int   m_num_pins; 
00119     
00120     /** The constant number that expresses the number of output pins in a HV507
00121      */
00122     //enum :int   {HV507_NUM_PINS = 64};
00123     static const int HV507_NUM_PINS = 64;
00124     
00125     /** The variable expressing the postion of stimulation point
00126      *
00127      *  -    0   : No stimulationpoint
00128      *  -    1 ~ (HV507_PIN_NUM * m_num_of_board): a stimulation point;
00129      *       if the number of stim points are over than 1, this var means
00130      *       the last one.
00131      */
00132     int m_pos_stim;
00133     
00134     
00135     void putSRCLKahead();
00136 };
00137 #endif