Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PLC cannot execute background C program
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

system "/var/ftp/usrflash/Project/C Language/Background Programs/xoptical.out" ;
call timer(10);

system "/var/ftp/usrflash/Project/C Language/Background Programs/xoptical.out";
call timer(10);

I think it has to do with file names containing spaces. Try this.
system "/var/ftp/usrflash/Project/C\ Language/Background\ Programs/xoptical.out“
Thanks ,Eric, my firmware version is 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;

int i,j;
int diffs=MatfCpoint + 1 ;


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


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?
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.
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[i]. 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.
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.
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?
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 and IDE 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?
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.
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.
Eric. I'm trying an electronic cam table. I want to know if there is a definite relationship between CamTable[m].PosData[i] and CamTable[m].OutData[i]? 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?
CamTable[m].OutData[i] 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]
Eric, thanks for your reply.
I use C language to assign 1000 to CamTable[16].OutData[i]. 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[i]).

float *CamDataPtr;
CamDataPtr = pshm->CamTable[16].OutData+OffsetTblSHM;
*(CamDataPtr + Ccount) =myval;

Attached Files Image(s)
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];
Eric, thanks .

Forum Jump:

Users browsing this thread: 1 Guest(s)