LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling DLL in LabVIEW

Solved!
Go to solution

No I can't since you have not included all the information that is necessary!

 

First your post does not show what CANMSGINFO is supposed to be!

Second, after I know what CANMSGINFO is I can create you a cluster that resembles this structure, but how to pass it to the function will depend on what the function expects so you have to provode the prototype for the API function too. A cluster is not a function call, just as the structure data definition won't do anything on its own in a C program either.

Rolf Kalbermatter
My Blog
0 Kudos
Message 31 of 41
(1,302 Views)

Ok i understand your meaning.So is better to send you the datasheet of the USB To CAN we are have and the program in Labview we have create.The real problem is that

 in my program i want to take samples every 1 sec and when i am putting in my for Loop 1 sec delay the pogram is not working properly.When i move the sensors(we have two sensors which transpose the distance to voltage 0-5 volt output) vertical or horizontal i am always reading the same voltage value which is wrong because if the distane is changed also the voltage change as well.If i delete this  remove the delay  the program working as is should be but it takes measurement very fast and that is not helping us to evaluate the sensors. So after reading the datasheet in pages 24-98-99 says its says how to fixed the delay time between messages in the bus that why i told youowbeggining how i can create this code in labview with DLL.Any suggestions ideas what is going wrong and how to fixed it?Below you can see the Vi i have created. Below the program i have create i labview.I also try to posted the program and the datasheet but the website is not letting me to do that ,how can i send them to you?

0 Kudos
Message 32 of 41
(1,298 Views)
0 Kudos
Message 33 of 41
(1,290 Views)

Wouldn't it be better if you created your own thread, rather than hijacking two different threads? The other thread: http://forums.ni.com/t5/LabVIEW/Convert-binary-data-to-decimal-in-CAN-XNET/td-p/1755132

0 Kudos
Message 34 of 41
(1,286 Views)

yes but i open a subject (http://forums.ni.com/t5/LabVIEW/ADC-for-IXXAT-USB-to-CAN-compact/m-p/1942625/highlight/true#M647144 ) as you mention and i didn't get any usefull reply by no one,so i try to find some similars problems with mine and to post my problem there 

0 Kudos
Message 35 of 41
(1,282 Views)

@gtathatos wrote:

yes but i open a subject (http://forums.ni.com/t5/LabVIEW/ADC-for-IXXAT-USB-to-CAN-compact/m-p/1942625/highlight/true#M647144 ) as you mention and i didn't get any usefull reply by no one,so i try to find some similars problems with mine and to post my problem there 


You did get a reply asking you for information, and some code. Instead of following up you decided to hijack two other threads.

0 Kudos
Message 36 of 41
(1,280 Views)

Ok no problem i will stay to this subject and never the less this is not the main issue now,the issue is if the problem i am having can be solve.Can you suggest a solution?

0 Kudos
Message 37 of 41
(1,278 Views)

Rolfk here are some information about what you asked.I am still trying to post the datasheet but is not letting me to do that.Above i also posted the program i have create.

 

CANMSGINFO

The data type summarizes various information on CAN messages in a 32-bit val-ue. The value can be addressed either byte-wise or via individual bit fields.

typedef union { struct { UINT8 bType; UINT8 bReserved; UINT8 bFlags; UINT8 bAccept; } Bytes; struct { UINT32 type: 8; UINT32 res : 8; UINT32 dlc : 4; UINT32 ovr : 1; UINT32 srr : 1; UINT32 rtr : 1; UINT32 ext : 1; UINT32 afc : 8; } Bits; } CANMSGINFO, *PCANMSGINFO;

The information of a CAN message can be addressed byte-wise via the element Bytes. The following fields are defined for this:

Bytes.bType: [in/out] Type of the message. See also Bits.type.

Bytes.bReserved: Reserved. See also Bits.res.

Bytes.bFlags [in/out] Various flags. See also Bits.dlc, Bits.ovr, Bits.srr, Bits.rtr and Bits.ext.

Bytes.bAccept: [out] With receive messages displays which filter has accepted the message. See also Bits.afc.

 

The information of a CAN message can be accessed bit-wise with the element Bits. The following bit fields are defined:

Bits.type: [in/out] Type of the message. The types listed in the following are defined for receive messages. For transmit messages, only the message type CAN_MSGTYPE_DATA is currently defined. Other values are not permitted here

CAN_MSGTYPE_DATA: Normal message. All regular receive messages are of this type. The field CANMSG.dwMsgId contains the ID of the message, the field CANMSG.dwTime the time of reception. The fields CANMSG.abData contain according to length (see Bits.dlc) the data bytes of the message. With transmit messages the IDs are to be entered in the field CANMSG.dwMsgId and the data bytes according to length in the fields CANMSG.abData. The field CANMSG.dwTime is normally set to 0, unless the message is to be transmitted with a delay. In this case the de-lay time is to be specified in ticks. See also the description of the structure CANMSG, or sec-tion 3.1.3.3.

 

CAN_MSGTYPE_INFO: Information message. This message type is entered in the receive buffers of all activated message channels with certain events or with changes to the status of the controller. The field CANMSG.dwMsgId of the message always has the value 0xFFFFFFFF. The field ab CANMSG.Data[0] contains one of the following values:

Constant

Meaning

CAN_INFO_START

The CAN controller was started. The field CANMSG.dwTime contains the relative start time (nor-mally 0).

CAN_INFO_STOP

The CAN controller was stopped. The field CANMSG.dwTime contains the value 0.

CAN_INFO_RESET

The CAN controller was reset. The field CANMSG.dwTime contains the value 0.

 

 

CANMSG

The data type describes the structure of a CAN message telegram.

typedef struct { UINT32 dwTime; UINT32 dwMsgId; CANMSGINFO uMsgInfo; UINT8 abData[8]; } CANMSG, *PCANMSG;

dwTime: [in/out] With receive messages, this field contains the relative reception time of the message in ticks. The resolution of a tick can be calculated from the fields dwClockFreq and dwTscDivisor of the structure CANCAPABILITIES in accor-dance with the following formula:

 

Resolution [s] = dwTscDivisor / dwClockFreq

An overrun of the 32-Bit dwTime value is received with a Timer Overrun messages ( CAN_MSGTYPE_TIMEOVR $5.2.5).With transmit messages, the field defines with how many ticks delay the mes-sage is to be transmitted to the bus. The delay time between the last message transmitted and the new message can be calculated with the fields dwClock-Freq and dwDtxDivisor of the structure CANCAPABILITIES in accordance with the following formula.

delay time [s] = (dwDtxDivisor / dwClockFreq) * dwTime

The maximum possible delay time is defined by the field dwDtxMaxTicks of the structure CANCAPABILITIES.

dwMsgId: [in/out] CAN ID of the message in Intel format (right-aligned) without RTR bit.

uMsgInfo: [in/out] Bit field with information on the message type. A description of the bit field is given in section 5.2.5.

abData: [in/out] Array for up to 8 data bytes. The number of valid data bytes is defined by the field uMsgInfo.Bits.dlc.

0 Kudos
Message 38 of 41
(1,273 Views)

Well all you will then need to do to create the "code" that resembles this C typedef is to create a cluster that contains 3 uInt32 and 8 uInt8 in that order

 

Of course this is probably not what you wanted to know, but to get more you need to learn to ask a meaningful question and read the responses that ask for more specific information.

 

Your other question that was linked to by smercurio did not receive any meaningful response because it was equally unclear. You talk about how to use an ADC over your CAN interface. If you really mean that then only the person seeing the schematic diagram can actually make meaningful comments to that. More likely you just want to know how to interprete the values that you would receive over the CAN interface but even that is not really possible to answer without quite a bit more information from your side such as what you actually receive over the interface and what type of ADC and whatever. As it looks to me so far, you are tasked with a project that you lack both in hardware and software knowledge to really be able to handle it. Otherwise your description would be more clear and helpful to help us help you.

Rolf Kalbermatter
My Blog
0 Kudos
Message 39 of 41
(1,264 Views)

Ok, I will try to explain as simple as I can the state of my problem.

 

We have two sensors connected to a PCB, these sensors are measuring the distance between the sensors and a metal plate and transpose-convert this distance to voltage. According to the datasheet for example 30,00 mm are equal 0 voltage and 100,00 mm are equal to 5 voltage, the step is 0,07V/mm. This voltage is converted into digital (ADC) through software the PCB has and through the CAN Bus we are reading the values of the sensors.

The communication with the PCB is made via a USB to CAN compact from IXXAT, we have create the LabView drivers for the device according to the datasheet of the company. The first problem we encountered was:

 

1. From the CAN Bus we are reading the values of the sensors which are 8 bytes. The problem we had in the beginning was that we could not do the conversion of the data to voltage. This problem is now solved, I spoke with our software Department they told me which byte is the MSB which is the LSB of the 8 bytes for each sensor and after that I was able to convert these values to voltage. For sensor 1 Byte 0 is the LSB and Byte 1 is the MSB. For sensor 2 the byte 2 is the LSB and Byte 3 is the MSB. For the conversion I read the data in HEX I transpose them to decimal, after that I divide them by 1024 and multiply by 5 and now is working perfectly. The CAN message we are reading can be seen in the picture Can message.

 

Can message.gif

 

2.  However another problem has occured.In the program we have create we would like to take sample every 1 sec or to be able to change the sampling time. When i am inserting a delay of 1 sec into my For Loop the program does not working properly. When I move the sensors vertical or horizontal in relation with the metal plate (the metal plate is stable in the same position only the sensors are moving) I am always reading the same voltage value which is wrong because if the distance also the voltage would be changed. If I remove this delay from the For Loop delay the program working as is should be but it takes measurement very fast and that is not helping us to evaluate our sensors. Any suggestions ideas what is going wrong and how to fix it?

In the attachment files you can find the Vi we have create, the LabView drivers for USB to CAN device and the datasheet of the device. I hope this would help you to understand more about the problem we have

0 Kudos
Message 40 of 41
(1,251 Views)