Jump to content
OMRON Forums

How to use ACC-28E board to read analog voltage in CPLC,thanks


YOUNAG

Recommended Posts

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

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...