From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

How to solve the packet error in DDK program of PCI-7358

Solved!
Go to solution

Hi Everyone,

 

I am now developing the RTX driver for NI motion PCI-7358.

 

I would like to achieve the same function as flex_load_dac(). According to the DDK, I have to manually send the command through the packet. The format for flex_load_dac() is:

 

Load DAC
CommandID: 61
Valid Resource Type(s): DAC
Vector Type(s): Input
Packet Data (Send)
Word Count: 1
Data Passed In: i16 outputValue

 

So I write my code as:

 

//////////////////////////////////

 

#define CB  0
#define CSR 8

 

x = *(BaseAddress+CSR);
while ( !( x & 0X01) ) {
 printf("%X\n",x);
 x = *(BaseAddress+CSR);
} //wait for the RTR
printf("HEAD1 %X\n",x);
*(BaseAddress+CB) = (u16)0X0131; // Word Count << 8 | Resource ID

 

x = *(BaseAddress+CSR);
while ( !( x & 0X01) ) {
 printf("%X\n",x);
 x = *(BaseAddress+CSR);
} //wait for the RTR
printf("HEAD2 %X\n",x);
*(BaseAddress+CB) = (u16)61; // Command ID

 

x = *(BaseAddress+CSR);
while ( !( x & 0X01) ) {
 printf("%X\n",x);
 x = *(BaseAddress+CSR);
} //wait for the RTR
printf("DATA %X\n",x);
*(BaseAddress+CB) = (i16)0X1111; // write a value to DAC output

 

x = *(BaseAddress+CSR);
while ( !( x & 0X01) ) {
 printf("%X\n",x);
 x = *(BaseAddress+CSR);
} //wait for the RTR
printf("FOOT %X\n",x);
*(BaseAddress+CB) = (u16)0XFF0A; // vector = 0XFF
 
The print output is:

HEAD1 1
0
0
0
HEAD2 1
8
10
DATA 11
10
10
10
10
10
10
FOOT 11

 

It seems that after the Command ID is sent to the card, a Packet Error is met.

 

I have read all the related document about motion control card, but none talks the detailed explanation of Packet Error and how to deal with it.

Could any body helps me to solve this problem or point out what's wrong in my packet?

 

It is a very urgent project. I wish I can get help on you!

 

Thank you in advance!

 

Rick

0 Kudos
Message 1 of 19
(5,754 Views)
Solution
Accepted by topic author Rick Hunter

Rick,

 

Attached are some old files used to create a linux driver for the 733x and 734x motion boards.  The command interface is the same for the 735x boards.  They are provided AS IS, but I think they will give you some very useful insight into what you need to do.  For example to clear the command error you send the packet terminator value repeatedly it the error is cleared.

 

Rodger

 

 

Download All
Message 2 of 19
(5,751 Views)

Hi Rodger,

 

Sorry to reply you late. During these days, I have successfully finished the packet making and command sending thought RTX. The document you provide is REALLY a very good help for me. It solve my problem perfectly!

 

Thank you very much for your support! I appreciate for this!

 

Regards,

 

Rick

MSP

0 Kudos
Message 3 of 19
(5,695 Views)

Hi Rodger,

 

Sorry to reopen this thread again. I was puzzled by the data format in Motion-DDK.

 

From the Motion-DDK, if u32, i32 and f64 data are passed to and from the controller, a specific format must be followed as below:

 

u32:
u32 cmddata[x] = (WORD) (u32data ?16);
cmddata[x + 1] = (u16) u32data;

 

i32:
i32 cmddata[x] = (WORD) (i32data ?16);
cmddata[x + 1] = (i16) i32data;

 

f64:
f64—big endian order cmddata[x] = ((u16) (&f64data)) [3];
cmddata[x + 1] = ((u16) (&f64data)) [2];
cmddata[x + 2] = ((u16) (&f64data)) [1];
cmddata[x + 3] = ((u16) (&f64data)) [0];
f64—little endian order cmddata[x] = ((u16) (&f64data)) [0];
cmddata[x + 1] = ((u16) (&f64data)) [1];
cmddata[x + 2] = ((u16) (&f64data)) [2];
cmddata[x + 3] = ((u16) (&f64data)) [3];

 

My first question: is the "?" symbol means the >> (shift operator) or something else?

 

The second question is: if "?" means ">>" in this list, all the u32 and i32 data are always transferred in big-endian order. Is it the only correct way to deliver the i32 and u32 data? Or I can pass the u32 and i32 either in little-order or big-order depending on my platform?

 

The last one: could you provide a feasible C code on how to convert the f64 data to u16?

 

I first followed the format in the list to convert the f64 data, but met with a lot of compiler errors in VC++. After checked with MSDN, it is said the convert process is double(f64)->long(i32)->unsigned short(u16). But the decimal part of double will be truncated during converting to long...

 

So, could you help me with some very simple sample code on the convert process? 

 

Thank you for your support!

 

Rick

MSP

 

0 Kudos
Message 4 of 19
(5,644 Views)

Rick,

 

1.  Yes, the ? should be the >> operator.

2.  Yes the board always expects the data sent to it to be in big-endian orders. 

3.  The trick to the f64 data is to NOT typecast the data directly (we don't want to lose the value of the data).  We are using pointers/addresses to manipulate and move the data.  To fix the code the u16 typecast needs to be a u16* typecast.

 

f64—big endian order

cmddata[x + 0] = ((u16*) (&f64data)) [3];
cmddata[x + 1] = ((u16*) (&f64data)) [2];
cmddata[x + 2] = ((u16*) (&f64data)) [1];
cmddata[x + 3] = ((u16*) (&f64data)) [0];

 

So we are getting the address of  the f64 data, then typecasting the address to think it is pointing to u16 data, then we can index it like an array to assign its different parts to the cmddata array.  Another way to do this is with a union where we have f64 data or a u16 data[4] array.  That way we can look at the same memory in two ways.  As an f64 to set the value, and as an u16 array to pass the contents of the memory on the PCI bus.

 

The plug-in board does a similar operation to reassemble the data back into an f64 (value unchanged).

 

Good luck and let me know if you have anymore questions.

 

Rodger

0 Kudos
Message 5 of 19
(5,618 Views)

Hi Rodger,

 

During these days, I have tried different ways to convert the f64 data to u16 ones. I got some hint from the NI M-Series driver DDK and wrote some code as below:

 

//////////////////////////////////////////

typedef union {

   USHORT us[4];
   double d;
}   F64toU16; 

 

 F64toU16 ftu;
 ftu.d = f64Value;

 

//as little endian

outbuffer[0] = ftu.us[0];

outbuffer[1] = ftu.us[1];

outbuffer[2] = ftu.us[2];

outbuffer[3] = ftu.us[3];

/////////////////////////////////////////

 

Could you tell me whether this way is available for the convert process? I think this is the more direct and easier way to deliver the command.

 

Thank you in advance!

 

Rick

MSP

 

0 Kudos
Message 6 of 19
(5,609 Views)

Rick,

 

Using a union is just fine, it is another way of doing the same thing the original code was accomplishing.  Just make sure to pass all data in big endian form to the board.

 

Rodger.

0 Kudos
Message 7 of 19
(5,604 Views)

Hi Rodger,

 

With your great support on my driver development, the project is going to the end. I have written almost all the flex_ functions , though some expections left.

 

There are several flex_ functions that can not find their corresponding commands in DDK Document. They are:

 

flex_load_circular_arc()
flex_load_move_constraints()
flex_wait_reference()
flex_check_reference()
flex_get_error_description()
flex_insert_program_label()
flex_load_axis_configuration_parameter()
nimcAxisStraightLineMove()
nimcClearFaults()
nimcConfigureMotionIOMap()
nimcResetController()

 

The same thing happened in DDK Document. The commands in the list below do not have the counterparts in the NI-function Document:

 

Load Velocity Filter Time Constant & Run/Stop Threshold
Configure Step Mode & Polarity
Read Traj Sample
Find Home
Find Index

 

I guess that the DDK Document may has been updated for times after it is released, so the new functions are missing. Since some of them are with very high importance and necessity, such as nimcResetController(), flex_load_circular_arc(), could you please provide me some information on these functions and their corresponding commands?

 

I believe this PCI-7358 driver project will be a perfect one with your information and help!

 

Sincerely Thanks!

 

Regards,

 

Rick
MSP

0 Kudos
Message 8 of 19
(5,562 Views)

Rick,

 

Can you please reply with the exact list of what commands you want help on.  I want to make sure I get to the ones you want first.  And I might not do them all if you don't have a need for them.

 

You are correct in the that driver has released multiple times since the DDK was released.  Based on the usage of the DDK (there just are not that many using it), we do not keep it up to data with each release.  But as you have seen, I am willing to help answer your questions so I think we can get your driver to work for your needs.

 

Thanks,

 

Rodger

0 Kudos
Message 9 of 19
(5,557 Views)

Hi Rodger,

 

I understand that you may have been through some difficulties in this case. Since my customer demands all the functions which is needed in his motion applications, the ones in the following list are necessary:

 

flex_load_circular_arc()
flex_wait_reference()
flex_check_reference()
flex_insert_program_label()
nimcResetController()

 

Except for the above, other commands are all optional now. Could you please help me on these 5 functions? Or you may directly send the command information to my email ( zhangjing@msptc.com ) for your convenient.

 

Regards,

 

Rick

MSP

0 Kudos
Message 10 of 19
(5,548 Views)