Jump to content
OMRON Forums

PLC cannot execute background C program


zerbzhang

Recommended Posts

Enter system "/var/ftp/usrflash/Project/C Language/Background Programs/xoptical.out" in the terminal window; the background c program can run correctly.

Then, it cannot be executed in the plc.

When xoptical.out runs, prepare will be changed to 0. PLC1data will record the number of executions and complete the count. The program cannot run as designed, only PLC1data has been accumulating. I think it is because the PLC cannot issue the system command correctly to make xoptical.out run. How to avoid this problem?

 

 

// open plc 1

// --------------------User Code Goes Here------------------------

open plc Xoptical

 

if(prepare==1)

{

system "/var/ftp/usrflash/Project/C Language/Background Programs/xoptical.out" ;

call timer(10);

PLC1data++;

}

 

if(compWipe==1)

{

system "/var/ftp/usrflash/Project/C Language/Background Programs/xoptical.out";

call timer(10);

PLC2data++;

}

 

close

Link to comment
Share on other sites

  • Replies 14
  • Created
  • Last Reply

Top Posters In This Topic

Thanks ,Eric, my firmware version is 2.5.4.0. I have followed your instructions many times and still cannot run the background program C in the plc. Another strange problem also appeared.

 

float *compdataptr;

compdataptr = pshm->CompTable[16].Data + OffsetTblSHM;

 

if(Fisprepare==1&&FcompLoad==0)

{

int i,j;

data1=0;

data2=0;

int diffs=MatfCpoint + 1 ;

 

for(i=0;i<=MatfLinear;i++)

{

for(j=0;j<=MatfCpoint;j++)

{

 

*(compdataptr + diffs*i + j) = tempCuttingDepth; // send to the comp table

data2++;

}

 

data1++;

}

}

 

When I run the compensation table data assignment program, the IDE's terminal window prompts "egmentation fault", and then the background C program terminates. I wonder if my assignment is wrong? But can't find the problem?

Link to comment
Share on other sites

This is a bad thing. I followed the Entering Table Data Points in C section of the Power PMAC User’s Manual. In my actual application now, I do need to dynamically assign CompTable[m].Data. Command("CompTable[16].Data[0]=0") implements assignment, unfortunately, it cannot satisfy my application. I'm wondering why, suddenly I can't use the C language to assign values, but Power PMAC User’s Manual explains that POWER PMAC has this function?

I do need this feature. Does another version of the firmware have this function? Can I re-order a Power CPU to realize this function? If possible, please email me Eric, thanks again for your reply.

Link to comment
Share on other sites

  • 2 weeks later...

Eric,Through the Command (Command("CompTable[0].Data[0]=0")), in the background C language program, about 10 thousand assignments can be completed per second.

I am trying to increase the speed of assignment. Exercise time is precious, especially when there are many cycles. Are there any good suggestions worth trying?

Link to comment
Share on other sites

  • 2 weeks later...

The following code worked to change the first 2 table entries for me with either a 1D or 2D compensation table. I am using firmware 2.6.0.1 and IDE 4.5.1.3 on a UMAC 1040 CPU, but I would expect it to work the same on any Power PMAC.

 

float *CompDataPtr;
CompDataPtr = pshm->CompTable[1].Data + OffsetTblSHM;
*CompDataPtr = pshm->P[0];
*(CompDataPtr+1) = pshm->P[1];

 

I'm not sure why this isn't working for you. I tried writing to values past the end of the table, but I can't get a segmentation fault.

 

Can you try code that manual writes to the same location as the first couple iterations of that loop?

Link to comment
Share on other sites

  • 2 weeks later...
Eric. I'm trying an electronic cam table. I want to know if there is a definite relationship between CamTable[m].PosData and CamTable[m].OutData? I set CamTable[m].PosData[1] to 1000, CamTable[m].OutData[1] will automatically become 1148846080? I checked the manual document, but did not find the content in this regard. Can you answer it or provide some information for reference?
Link to comment
Share on other sites

CamTable[m].OutData is used for enabling GPIO based on motor position.

 

If you bring the motor to a position of CamTable[m].X0 with the camtable properly enabled, then...

The location specified by CamTable[m].pOut will be set to CamTable[m].OutData[0]

CamTable[m].PosOffset/Motor[x].CompDesPos will be set to CamTable[m].PosData[0]

Link to comment
Share on other sites

Eric, thanks for your reply.

I use C language to assign 1000 to CamTable[16].OutData. However, the result is 1148846080. What surprised me is that the values of CamTable[16].PosData[3], CamTable[16].PosData[5], CamTable[16].PosData[7], CamTable[16].PosData[9] are 1000 (It is the value I want to assign to CamTable[16].OutData).

 

 

float *CamDataPtr;

CamDataPtr = pshm->CamTable[16].OutData+OffsetTblSHM;

for(Ccount=0;Ccount

{

*(CamDataPtr + Ccount) =myval;

}

Camtable.png.6d3977089e9a2faf7ef4b75218c6df06.png

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...