How to periodically send various types of data via the Serial Port?

Hello! Everyone

I have to send data to LabVIEW to my device on the Serial Port.

I know how to send data on serial port in LABVIEW, I already have this part.

Now the problem is that I have several types of data I need to question my embedded device, if I want to send the query periodically command.

So lets say that my four Op Codes are the following, which will send four different types of query command to my device on the serial port.

(To be honest only OP_LED and OP_SENSOR is used now)

0, OP_SYNC

1, OP_LED

2, OP_SENSOR

3, OP_FUTURE

Structure of basic package is as follows:

Header (0x2C), Checksum, length of the data (n bytes), Op_Code (1 byte), length (length of Code + data Op)

For OP_LED, I need to send the package as follows:

0x2c 0x02 0x01 0 x 00 0x2F (0x2F being the XOR checksum) (calculation of Checksum part is done and SUB Vi form)

Length of the package this is 0x02

0x01 is Op Code for OP_LED

In the same way

For OP_SENSORi need to send the package as follows:

0x2c 0x03 0x02 0x00 0 x 00 0x2D (0x2D being the XOR checksum) (calculation of Checksum part is done and SUB Vi form)

0x03 is length of packet here

0x02 is Op Code for OP_SENSOR

So, how can I do this periodically in labview, in such sort that period can be adjusted whenever necessary.

Is there something in LabVIEW to do.

I had done the reception and decoding part and working properly.

http://forums.NI.com/T5/LabVIEW/store-data-coming-from-serial-port-in-buffer-and-then-take/m-p/32722...

So I must implement read and write the part of same while loop?

Do not insert in the table if you put data in an array at index 0.  Just use array to build.

No need to have Visa to write don't be a part of wire to the wire of reference and error VISA go in the upper part.  These wires should go THROUGH the entry VISA.

Don't your checksum requires all the bytes up through data?  Righ now, you only put the checksum on data bytes and forget the opcode and length bytes.

Your sending is not the opcode for Opsync or Opfuture.  You just send the empty tables.  At the same time for the other two, you put the opcode in the data table.  All your original opcode in the table build thread.  Get the data out of these structures in case item which is supposed to represent the opcode.

xpress_embedo wrote:

Now it works but I have now two problems.

(1) OP_SYNC and OP_FUTURE do not data, but still receive its data on serial port, can I do something here as I have nothing when the table is empty in the structure of the case.

I do not understand this statement.  Perhaps my answer above will fix any issue you have here.

(2) how can selection operation Code to be send is done using control façade but real application, this task should be automated to a certain frequency, like OP_LED package must go out to the serial port to 100msec and packet OP_SENSOR must go out to 1000msec, I do this.

Now you agree a little more architecture.  I would encapsulate the code that is in the while loop as a Subvi.  Then with the hand of your program while loop, use two time Express VI, a game for 100 msec, the other for 1000 msec.  When an express VI is true, run the Subvi with a command set waiting for the answer.  When the other VI Express is true, have it run the Subvi with the other set of commands.

The device responds with anything when you send these commands?  You only send data.  I see no VISA Read to be able to recover all the data.

Tags: NI Software

Similar Questions

  • Store data from the Serial Port in the buffer and then take action?

    Hello! Everyone,

    I'm new to LabVIEW and I take assistance from various videos and stuffs available online to get started with LabVIEW.

    But I have a duty, therefore needing help.

    initially I see some of the tutorial videos and learned about the LabVIEW interface, and does a little project to communicate with the Port series (receiving and sending data).

    Happens to my task.

    My LabVIEW application will send a few State request packets on my device or control and based on the response packet that I have to display values.

    The Structure of package is as

    Header, length, Op_Code, data Checksum

    There is no terminator as newline or carriage return or anything else.

    In C language, I read the data from the Serial Port, and based on the length, I conclude that I got the full package or not, and then by recalculating the checksum value, the integrity of the package is verified and then based on that Op-Code has been sent will be decided.

    (I'm dealing with hexadecimal data)

    But how can I do this in LabVIEW.
    A tutorial or any referece will be useful for me.

    1. I suggest that you learn to use Shift Registers instead of local and global variables.  They are much more efficient (memory and execution speed) and make it much easier to read the schema.

    2. you don't need this inside the loop property node.  Is there a way to configure a Serial Port to turn off the stop character.

    3. you don't need to wait for playback VISA will limit the rate of loop if no data is coming.

    4. Once you have the length, you simply read the rest of the entire message and process it at a time.  This will make things a LOT faster.

    5. you should really do this enum a def type so that you can ensure that all your enum constants have the same values.  If you need to add a State later, simply update your enum in the same place then.

  • How to convert string data from the serial port to double?

    Hello!

    I am very new in LabView and attempt to read data from an OHAUS pioneer pa-313 electronic scale via RS232 serial port. I use the VISA. I can read the data and see it as a string to the screen, but when I try to convert it to a double, it is just the integer and decimal numbers have disappeared. Here's the question: what can be the problem? How can I get the decimals as well?

    What is your normal decimal point?. or?

  • Send and receive data via the Ethernet Port?

    Hello

    I am trying to acquire details of LAN/Ethernet from the PC through LabVIEW.Like details, we get the date & time, etc Serial Port system, is it possible to get the details of my PC via LabVIEW.My LAN aims to sebd and Receive via Ethernet Port command.

    The last time I did it, I used the range of tcp. (I go ctrl + space for quick menu then type tcp). Open a connection to the network device, and then use tcp read/write, depending on the case. There are examples that can be very useful

  • How to transfer files from PC to PC via a serial port using labview

    I need to transfer files (.txt, .doc, .xls) from PC to PC via a serial port using LabVIEW. Is it possible to transfer files, if so how to transfer?

    Yes, it is possible to transfer files with the serial port using LabVIEW.  The files are just collections of bytes and the serial port is good enough in the expedition of the bytes from one PC to another.  You must connect the ports series with a null modem cable.

    First, take a look at the example of serial communication.   In LabVIEW, go to the Help menu and select «Find examples...» ».  From there, you can search for "serial" or navigate to hardware input and output > series.  Select «Write series base» and Read.vi  Try this example to gain confidence on the serial communication methods.

    Then it's time to learn how to read and write files.  For this, the examples might be somewhat confusing as they deal with files that are presumed to have data of a specific type in them.  I would recommend just familiarize yourself with the functions in the file e/s palette.  Specifically, familiarize yourself with the following functions.

    1. Open/create/replace file - on the side of your destination, you will need to create the copy of the file you are trying to transfer
    2. Close the file - when you're done reading or writing to a file, you must close it.  It cleans the memory used and finalizes write operations that are still floating in the write buffer.
    3. Read a binary file - is the best way to play a file when you don't really like what type of file it.  In your case, you just want to get these read bytes and sent so they can be written down instead of destination.
    4. Write to a binary file - next to the destination, is what will store the bytes in the file that you created with the number 1.
    5. Size of the file get (under the range of the advanced features of file) - you need to know how big the file is, so you know when you are finished.

    OK, so once you are able to create files byte write and read bytes from existing files, you can move forward.

    I suggest the basic method is to have the user specify a source file on the source PC, and a folder on the destination computer.  Then find the size of the source file using the number 5.  Divide this number of size by the number of bytes that you want to transfer to the times.  The series pads are usually around 32 k (if I remember correctly) in order not to exceed that.  Now start to send data by reading a number of bytes and this string output wiring to the feature of writing VISAS.  On the side of destination, you will want to monitor the serial port for bytes and read when they arrive.  This string of yarn to the writing of the function of binary file to add them to your destination file.

    This is the basic outline of how to do it.  He needs to not to overload him write and read buffers on the serial ports.  Initially, you can use delays on the side sending to make sure that the side reading has enough time to digest.  To make things faster, you can bring in a control of flow.

    If all that sounds a little intimidating, there are there Alliance member companies (such as the automation of PrimeTest) who can write this code for you and even provides a turnkey for you solution.

    Happy wiring,

    Dan press

    Certified LabVIEW Architect

    PrimeTest Automation

  • How to create a stop button to send commands via the serial port and finish labview vi?

    I want to send two commands on my camera, the first to stop the execution and the second to get out of the remote control mode. This is done on RS232. What I want is a way to put this in my existing VI that tells the device to run. Now if I stop the program, that the devices just run the last command unless I have stop manually. How can I set up a stop button that are not sent to all orders except in such a hurry? I tried the structure of the case, but didn't know how to put a part of 'status quo' If island stops in the while loop is not pressed the button.


  • How can I install Firefox on Samsung S5 via the usb port on my PC

    You don't have a Google account - don't want no one. Want to just Firefox. How can I install via the PC's USB port. I have the developer options enabled.

    You can use the Aurora of Firefox for Android version. https://www.Mozilla.org/en-us/Firefox/channel/#developer

  • Sending data through the serial port and the mscomm control is not the same as the original data

    Please find attached the mscomSerialWrite2.vi and the resulting image.

    Try it and find that when data "FFAE" 4040 EA41 D8FF is sent,

    the received data are "FFAE" 4040 EA41 3F

    I tried other data, the result is as follows:

    sending: 4164 8163 4341 03 receive: 41 64 81 63 43 41 03 leadK
    sending: A143 B245 6AAA BBCC receive: AA BB 00 A1 B2 45 6a 43 result: NG
    sending: AAAA AAAA AAAA AAAA AAAA AAAA receive: result AA AA AA AA AA AA AA AA AA AA AA AA K
    sending: A1A1 A1A1 A1A1 A1A1 A1A1 receive: result A1 A1 A1 A1 A1 A1 A1 A1 A1 A1K
    Send: FFAE 4040 EA41 D8FF receive: FF AE 40 40 41 EA 3F result: NG
    Send: FFAE 4040 EA41 D8FF AA23 AB33 A233 AAAA A404 ABCD A2CD A22D B22C receive: FF AE 40 40 41 EA 3F 3F 3F 3F AA AA AB CD A2 CD result 3F 3F 3F: NG
    Send: FFAE 40A 2 SDAC AETS receive: result FF AE 40 A2 CC DD EE 00: NG

    Please help me solve the problem.

    According to Microsoft, you want something with non-printable strings as an array of bytes, not a string.  I don't know that it will make a difference in this case, but may be worth a try.

  • How to connect Agilent 8163 b via the serial port

    I have a problem connecting to the serial port with Agilent 8163 b. The driver that I use is driver_vxipnp_816x_4_1_4.exe. The problem always message display "Visa resource not found. Check the HPIB-Bus address"when I use the components inside the"hp816x tree.vi ". However, I have no error if I use normal read and write VISA.

    Y does it can someone help me answer my question? Thanks in advance.

    Thanks for the reply.

    I face a problem that you use with GPIB-USB-HS due to the physical dimension, as shown. The width between the remote locking connector (FIR) and (w1) GPIB connector to the appliance is too small for the GPIB-USB-HS (w2) connect to this topic. If I unplug the connector RIL, tunable Laser will not be activated. So I have a few questions as follows.

    1. the LabView can always activate the tunable Laser if I unplug the connector at RISK in my case via GPIB?

    2. the LabView is compatible with GPIB connector (model x 10833) Agilent?

    3. is there a way to solve the problem posed by the RIL connector unplugged?

    The drop box

    P/S: version please is 4.84 to 8163 b.

    Thanks for the help and I'm too new in this field.

  • How can insert different types of data in the table?

    Hello
    How can I insert different types of data in the table, (e.g., numeric and string) in the same index of a table.

    example:
    index0 car 10 green

    car red 11 index1
    Index2 car Blue 12

    where green car red and blue car as string and 10, 11 and 12 in the numeric form.
    then I extracted 10, 11 and 12 a digital table

    and, the green car, red car, blue car in a string array

    Help!

    Use 'Analysis of the chain' as in the picture as an attachment.  This will extract the number and color that you can add tables later.

  • How to set the number of packages to be send per second on the serial port in labview

    Hello.

    I need to send data to the serial port such that each data packet must be sent at a rate of 4 packets per second? How can it be done?

    Thanks and greetings

    What defines a package?

    You just need to have a while loop with a timer waiting for 250 milliseconds surrounding your VISA writing the function.

  • 2 ways to send 16-bit to the serial port. What is the good?

    I am trying to send data via a serial port... This data consists of a 16-bit format. The data are sent by a DSP. Searching in the internet I found two ways to send data. The first is that the first photo anda the second way is the second picture.  I read data ok, which in this case is a sine wave. But I 'don't know if it is correct or not.

    In the first case , the citation read buffer sende th 8-bit to decimate them VI that will be concatenated after to join numbers function...

    Is it fair or not?   Second question. I noticed when I put multiples of 8 in the number of bytes the graph is ok. But when the number is not a multiple is the graph 'missing pieces '.  Why?

    In the second case, I confess I didn't undertood it. I know that the CASTING of TYPE function transforms the string on a table swap bytes (DSP sends the MSB and LSB) I know what subset of string.  I read that the 4 in the offset is put there to avoid the reading of the data header. But I don't know why 2048 is here. The latter reads data too...

    With any who answer my questions would be a really really help

    Thank you guys.

    First case

    second case

    Both are probably correct for the data being sent.

    If you want to read a unique 16-bit value at a time, then obviously you would set the number of bytes to read to be 2. The following code shows two ways to convert the two bytes to a single value. The chain Unflatten to specify the boutien.

    You don't mention her, but how do you synchronize the data. With the dsp to send two separate bytes, not sure what byte you will read first. Do you send start/stop characters so that you know this vital information?

  • When I send a text message and mobile data are off, it is not given, but I do not see this message for a few minutes. I can then refer using "send as a text message. How can I 'send as a text message' in the first place?

    When I send a text message and mobile data are off, it is not given, but I do not see this message for a few minutes. I can then refer using "send as a text message. How can I 'send as a text message' in the first place?

    Disable the iMessage?

  • How to save data from the COM port to file?

    Hi all

    can someone tell me please how to save data from the COM port on file? I transfer 1 byte of serial port... attached is the image of the vi... very basic.

    I would like to save the data in a table... I mean, 1 data--> data--> data tab 2 tab 3rd--> tab

    and so on... can anyone help?


  • In the attached VI why looping force the type of data while the other does not?

    In the attached VI why looping force the type of data while the other does not?

    I'm guessing that you have created the Enum on the front panel.  If you right click and create an indicator, it corresponds to the type and be an enum.  LabVIEW represents enums as U16, but because the types are not the same (for example, your enum has 3 values, but a U16's 65 536 values), LabVIEW automatically converts value (or converts) the smallest representation (enum) in the largest value (U16).

Maybe you are looking for

  • Where is the frigin toolbar in firefox mobile?

    How can you us HELLO on their cell phones if the stupid button cannot be installed?Very frustrating.DON

  • I have reactivated the plugin every time

    Hello I have 2 PC. Problem with PC 1Whenever I boot firefox I must disable and then enable again Extension to make it work. If I don't do this, then the Extension will appear as activate but it won't work. It will display turn on but will not work un

  • Wireless for Windows Vista PC

    It is a great resource to learn more about the software and hardware of computers... After reading a lot of help and answers questions: is it really worth buying a wireless card, check if the modem accepts the card wireless PC and MS download, the so

  • Still boring stuck 0.8 Ghz with docking station

    If I put my W520 in sleep mode, put in my docking station and run it, it is still stuck at 0, 8 GHz! Same throttlestop will not work! take it and on the dock during the race makes no difference. Oh well, there is a difference: as it is off the COAST

  • event structure and while loop iteration

    Hello It took me time to identify the problem I have, but I think I've nailed it and need help to solve. I am right to say that a while loop that contains a structure of the event will travel only once and then wait for another event to occur before