Jump to content
OMRON Forums

YOUNAG

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by YOUNAG

  1. Why did the code copied in the manual fail to read the analog voltage value? Did something go wrong?

    #include <gplib.h>
    #include <stdio.h>
    #include <dlfcn.h>
    #include <RtGpShm.h>
    //----------------------------------------------------------------------------------
    // pp_proj.h is the C header for accessing PMAC Global, CSGlobal, Ptr vars
    // _PPScriptMode_ for Pmac Script like access global & csglobal
    // _EnumMode_ for Pmac enum data type checking on Set & Get global functions
    //------------------------------------------------------------------------------------
    #define _PPScriptMode_	// uncomment for Pmac Script type access
    #define _EnumMode_			// uncomment for Pmac enum data type checking on Set & Get global functions		
    
    #include "../../Include/pp_proj.h"
    
    void user_plcc()
    {
    unsigned int MySecondIoICAdr = pshm->OffsetCardIO[9];
    volatile unsigned int *MySecondIoRawADC1 = (unsigned int*)piom + MySecondIoICAdr / 4;
    volatile unsigned int *MySecondIoRawADC2 = (unsigned int*)piom + MySecondIoICAdr / 4 + 1;
    volatile unsigned int *MySecondIoRawADC3 = (unsigned int*)piom + MySecondIoICAdr / 4 + 2;
    volatile unsigned int *MySecondIoRawADC4 = (unsigned int*)piom + MySecondIoICAdr / 4 + 3;
    unsigned int MySecondIoADC1u = (*MySecondIoRawADC1 >> 16) & 0xFFFF;
    unsigned int MySecondIoADC2u = (*MySecondIoRawADC2 >> 16) & 0xFFFF;
    unsigned int MySecondIoADC3u = (*MySecondIoRawADC3 >> 16) & 0xFFFF;
    unsigned int MySecondIoADC4u = (*MySecondIoRawADC4 >> 16) & 0xFFFF;
    int MySecondIoADC1s = (*MySecondIoRawADC1 >> 16) - 32768;
    int MySecondIoADC2s = (*MySecondIoRawADC2 >> 16) - 32768;
    int MySecondIoADC3s = (*MySecondIoRawADC3 >> 16) - 32768;
    int MySecondIoADC4s = (*MySecondIoRawADC4 >> 16) - 32768;
    }

     

    1.png

×
×
  • Create New...