Jump to content
OMRON Forums

problems accessing "Motor[1].AmpEna" from background C program


vanandel
 Share

Recommended Posts

I have a background C program, capp1.c, that needs to report motor status. This application worked under earlier versions of PowerPMAC firmware, but now I've upgraded to 1.5.8.0 and the 8/9/2012, 1.5.0.21 IDE.

 

I get a pointer to the shared memory:

 

pSHM= GetSharedMemPtr();

 

and use this pointer to query the motor state:

 

if(pSHM->Motor[motor_number].AmpEna) ms |= MS_AMP_ENA;

 

The IDE status window shows motor '1' has "Amp Enabled". My C program reports that motor '1' does NOT have the AmpEna bit set.

 

When I search for RtGpShm.h, I find two versions under the IDE:

usr/local/dtlibs/rtpmac/RtGpShm.h

AND

usr/local/ppmaclibs/rtpmac/RtGpShm.h

 

Questions:

1) Why are there two different copies of this include file with different contents? (This was the first installation of the Power PMAC IDE on this PC .) One copy has "#ifdef bigendian" and has two different definitions of bit fields for big-endian vs little-endian -- which is the correct version?

 

2) How can I verify that my C program (which uses the structure definitions in RtGPShm.h) is using an offset in shared memory that matches the offset of Motor[1].AmpEna, as seen from the IDE? That is, how can I determine the offset of the Motor[1].AmpEna byte from the start of shared memory?

 

Thanks for your assistance.

Link to comment
Share on other sites

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

I have a background C program, capp1.c, that needs to report motor status. This application worked under earlier versions of PowerPMAC firmware, but now I've upgraded to 1.5.8.0 and the 8/9/2012, 1.5.0.21 IDE.

 

I get a pointer to the shared memory:

 

pSHM= GetSharedMemPtr();

 

and use this pointer to query the motor state:

 

if(pSHM->Motor[motor_number].AmpEna) ms |= MS_AMP_ENA;

 

The IDE status window shows motor '1' has "Amp Enabled". My C program reports that motor '1' does NOT have the AmpEna bit set.

 

When I search for RtGpShm.h, I find two versions under the IDE:

usr/local/dtlibs/rtpmac/RtGpShm.h

AND

usr/local/ppmaclibs/rtpmac/RtGpShm.h

 

Questions:

1) Why are there two different copies of this include file with different contents? (This was the first installation of the Power PMAC IDE on this PC .) One copy has "#ifdef bigendian" and has two different definitions of bit fields for big-endian vs little-endian -- which is the correct version?

 

2) How can I verify that my C program (which uses the structure definitions in RtGPShm.h) is using an offset in shared memory that matches the offset of Motor[1].AmpEna, as seen from the IDE? That is, how can I determine the offset of the Motor[1].AmpEna byte from the start of shared memory?

 

Thanks for your assistance.

 

Hi,

IDE always uploads the Lib from PowerPMAC on connection.

Did you compile your project code after you updated the FW and IDE?

Thanks,

Atul

Link to comment
Share on other sites

Bit numbers are given in “Intel” (little-endian) style, where the value of Bit n in the word is 2n. All bit numbers are for a full 32-bit word, even if the hardware uses less than 32 bits. Why there are two versions I am not sure but I will look into this in more detail.

 

The Power PMAC Software Reference Manual has a memory map listing that provides the offset from the start of I/O memory. Note The ASIC data structures are referenced to a different base address, piom instead of pshm.

Link to comment
Share on other sites

I have a background C program, capp1.c, that needs to report motor status. This application worked under earlier versions of PowerPMAC firmware, but now I've upgraded to 1.5.8.0 and the 8/9/2012, 1.5.0.21 IDE.

 

I get a pointer to the shared memory:

 

pSHM= GetSharedMemPtr();

 

and use this pointer to query the motor state:

 

if(pSHM->Motor[motor_number].AmpEna) ms |= MS_AMP_ENA;

 

The IDE status window shows motor '1' has "Amp Enabled". My C program reports that motor '1' does NOT have the AmpEna bit set.

 

When I search for RtGpShm.h, I find two versions under the IDE:

usr/local/dtlibs/rtpmac/RtGpShm.h

AND

usr/local/ppmaclibs/rtpmac/RtGpShm.h

 

Questions:

1) Why are there two different copies of this include file with different contents? (This was the first installation of the Power PMAC IDE on this PC .) One copy has "#ifdef bigendian" and has two different definitions of bit fields for big-endian vs little-endian -- which is the correct version?

 

2) How can I verify that my C program (which uses the structure definitions in RtGPShm.h) is using an offset in shared memory that matches the offset of Motor[1].AmpEna, as seen from the IDE? That is, how can I determine the offset of the Motor[1].AmpEna byte from the start of shared memory?

 

Thanks for your assistance.

 

Hi,

IDE always uploads the Lib from PowerPMAC on connection.

Did you compile your project code after you updated the FW and IDE?

Thanks,

Atul

 

Yes, I cleaned the project and compiled it after updating the FW and IDE. Does the IDE upload the include file, or just the library?

Link to comment
Share on other sites

I have a background C program, capp1.c, that needs to report motor status. This application worked under earlier versions of PowerPMAC firmware, but now I've upgraded to 1.5.8.0 and the 8/9/2012, 1.5.0.21 IDE.

 

I get a pointer to the shared memory:

 

pSHM= GetSharedMemPtr();

 

and use this pointer to query the motor state:

 

if(pSHM->Motor[motor_number].AmpEna) ms |= MS_AMP_ENA;

 

The IDE status window shows motor '1' has "Amp Enabled". My C program reports that motor '1' does NOT have the AmpEna bit set.

 

When I search for RtGpShm.h, I find two versions under the IDE:

usr/local/dtlibs/rtpmac/RtGpShm.h

AND

usr/local/ppmaclibs/rtpmac/RtGpShm.h

 

Questions:

1) Why are there two different copies of this include file with different contents? (This was the first installation of the Power PMAC IDE on this PC .) One copy has "#ifdef bigendian" and has two different definitions of bit fields for big-endian vs little-endian -- which is the correct version?

 

2) How can I verify that my C program (which uses the structure definitions in RtGPShm.h) is using an offset in shared memory that matches the offset of Motor[1].AmpEna, as seen from the IDE? That is, how can I determine the offset of the Motor[1].AmpEna byte from the start of shared memory?

 

Thanks for your assistance.

 

Hi,

IDE always uploads the Lib from PowerPMAC on connection.

Did you compile your project code after you updated the FW and IDE?

Thanks,

Atul

 

Yes, I cleaned the project and compiled it after updating the FW and IDE. Does the IDE upload the include file, or just the library?

 

IDE always upload the Libraries and not the included files. IDE compares the version of the libraries and always makes sure it is new.

Thanks,

Atul

Link to comment
Share on other sites

Bit numbers are given in “Intel” (little-endian) style, where the value of Bit n in the word is 2n. All bit numbers are for a full 32-bit word, even if the hardware uses less than 32 bits. Why there are two versions I am not sure but I will look into this in more detail.

 

The Power PMAC Software Reference Manual has a memory map listing that provides the offset from the start of I/O memory. Note The ASIC data structures are referenced to a different base address, piom instead of pshm.

I'm reading the August 2012 version of the Power PMAC Software Reference Manual, and can't find a memory map that lists the offset of Motor[1].Control[0] in shared memory. (Motor[1].Control[] is in a union with the Motor[1].AmpEn bit field).

 

Please give me a page number in this 1043 page document!

Link to comment
Share on other sites

The motor structures are only found in shared memory - as you are currently doing. I/O hardware is in piom memory. See "POWER PMAC I/O ADDRESS OFFSETS" starting on page 1006.

 

OK - for this issue, I don't care about piom memory, I only care about shared memory.

 

As I said in my initial forum post, my C program, the IDE terminal, and the IDE motor status window don't agree on what's in the motor structures in shared memory. The IDE motor status window shows motor '1' has "Amp Enabled", the IDE terminal interface to the PowerPMAC shows:

Motor[1].AmpEna = 1

 

however when my C program uses shared memory:

if(pSHM->Motor[1].AmpEna)

 

it DOES NOT show that the Amp Enabled bit is true.

 

How do I determine why the C program doesn't correctly reference the correct bit? If I could determine the offset in shared memory the terminal interface uses for 'Motor[1].AmpEna , I could compare this to the offset my C program is using in shared memory.

 

Again - this program used to work, and I've recompiled the program for the new libraries and IDE.

Link to comment
Share on other sites

Can you make sure you don't have multiple copies of your app on the system.

Maybe you are running a copy of your app that was built for the last version of firmware. You can check with the command

 

system find / -name NameofYourApp.out

 

Also the .h files that you should be compiling with are on the powerpmac ftp site. ftp://192.168.0.200/libppmac

 

These are automatically uploaded to

 

C:\Program Files\Delta Tau Data Systems, Inc.\2.0\Power PMAC Suite\powerpc-460-linux-gnu\usr\local\dtlibs

 

by the IDE. If for some reason they are different that could be your problem.

 

The motor structures are only found in shared memory - as you are currently doing. I/O hardware is in piom memory. See "POWER PMAC I/O ADDRESS OFFSETS" starting on page 1006.

 

OK - for this issue, I don't care about piom memory, I only care about shared memory.

 

As I said in my initial forum post, my C program, the IDE terminal, and the IDE motor status window don't agree on what's in the motor structures in shared memory. The IDE motor status window shows motor '1' has "Amp Enabled", the IDE terminal interface to the PowerPMAC shows:

Motor[1].AmpEna = 1

 

however when my C program uses shared memory:

if(pSHM->Motor[1].AmpEna)

 

it DOES NOT show that the Amp Enabled bit is true.

 

How do I determine why the C program doesn't correctly reference the correct bit? If I could determine the offset in shared memory the terminal interface uses for 'Motor[1].AmpEna , I could compare this to the offset my C program is using in shared memory.

 

Again - this program used to work, and I've recompiled the program for the new libraries and IDE.

Link to comment
Share on other sites

I removed all the old copies of my app, and renamed

usr/local/ppmaclibs/rtpmac/RtGpShm.h

, so it wouldn't be confused with the correct version:

 

usr/local/dtlibs/rtpmac/RtGpShm.h

 

After rebuilding my application, my application works as expected.

 

Thanks for your assistance.

 

It would be helpful if DeltaTau only shipped one copy of RtGpShm.h with the IDE. I was using a fresh install of the IDE, and somehow ended up with different versions:

usr/local/ppmaclibs/rtpmac/RtGpShm.h [A bogus version]

usr/local/dtlibs/rtpmac/RtGpShm.h [the correct version]

 

 

 

Can you make sure you don't have multiple copies of your app on the system.

Maybe you are running a copy of your app that was built for the last version of firmware. You can check with the command

 

system find / -name NameofYourApp.out

 

Also the .h files that you should be compiling with are on the powerpmac ftp site. ftp://192.168.0.200/libppmac

 

These are automatically uploaded to

 

C:\Program Files\Delta Tau Data Systems, Inc.\2.0\Power PMAC Suite\powerpc-460-linux-gnu\usr\local\dtlibs

 

by the IDE. If for some reason they are different that could be your problem.

 

The motor structures are only found in shared memory - as you are currently doing. I/O hardware is in piom memory. See "POWER PMAC I/O ADDRESS OFFSETS" starting on page 1006.

 

OK - for this issue, I don't care about piom memory, I only care about shared memory.

 

As I said in my initial forum post, my C program, the IDE terminal, and the IDE motor status window don't agree on what's in the motor structures in shared memory. The IDE motor status window shows motor '1' has "Amp Enabled", the IDE terminal interface to the PowerPMAC shows:

Motor[1].AmpEna = 1

 

however when my C program uses shared memory:

if(pSHM->Motor[1].AmpEna)

 

it DOES NOT show that the Amp Enabled bit is true.

 

How do I determine why the C program doesn't correctly reference the correct bit? If I could determine the offset in shared memory the terminal interface uses for 'Motor[1].AmpEna , I could compare this to the offset my C program is using in shared memory.

 

Again - this program used to work, and I've recompiled the program for the new libraries and IDE.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share


×
×
  • Create New...