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.

Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

No LIN response from an AMIS stepper driver

Hello,

 

actually i'm trying to control an Onsemi AMIS 30623 stepper driver through LIN using LabWindows/CVI 9 and a NI USB-8476 LIN Interface.

 

My Problem is that I don't get any response from the device at all and my master task in CVI just reads back the full LIN Frames it has sent but no response Frames from the AMIS.

 

I'm using the Frame API within CVI to send and receive data from the LIN bus. Opening the LIN object, setting the desired Parameters and so on seems to work fine within CVI. These are the parameters i used:

- Baudrate: 19200

- Termination: Enabled

- LogBusErrors: Enabled

- SelfReception: Enabled

 Also bringing the Interface to operational mode works fine.

 

The AMIS chip has a fixed Hardware ID of 0x70. To check the status of the AMIS, a special command ("Preparation Frame") followed by two "Reading Frames" have to be sent as you can see in this picture:

 

GetFullStatus.jpgAs far as I know the "Preparation Frame" must be a "LIN Full Frame" (isRemote value 18). So I created the frame as follows:

 

 

 

NCTYPE_CAN_FRAME frameMasterGetFullStatusPreparingFrame;


frameMasterGetFullStatusPreparingFrame.ArbitrationId = 0x3C; // Identifier = 00111100
frameMasterGetFullStatusPreparingFrame.Data[0] = 0x80; // Data 1: AppCMD = 80
frameMasterGetFullStatusPreparingFrame.Data[1] = 0x81; // Data 2: 10000001 (GetFullStatus CMD = 0x01)
frameMasterGetFullStatusPreparingFrame.Data[2] = 0xF0; // Data 3: 11110000 Physical Address = 0x70
frameMasterGetFullStatusPreparingFrame.Data[3] = 0xFF; // Data 4: FF
frameMasterGetFullStatusPreparingFrame.Data[4] = 0xFF; // Data 5: FF
frameMasterGetFullStatusPreparingFrame.Data[5] = 0xFF; // Data 6: FF
frameMasterGetFullStatusPreparingFrame.Data[6] = 0xFF; // Data 7: FF
frameMasterGetFullStatusPreparingFrame.Data[7] = 0xFF; // Data 8: FF
frameMasterGetFullStatusPreparingFrame.DataLength = 8; // Length = 8 Byte
frameMasterGetFullStatusPreparingFrame.IsRemote = 18; // 18 = LIN Frametype "Full Frame"

 

 

 If I understand LIN right, both other "Reading Frames" should be handled in the way that the master sends out the frame header and the AMIS fills in the data bytes. So this should be frames of the type "LIN Header Frame" (isRemote Value 17). So I created them as follows:

 

NCTYPE_CAN_FRAME frameMasterGetFullStatusReadingFrame1;
frameMasterGetFullStatusReadingFrame1.ArbitrationId = 0x7D; // Identifier = 01111101
frameMasterGetFullStatusReadingFrame1.DataLength = 8; // Length of Reading Frame = 8 Byte
frameMasterGetFullStatusReadingFrame1.IsRemote = 17; // 17 = LIN Frametype "LIN Header Frame"

NCTYPE_CAN_FRAME frameMasterGetFullStatusReadingFrame2;
frameMasterGetFullStatusReadingFrame2.ArbitrationId = 0x7D; // Identifier = 01111101
frameMasterGetFullStatusReadingFrame2.DataLength = 8; // Length of Reading Frame = 8 Byte
frameMasterGetFullStatusReadingFrame2.IsRemote = 17; // 17 = LIN Frametype "LIN Header Frame"

 

 Now I send the sequence using the "ncWrite" function like this:

 

NCTYPE_CAN_FRAME frameMasterGetFullStatusPreparingFrame; // Example Frame to be sent

int linError = -1;

// Write the LIN Frame on the Network
linError = ncWrite(*handleTxRx, sizeof(frameMasterGetFullStatusPreparingFrame;);), frameMasterGetFullStatusPreparingFrame;);
if(linError == 0) // Success handling goes here
{
DebugPrintf("> LINInterfaceWriteFrame: Writing on LIN interface successful\n");
}
if(linError > 0) // Warning handling goes here
{
DebugPrintf("> LINInterfaceWriteFrame: Writing on interface has warning [%d]\n", linError);
return AFX_LIN_FAULT;
}
if(linError < 0) // Error handling goes here
{
DebugPrintf("> LINInterfaceWriteFrame: Writing on interface failed with error [%d]\n", linError);
return AFX_LIN_FAULT;
}

linError = ncWaitForState(*handleTxRx, NC_ST_WRITE_SUCCESS, LIN_WRITE_TIMEOUT, 0);
if(linError == 0) // Success handling goes here
{
DebugPrintf("> LINInterfaceWriteFrame: Writing success on LIN interface successful\n");
return AFX_LIN_SUCCESS;
}
if(linError > 0) // Warning handling goes here
{
DebugPrintf("> LINInterfaceWriteFrame: Writing success on interface has warning [%d]\n", linError);
return AFX_LIN_FAULT;
}
else //if(linError < 0) // Error handling goes here
{
DebugPrintf("> LINInterfaceWriteFrame: Writing success on interface failed with error [%d]\n", linError);
return AFX_LIN_FAULT;
}

 

The sequence I use is like this:

1) Send the Preparation Frame (works fine and I can self-receive my frame within the Master)

2) Wait 15ms

3) Send the first Response Frame header (sending works fine but I don't get any data from the AMIS slave)

4) Wait  15ms

5) Send the second Response Frame header (sending works fine but I don't get any data from the AMIS slave)

 

After 1.5s waiting for data I get a "LIN Bus Inactive" Message in my Master's receive buffer.

 

I really don't know why the slave doesn't send any in-frame response to my header. If i unserstand right, the sending of a header by the master and the sending of the requested data by the AMIS slave should together form a "Full Frame" that my master can then read again from the receive buffer or do I misunderstand something?

 

My receiving function is using ncRead() with a check for NC_ST_READ_AVAIL before to see if there is new data available. Could there be a problem with the  NC_ST_READ_AVAIL when waiting for in-frame responses?

 

I hope there aren't too many questions open in this thread. I really appreciate all of your input to get my things working a bit better here.

 

Thank you a lot and best regards,

Bernd

0 Kudos
Message 1 of 4
(7,332 Views)

Hi Bernd,

 

did you already try the LIN example LIN Master Send Header Frame Respond and Receive.c from

C:\Users\Public\Documents\National Instruments\CVI\Samples\nican\LIN\LIN Master Send Header Frame Respond and Receive?

 

Your calling steps seem to be right for me as well as your understanding of LIN (master sends header frame, slave puts in data). 

 

You can find a good description of LIN here: Introduction to the Local Interconnect Network (LIN) Bus

 

One little detail may be the root of your problem:

Did you check if your device uses LIN 2.0 or higher? If so you need to change the checksum mode of your LIN module

before starting the task by calling ncSetAttribute and

change the NC_ATTR_LIN_CHECKSUM_TYPE (LIN Checksum Type) to 1 (Enhanced).

 

 
Best Regards,

 

 

Message Edited by AndreasS on 04-20-2010 03:05 PM
Andreas Stark
LabVIEW Lead @ Rocket Factory Augsburg
0 Kudos
Message 2 of 4
(7,285 Views)

I am having the same type of problem with no response from the slave after writing a status message to my slave.

Although my message NADs are different & I am only trying to read 1 response, it is the same issue.

Did you find a solution to this problem?

0 Kudos
Message 3 of 4
(6,659 Views)

Hi Tangie,

 

did you try changing the LIN mode? If that does not help, please open up a new forum thread or call your local NI Support.

 

Andreas Stark
LabVIEW Lead @ Rocket Factory Augsburg
0 Kudos
Message 4 of 4
(6,651 Views)