Convert serial data to array

Post beginners questions here. Don't be ashamed starting stupid topics.
Ответить
magreent
beginner
beginner
Сообщения: 14
Зарегистрирован: 19 мар 2008, 01:57
Версия LabVIEW: 7.1
Откуда: United States
Контактная информация:

Convert serial data to array

Сообщение magreent »

I am relatively new to Labview and have a question on reading data from a serial port. I have attached the template of my block diagram. The data I get from the buffer is of the form:
3e40e5
3e60e5
3de0e4
3e80e7
3df0e5
3e20e6
3e40e6
3dd0e5
etc
ie hexadecimal data that I can look at with a string indicator on the front panel. I will be getting thousands of data points per run and so my questions are:

1) How do I put this data into a 1D array such that at
the 1st position I have 3e40e5
the 2nd position I have 3e60e5
the 3rd position I have 3de0e4
etc

I will need to manipulate the array data.

2) How do I save this data together with a time stamp so that I can keep track of the exact time that each data-point was taken.
The end result would be to have a 2D array with the following:

time 1 3e40e5
time 2 3e60e5
time 3 3de0e4
time 4 3e80e7
etc..

I am using Labview 7.1
Thanks in advance.
Вложения
Labview Document.pdf
(29.29 КБ) 750 скачиваний
Аватара пользователя
Eugen Graf

Activity Professionalism Silver Black
guru
guru
Сообщения: 6502
Зарегистрирован: 13 ноя 2007, 02:20
Награды: 4
Версия LabVIEW: 2009
Откуда: Saarbrücken
Контактная информация:

Re: Convert serial data to array

Сообщение Eugen Graf »

Hello magreent and welcome here!

1) You have to buffer your received data. So use the Read VISA.VI in a while loop with a shift registrer. So you will get for every reading a new entry in your array, if you will use the Build Array.VI for each reding.

2) if you want to use the PC time stamp, use the Get date/time.VI and then convert the output of it using Get Date/Time String.VI and append this string to your array.

But I think you should convert your binary data to a number, don't you? What can you do with a HEX-Number?

Your issue isn't complex, so no problem to solve it. If you have any questions, so post them.

Regards, eg

P.S. please use no PDFs, you can Copy&Paste your block diagram into MS Paint and save as a PNG-FIle. That is the best for publishing a picture into this forum.
magreent
beginner
beginner
Сообщения: 14
Зарегистрирован: 19 мар 2008, 01:57
Версия LabVIEW: 7.1
Откуда: United States
Контактная информация:

Re: Convert serial data to array

Сообщение magreent »

Thanks for the response. I have attached again the file of the code I am using to get this hexadecimal string. The reason I want it in an array is so that I can convert and manipulate the data later.
Labview-Document.PNG
Thanks
Аватара пользователя
Eugen Graf

Activity Professionalism Silver Black
guru
guru
Сообщения: 6502
Зарегистрирован: 13 ноя 2007, 02:20
Награды: 4
Версия LabVIEW: 2009
Откуда: Saarbrücken
Контактная информация:

Re: Convert serial data to array

Сообщение Eugen Graf »

Try this VI
Вложения
Aray.PNG
Array.vi
(23.05 КБ) 787 скачиваний
magreent
beginner
beginner
Сообщения: 14
Зарегистрирован: 19 мар 2008, 01:57
Версия LabVIEW: 7.1
Откуда: United States
Контактная информация:

Re: Convert serial data to array

Сообщение magreent »

Is there any way you can save this vi so I can open it in Labview 7.1?
Аватара пользователя
Eugen Graf

Activity Professionalism Silver Black
guru
guru
Сообщения: 6502
Зарегистрирован: 13 ноя 2007, 02:20
Награды: 4
Версия LabVIEW: 2009
Откуда: Saarbrücken
Контактная информация:

Re: Convert serial data to array

Сообщение Eugen Graf »

Here for 7.1

Please complete your forum-profile with your LV version.
Вложения
Array7_1.vi
(44.52 КБ) 697 скачиваний
magreent
beginner
beginner
Сообщения: 14
Зарегистрирован: 19 мар 2008, 01:57
Версия LabVIEW: 7.1
Откуда: United States
Контактная информация:

Re: Convert serial data to array

Сообщение magreent »

Thanks for the vi.
It is indeed working.
The last piece that needs to fall into
place is how I can save the array
to a file for each run.
Аватара пользователя
Eugen Graf

Activity Professionalism Silver Black
guru
guru
Сообщения: 6502
Зарегистрирован: 13 ноя 2007, 02:20
Награды: 4
Версия LabVIEW: 2009
Откуда: Saarbrücken
Контактная информация:

Re: Convert serial data to array

Сообщение Eugen Graf »

Use Write To Text File.VI in each iteration.
Вложения
ArraySave.PNG
Array.vi
(61.33 КБ) 667 скачиваний
mulytiwi
interested
interested
Сообщения: 1
Зарегистрирован: 20 май 2014, 14:08
Версия LabVIEW: 2013
Контактная информация:

Re: Convert serial data to array

Сообщение mulytiwi »

Hi Eugen, can you help me, how to convert serial data to array 2D like, for example if data 5x5 from 255000255000255000255000255000255000255000255000255000255000255000255000255 to
255 000 255 000 255
000 255 000 255 000
255 000 255 000 255
000 255 000 255 000
255 000 255 000 255

I'm using LabVIEW 2012.

Thx before
Аватара пользователя
IvanLis

Activity Professionalism Tutorials Gold Man of the year 2012
Автор
guru
guru
Сообщения: 5462
Зарегистрирован: 02 дек 2009, 17:44
Награды: 7
Версия LabVIEW: 2015, 2016
Откуда: СССР
Благодарил (а): 28 раз
Поблагодарили: 86 раз

Re: Convert serial data to array

Сообщение IvanLis »

mulytiwi писал(а):Hi Eugen, can you help me, how to convert serial data to array 2D like, for example if data 5x5 from
1.png
Ответить
  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «For beginners»