LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Input byte data to write serial command vi

Hi community, 

 

i’m wanting to implement a syringe pump SPM-200 which uses trimac motion control stepper motor TMCM-1021. This particular motor only receive byte data communication via RS485. I’ve tried to convert my test values to byte data array and use the byte to string array function to send it into write serial command to vi however the communication was not establish. Is there anyone out there with similar experiences that can lend a helping hand or someone who knows how to input byte data for serial commands? Would greatly appreciate any help because I’m stuck on this for a week now. 

 

Many thanks, 

Jarrold

0 Kudos
Message 1 of 10
(1,657 Views)

Hi Jarrold,

 

what is the manual of your motor telling you about the expected data format?

How are you providing your control data?

 

RS485 should be handled by VISA (it's a serial communication): VISA expects a string, which is just a byte array in the end…

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 2 of 10
(1,650 Views)

Hi GerdW,

 

The manual is asking me to input the commands in binary format and i've been simulating it with a byte array control with values of required attached in the picture. Basically, Bit 1 is the address bit, 2/3/4 bytes are settings, 4 bytes for values and last byte is a checksum. I've purely wrote it to the Write serial command vi after setting visa config at baud rate of 9600 and using visa com port as attach in the picture. But it wouldnt even start the motor, thats why i'm perplex as im not sure if im sending the write data format for the commands needed. Am i doing this right? Sorry i'm pretty new at this serial command function in labview. 

 

Thank you, 

Jarrold 

Download All
0 Kudos
Message 3 of 10
(1,617 Views)

Hi Jarrold,

 

which data do you send to your motor?

Did you use the correct checksum?

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 4 of 10
(1,614 Views)

You should probably disable the termination character on the Serial Configure.  Does the device send a response?  Since you are sending binary data, it would probably respond with binary and a termination character would cause the response to end early if the it happened to be a part of the data stream.

 

Are you sure your checksum is correct?  Are you data bits, stop bits, and parity correct?

 

Have you communicated with it using any software they provided to make sure the communication stream is correct?

0 Kudos
Message 5 of 10
(1,612 Views)

Hi GerdW and RavensFan,

 

I've tried your suggestions but still to no avail. The VI i attached is what i've done and logically it should be right. However, i'm only able to write the command to the device but i can't read a reply. Below is my VI and could you please help me check if i'm missing out anything? 

 

@GerdW i've tried using only the manufacturers software and it could work there however, when i downloaded a software called TMCL - IDE, it couldnt set up a connection with the device itself at all even though it's suppose to. 

 

The is one of the instruction for the binary communication format and from what i'm seeing its the same as output to my vi. A timeout of the read vi has been stopping my program and i'm not sure if its taking too long to read from the device as its baud rate is suppose to be at 9600. I've research and think its should be okay to read 9 bytes in 9600 baud rate but i'm not sure. 

Download All
0 Kudos
Message 6 of 10
(1,586 Views)

Hi Jarrold,

 

why do you use InsertIntoArray when you want to build an array?

check.png

Your "Control 4 Bytes" doesn't fit to the ROR description in your manual snippet.

 

A timeout of the read vi has been stopping my program and i'm not sure if its taking too long to read from the device as its baud rate is suppose to be at 9600

The timeout occurs because you don't receive an answer from your device (most probably)…

Reading 9 bytes at 9600baud just takes ~10ms.

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 7 of 10
(1,580 Views)

Hi GerdW,

 

I didn’t notice that inserting into an array is different from building one. I thought both output would be an array so it wouldn’t matter. 

 

The control bytes should be at 01 01 00 00 + 4 bytes value + checksum for ROR instruction to address 1 right? (Just checking if I’m understanding the snippet wrongly)

 

If yes, I did tried that instruction but it still didn’t receive a reply 😞 

 

i was suspecting maybe the baud rate differs from device and host but I can’t seem to establish a connection and I’m lost. Is there any other info I can provide you so it might be helpful? 

 

Best regards,

Jarrold

0 Kudos
Message 8 of 10
(1,565 Views)

@Jarrold wrote:

Hi GerdW,

 

I didn’t notice that inserting into an array is different from building one. I thought both output would be an array so it wouldn’t matter. 



Yes they both output an array.  But 99% of the time you probably need Build Array.  The other 1% of the time would be Insert Into Array.  That's because 99% of the time you are putting elements at the beginning or end of the array.  It is much easier to do that with Build Array then doing all the extra work you need to do to figure out where the end of the array is so you can "Insert" it there.

 

Are you sure your checksum is correct?  It looks like you are just summing the bytes.  That may be fine, but many checksum protocols are much more complicated than that.  What does the manual say?

0 Kudos
Message 9 of 10
(1,553 Views)

Hi RavensFan,

 

Thank you for the insights, i'll change the insert array to build array. 

 

For the checksum it is stated that it is the sum of all the other bytes using 8-bit addition. 

With that said, say our velocity is 10000, the send command should be 01 01 00 00 00 00 27 10 39 which is the same as the example given in the manual when

Module address: 1

Instruction: 1

Type: 0 

Motor : 0

Value: 10000 (00 00 27 10)

Checksum: 39

 

 

0 Kudos
Message 10 of 10
(1,533 Views)