Jump to content
OMRON Forums

Gather enable from background C program crash PowerPMAC


george.kontogiorgos

Recommended Posts

Hello,

I am unsuccessful trying to trigger data gather from a C background program. I wrote the following program (capp1.c) to debug the problem:

/*For more information see notes.txt in the Documentation folder */
#include <gplib.h>

#define _PPScriptMode_		// for enum mode, replace this with #define _EnumMode_
#include "../../Include/pp_proj.h"

int main(void)
{
	InitLibrary();  // Required for accessing Power PMAC library

	pshm->Gather.Enable=2;
	
	CloseLibrary();
	return 0;
}

Then I built, downloaded and save the project. After that I restarted the controller with $$$ on IDE terminal and run my background program via SSH connection (./capp1.out). The controller then suddenly  stops responding on IDE and the controller`s watchdog LED lights up.

When I first do some gather via IDE terminal (Configure everhing, Gather.Enable=2 and Gather.Enable=0) , the background program starts working (it sets correctly the enable register and gather the desired data).

I have the hypothesis that the commands issued from terminal do some initialization on gather feature but I do not know how to track it. This idea of initialization comes to me when I realized that when I do Gather.Enable=2 on C program the Gather.Index does not automatically erase as it happens when the same command is issued from IDE terminal. So I manually erase the buffer and reset index as follows:

/*For more information see notes.txt in the Documentation folder */
#include <gplib.h>

#define _PPScriptMode_		// for enum mode, replace this with #define _EnumMode_
#include "../../Include/pp_proj.h"

int main(void)
{
	InitLibrary();  // Required for accessing Power PMAC library

	//Put your code here

  	// Disable any running gather
	pshm->Gather.Enable=0;
  
	// Set sample counter to zero
	pshm->Gather.Samples=0;

  	// Erase buffer with gpascii command (Index points to buffer's position 0 after clear)
	GetResponse("clear gather", gpascii_response, 100, 1);

	// Start gather
	pshm->Gather.Enable=2;

	CloseLibrary();
	return 0;
}

 Another point is that I could successfully enable the gather at first time after reset by using:

GetResponse("Gather.Enable=2", gpascii_response, 100, 1);

Instead of:

pshm->Gather.Enable=2;

I  tryed on two different controller's architecture:

Type: POWER PMAC BRICK

CPU: PowerPC, AMP86xxx

Firmware: 2.5.4.0

And

Type: POWER PMAC BRICK

CPU: arm,LS1021A

Firmware: 2.6.0.0

Thanks in advance,

George

Edited by george.kontogiorgos
Link to comment
Share on other sites

  • george.kontogiorgos changed the title to Gather enable from background C program crash PowerPMAC

I can start gathering by running a C program with the following line after using the plot tool to initialize settings.

pshm->Gather.Enable=2;

I have a feeling the issue lies in the setup of the "Gather." variables usually configured by the plot tool. Can you try using the tool to set these up as a test? You should be able to close it before your actual gathering and keep the settings.

  • Like 1
Link to comment
Share on other sites

Hi Eric,

As your suggestion I did some tests as follows.

Test 1

I issued the folowing commands (on that order) on the terminal:

$$$
Gather.Items=1
Gather.Addr[0]=Sys.ServoCount.a
Gather.Period=1
Gather.MaxSamples=100000

And then I ran my C Background Program with the following content

/*For more information see notes.txt in the Documentation folder */
#include <gplib.h>   

#define _PPScriptMode_		// for enum mode, replace this with #define _EnumMode_
#include "../../Include/pp_proj.h"

int main(void)
{
	InitLibrary();  // Required for accessing Power PMAC library

	pshm->Gather.Enable=2;				//Put your code here

	CloseLibrary();
	return 0;
}

And then the PowerPMAC crashed (the red arrow 😞

image.thumb.png.f77bb2d87c4ffb31b661ea1ae5f74604.png

Test 2

I reseted the PowerPMAC with $$$, opened the plot window and wait it initialize. After that I closed the plot window and set my gather parameters (Just to be the same as the last test since plot window sets Gather.Period and Gather.MaxSamples when it opens).

Then I ran my C Background Program (the same as Test 1) and everything goes fine.

Conclusions from Test 1 and Test 2

Opening the plot window before using pshm->Gather.Enable=2 on the C Backgroud Program works fine (the PowerPMAC does not crash by enabling gather on a C program). I suspected the Gather.Enable=1 followed by a Gather.Enable=0 that is on plot window Gather Settings area. That was difference from my configuration from terminal and configuration from Plot window. This lead me to Test 3.

Test 3

I did exactly the same as Test 1 but adding Gather.Enable=1 followed by a Gather.Enable=0 on Initial gather configuration on IDE Terminal:

$$$
Gather.Items=1
Gather.Addr[0]=Sys.ServoCount.a
Gather.Period=1
Gather.MaxSamples=100000
Gather.Enable=1
Gather.Enable=0

Then I ran the  C Background Program and the PowerPMAC did not crash.

Conclusions from Test 3

PowerPMAC Test 3 lead me to the conclusion that setting Gather.Enable=1 or Gather.Enable=2 (value 2 I tested earlier on my first post of this thread) run some initialization on Gather. structure. So I did Test 4 to know if setting Gather.Enable=0 and run the C Background Program crash the PowerPMAC.

Test 4

I reseted the PowerPMAC controller and then issued the following commands into the IDE Terminal

Gather.Items=1
Gather.Addr[0]=Sys.ServoCount.a
Gather.Period=1
Gather.MaxSamples=100000
Gather.Enable=0

Then I ran the  C Background Program and the PowerPMAC crashed.

Conclusions from Test 4

Setting the same value (Gather.Enable=0) to register and running the C program crash the controller. The last test, the test 5, I just tryed the last option for enabling gather (Gather.Enable=3).

Test 5

I reseted the PowerPMAC controller and then issued the following commands into the IDE Terminal

Gather.Items=1
Gather.Addr[0]=Sys.ServoCount.a
Gather.Period=1
Gather.MaxSamples=100000
Gather.Enable=3
Gather.Enable=0 // Stop rotary gather

Then I ran the  C Background Program and the PowerPMAC did not crashed.

Conclusion

Changing Gather.Enable value from 0 to something different from IDE terminal may initialize something inner the controller that allow pshm-Gather.Enable works fine on a C Background Program. This is what Plot window does when it initializes (we can see on Gather registers changes). Obviously I do not know in fact what the Plot window does and maybe it do some inner controller initialization.

 

Thanks,

George

Edited by george.kontogiorgos
  • Like 1
Link to comment
Share on other sites

I believe that the act of setting Gather.Enable from the script environment applies the settings in Gather. variables. Setting Gather.Enable to 2 or 3 from C code after changing these settings, but before changing the value in the script environment, will crash PMAC.

The "Command" command can be used from C to run code in the script environment after changing these settings.

Command("Gather.Enable=2");

 

  • Like 1
Link to comment
Share on other sites

Hi Eric,

16 hours ago, Eric Hotchkiss said:

The "Command" command can be used from C to run code in the script environment after changing these settings.

Command("Gather.Enable=2");

Thanks for the tip. I was using to circumvent the problem on my API:

GetResponse("Gather.PhaseEnable=2", gpascii_response, 100, 1);

But maybe your command is faster than mine since GetResponse has to manipulate the return from the command.

I was thinking in just initialize Gather. structure on the begining of my program with something like that

// Initialize Gather. struture
Command("Gather.Enable=0");
Command("Gather.Enable=1");
Command("Gather.Enable=0");

// Use gather structure directly
pshm->Gather.Enable=2;

Thanks,

George

Link to comment
Share on other sites

The CaptCompISR should be as short as is possible. The best method would be to set a flag (such as a script global variable), that can be reacted to by a background Script/C PLC.

Here is an example Script PLC.

GLOBAL MyGatherFlag
OPEN PLC StartGatherPLC
LOCAL MyGatherLatch
IF(MyGatherFlag == 1)
{
    IF(MyGatherLatch == 0)
    {
        Gather.Enable = 2
        MyGatherLatch = 1
    }
}
ELSE
{
    IF(MyGatherLatch == 1)
    {
        Gather.Enable = 0
        MyGatherLatch = 0
    }
}
CLOSE

 

Link to comment
Share on other sites

Hi Eric!

Thanks for replying me.

12 hours ago, Eric Hotchkiss said:

The CaptCompISR should be as short as is possible.

Yes, I do know that this is a good pratice, thanks for the advice. I think it would not be a problem if the CaptCompISR just enable the gather.

12 hours ago, Eric Hotchkiss said:

The best method would be to set a flag (such as a script global variable), that can be reacted to by a background Script/C PLC.

I had this idea but I was trying to avoid any delay between the interruption and enabling the gather. 

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