Jump to content
OMRON Forums

GPIO access on AX1515N (CK3M) code example


Recommended Posts

Good day,

I am trying to understand how to read and write values to the GPIO port on my AX1515N (CK3M) however, the documentation avaiable hasnt helped much on this regard.
For learning pourpuses, could you provide an code example that follows the folowing pseudocode:

void user_plcc()
{
    input = IN_00; // read the state of IN00 (LOW = 0V, HIGH = 24V)
 
    if (input == LOW) // blinck output 0 every 1000 ticks
    {
       
        static int i = 0;
 
        if(i > 1000)
        {
           OUT_00 = HIGH;
        }
        else
        {
            OUT_00 = LOW;
        }
        i = i %2000;
    }
}

I have tried somethin of the sorts but i dont get any measurable results.

#define OutputData(x) (x << 16)
 
void user_plcc()
{
 
    volatile GateArray3 *MyGate3IO;
    MyGate3IO = GetGate3MemPtr(0);
 
    static int i = 0;
 
    if(i++ > 1000)
    {
 
        MyGate3IO->GpioData[0] = OutputData(0xAAAA);    
 
    }
    else
    {
 
        MyGate3IO->GpioData[0] = OutputData(0x5555);            
 
    }
 
    i = i %2000;
}
Link to comment
Share on other sites

These I/O, being optically isolated, need external bias (typically 24VDC ) for current to flow.  See:

CK3IO.thumb.jpg.42cb6b301d8c00a8dd983708bfd6b61d.jpg

 

But, even without the 24v connected, you should see the individual led channel status indicators respond when your code changes the OUTPUTS,  no ??
 

Link to comment
Share on other sites

If you mean the LEDs on top og the GPIO port, no, they dont lit up when the bgcplc is running. I have tried both with and without the external 24V power source on two systems and always get the same behaviour.

Is there something i have to configure in order to use the GPIO port?

WhatsApp Image 2024-01-22 at 17.13.23_6af72a34.jpg

Link to comment
Share on other sites

Have you enabled your plc with:
UserAlgo.BgCplc[0] = 1     ?


Also, by default, 

You should be able to type in the terminal:

Gate3[0].GpioData[0] = 0    // outputs off
Gate3[0].GpioData[0] = $10000    //Output 1 ON  

Gate3[0].GpioDir[0] = $ffff0000   // this should be the default

  • Thanks 1
Link to comment
Share on other sites

I'd agree with Dave--I always try to split my troubleshooting for stuff like this into pieces. Rather than using a C PLC, which brings with it it's own set of questions (Did it generate an error on build and I didn't notice? Is it actually enabled? Are the pointers correct? Etc.), start basic.

-If you issue the specific command to turn an output on through the terminal window, does the LED indicator turn on?

-Can you turn them all on (GpioData[0] = $FFFF0000)?

-After that, can you turn them off?

 

As he noted in the previous post, 9/18/27 are inputs--you'll need to bring in the reference voltage into those pins. If you see the LEDs toggle, but aren't seeing your devices toggle, that's a likely cause.

 

Finally, I'd check if your code was loaded properly and actually running.

 

Link to comment
Share on other sites

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...