Read 5 ADC Values Via Rs232

VISA; TCP/IP, CAN and similar protocols
Аватара пользователя
mzu2006

Professionalism Tutorials Black
doctor
doctor
Сообщения: 2456
Зарегистрирован: 16 авг 2008, 02:12
Награды: 3
Версия LabVIEW: 7.1 10 11 12
Откуда: St-Petersburg (RU), Phila, Boston, Washington DC
Контактная информация:

Re: Read 5 ADC Values Via Rs232

Сообщение mzu2006 »

RMB on the text indicator -> and check "\" codes display and show what the indicator will display now.
exodia505
beginner
beginner
Сообщения: 10
Зарегистрирован: 10 апр 2012, 15:16
Версия LabVIEW: 8.5
Контактная информация:

Re: Read 5 ADC Values Via Rs232

Сообщение exodia505 »

i think you have my board ,plz help me !!!
exodia505
beginner
beginner
Сообщения: 10
Зарегистрирован: 10 апр 2012, 15:16
Версия LabVIEW: 8.5
Контактная информация:

Re: Read 5 ADC Values Via Rs232

Сообщение exodia505 »

:shok:
Аватара пользователя
mzu2006

Professionalism Tutorials Black
doctor
doctor
Сообщения: 2456
Зарегистрирован: 16 авг 2008, 02:12
Награды: 3
Версия LabVIEW: 7.1 10 11 12
Откуда: St-Petersburg (RU), Phila, Boston, Washington DC
Контактная информация:

Re: Read 5 ADC Values Via Rs232

Сообщение mzu2006 »

I can not help you unless you explain your problem consistently and follow the advice. Please, enable "\" codes and show me the result.
asmahamdaoui
interested
interested
Сообщения: 5
Зарегистрирован: 25 июл 2013, 18:58
Версия LabVIEW: 2012
Контактная информация:

Re: Read 5 ADC Values Via Rs232

Сообщение asmahamdaoui »

i have the same problem what is the solution please :help:
Аватара пользователя
dadreamer

Activity Professionalism Автор
professor
professor
Сообщения: 3926
Зарегистрирован: 17 фев 2013, 16:33
Награды: 4
Версия LabVIEW: 2.5 — 2022
Благодарил (а): 11 раз
Поблагодарили: 126 раз
Контактная информация:

Re: Read 5 ADC Values Via Rs232

Сообщение dadreamer »

asmahamdaoui, which problem do you have? You can not separate data received from device via RS232?
asmahamdaoui
interested
interested
Сообщения: 5
Зарегистрирован: 25 июл 2013, 18:58
Версия LabVIEW: 2012
Контактная информация:

Re: Read 5 ADC Values Via Rs232

Сообщение asmahamdaoui »

yes i need to separate 14 temperature value
Аватара пользователя
dadreamer

Activity Professionalism Автор
professor
professor
Сообщения: 3926
Зарегистрирован: 17 фев 2013, 16:33
Награды: 4
Версия LabVIEW: 2.5 — 2022
Благодарил (а): 11 раз
Поблагодарили: 126 раз
Контактная информация:

Re: Read 5 ADC Values Via Rs232

Сообщение dadreamer »

asmahamdaoui, how do you send data from the device? Show your printf(); commands and text you have received in :labview: . Did you try what mzu2006 suggests here?
asmahamdaoui
interested
interested
Сообщения: 5
Зарегистрирован: 25 июл 2013, 18:58
Версия LabVIEW: 2012
Контактная информация:

Re: Read 5 ADC Values Via Rs232

Сообщение asmahamdaoui »

printf("%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f\n\r",val0,val1,val2,val3,val4,val5,val6,val7,val8,val9,val10,val11,val12,val13);

I enable "\" codes and the indicator show : 137.09131.23137.09131.23137.09137.09137.09\s41.78137.09\s\s0.00137.09137.09\s\s0.00\s\s0.21\n
Аватара пользователя
dadreamer

Activity Professionalism Автор
professor
professor
Сообщения: 3926
Зарегистрирован: 17 фев 2013, 16:33
Награды: 4
Версия LabVIEW: 2.5 — 2022
Благодарил (а): 11 раз
Поблагодарили: 126 раз
Контактная информация:

Re: Read 5 ADC Values Via Rs232

Сообщение dadreamer »

There's something strange with your indicator, because I tried this format of printf and the result is different from yours. I've tested DbgPrintf and LStrPrintf functions, they work like their C/C++ analogs, but are intended to work in :labview: . So, when I'm doing
LStrPrintf(LStrHandle DestStr, CStr fmt, double val1, double val2, double val3, double arg4, double arg5, double arg6, double arg7, double arg8, double arg9, double arg10, double arg11, double arg12, double arg13, double arg14);
with
fmt = "%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f\n\r"
and
val1 ... val14 = 1 ... 14
I'm getting
DestStr = " 1,00 2,00 3,00 4,00 5,00 6,00 7,00 8,00 9,00 10,00 11,00 12,00 13,00 14,00"
or in "\" codes
"\s\s1,00\s\s2,00\s\s3,00\s\s4,00\s\s5,00\s\s6,00\s\s7,00\s\s8,00\s\s9,00\s10,00\s11,00\s12,00\s13,00\s14,00\r\n\r".
As you can see, each number is separated from each other with \s\s symbols. Then I'm scanning DestStr with Scan From String :vi: by giving format string input equal to "%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f%6.2f". The format is identical to initial format (fmt) but doesn't have \n\r at the end. After running this program I get my 14 numbers (1 ... 14) as outputs. You also can try Scan From String with your initial format, it should work allright. If it won't, you may separate numbers from each other by \n\r and try Scan From String with this new format again. Look at attached example.
Вложения
Strings.vi
LV2011
(13.23 КБ) 284 скачивания
asmahamdaoui
interested
interested
Сообщения: 5
Зарегистрирован: 25 июл 2013, 18:58
Версия LabVIEW: 2012
Контактная информация:

Re: Read 5 ADC Values Via Rs232

Сообщение asmahamdaoui »

I'm so grateful for your help :)
my project is to realize a temperature acquisition card based in a 16F887 microcontroller,and controlled by labview i m using the ccs compiler it doesn't know this two functions DbgPrintf and LStrPrintf so I used the "Search/Split String" but sometime it works well sometimes did not you will found tne ccs file , isis circuit and the vi in joint piece
Вложения
1 - Serial Read.vi
(41.19 КБ) 302 скачивания
semlab5.c
(4.11 КБ) 282 скачивания
Аватара пользователя
dadreamer

Activity Professionalism Автор
professor
professor
Сообщения: 3926
Зарегистрирован: 17 фев 2013, 16:33
Награды: 4
Версия LabVIEW: 2.5 — 2022
Благодарил (а): 11 раз
Поблагодарили: 126 раз
Контактная информация:

Re: Read 5 ADC Values Via Rs232

Сообщение dadreamer »

asmahamdaoui, why do you use such complex code in your vi? You don't need a lot of "Search/Split String" instruments, one "Scan From String" :vi: is enough to do all the work (look again at my example). On your microcontroller you should use conventional printf as you do now. So, everything is ok in semlab5.c. But in 1 - Serial Read.vi you firstly should simplify string parsing with appropriate vi's, for instance "Scan From String" or regular expressions etc. Secondly, you read COM-port data incorrectly: each time 84 bytes. The string may be longer or shorter than 84 bytes. When parsing such string, that does not match 84 bytes, you'll get an error or wrong temperature values. I suggest you this way of data acquisition:

Изображение

In While Loop you're checking if COM-port has new data in it. If there is new data, you read it entirely with VISA Read and bytes amount. Acquisition frequency may be changed as you wish. When string is obtained, it may be parsed with some algorithm and resulting useful values can be displayed at Graph or indicators.

P.S.: DbgPrintf and LStrPrintf functions are just an illustration of printf command in :labview: . There's no need to use them anywhere in your project.
Последний раз редактировалось dadreamer 01 мар 2017, 08:12, всего редактировалось 1 раз.
asmahamdaoui
interested
interested
Сообщения: 5
Зарегистрирован: 25 июл 2013, 18:58
Версия LabVIEW: 2012
Контактная информация:

Re: Read 5 ADC Values Via Rs232

Сообщение asmahamdaoui »

good morning,
I have always a synchronization problem with my application between labview and isis :( the running interrupts when it receives a wrong string(my string contains 84 character )
help please
Вложения
semlab17.vi
(32.37 КБ) 289 скачиваний
semlab17.rar
(35.81 КБ) 293 скачивания
semlab17.c
(3.62 КБ) 272 скачивания
Аватара пользователя
dadreamer

Activity Professionalism Автор
professor
professor
Сообщения: 3926
Зарегистрирован: 17 фев 2013, 16:33
Награды: 4
Версия LabVIEW: 2.5 — 2022
Благодарил (а): 11 раз
Поблагодарили: 126 раз
Контактная информация:

Re: Read 5 ADC Values Via Rs232

Сообщение dadreamer »

asmahamdaoui

Well, you may check string length and if it equals 84 bytes you can do further processing. Also it's good to test each byte of string if it represents a symbol you expect (numeric symbols 0 to 9, carriage return, line feed). If the byte being tested doesn't meet your requirements you can display error message or cut the symbol from the string or do nothing (empty Case structure, for instance).
Ответить

Вернуться в «Communcation with devices»