zerbzhang Posted July 9, 2021 Share Posted July 9, 2021 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 More sharing options...
Omron Forums Support Posted July 9, 2021 Share Posted July 9, 2021 I think it has to do with file names containing spaces. Try this. system "/var/ftp/usrflash/Project/C\ Language/Background\ Programs/xoptical.out“ Link to comment Share on other sites More sharing options...
zerbzhang Posted July 10, 2021 Author Share Posted July 10, 2021 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 More sharing options...
Omron Forums Support Posted July 12, 2021 Share Posted July 12, 2021 Because compensation tables dynamically resize, it is not possible to write to those structures from C in that manner. Command quotes can be used instead. Command("CompTable[16].Data[0]=0"); Link to comment Share on other sites More sharing options...
zerbzhang Posted July 13, 2021 Author Share Posted July 13, 2021 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 More sharing options...
Omron Forums Support Posted July 13, 2021 Share Posted July 13, 2021 I am sorry. I remembered something about CamTables and assumed it was true for Compensation Tables as well. Compensation Table Correction Sizes can be configured in C as shown in the Power PMAC Users Manual. Link to comment Share on other sites More sharing options...
zerbzhang Posted July 28, 2021 Author Share Posted July 28, 2021 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 More sharing options...
Omron Forums Support Posted August 10, 2021 Share Posted August 10, 2021 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 More sharing options...
zerbzhang Posted August 23, 2021 Author Share Posted August 23, 2021 Thanks, Eric *CompDataPtr = pshm->P[0]; It is possible to assign pointers to P variables. I used to be local variables and always reported errors. This method can efficiently complete the assignment, I am very happy. Link to comment Share on other sites More sharing options...
Omron Forums Support Posted August 24, 2021 Share Posted August 24, 2021 I was just using "pshm->P[0]" as a placeholder so I could edit the value and not have to re-compile. You can also use C-Variables or literal numbers. Link to comment Share on other sites More sharing options...
zerbzhang Posted August 25, 2021 Author Share Posted August 25, 2021 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 More sharing options...
Omron Forums Support Posted August 25, 2021 Share Posted August 25, 2021 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 More sharing options...
zerbzhang Posted August 26, 2021 Author Share Posted August 26, 2021 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; } Link to comment Share on other sites More sharing options...
Omron Forums Support Posted September 1, 2021 Share Posted September 1, 2021 For OutData, the pointer must be declared as an int. int *OutDataPtr; OutDataPtr = pshm->CamTable[0].OutData + OffsetTblSHM; *OutDataPtr = (int) pshm->P[0]; *(OutDataPtr+1) = (int) pshm->P[1]; Link to comment Share on other sites More sharing options...
zerbzhang Posted September 2, 2021 Author Share Posted September 2, 2021 Eric, thanks . Link to comment Share on other sites More sharing options...
Recommended Posts