Skip to content Skip to navigation Skip to collection information

Connexions

You are here: Home » Content » Programación Gráfica LabVIEW - Cadenas de texto y Ficheros de entrada y salida » VI para leer desde ficheros

Navigation

Recently Viewed

This feature requires Javascript to be enabled.
 

VI para leer desde ficheros

Module by: Juan Martínez. E-mail the author

Based on: File Reader VI by National Instruments

Summary: En este ejercicio, se pretende construir un VI que lea datos desde un fichero. Completar los siguientes pasos para construir un VI que lea el fichero creado previamente y muestre la información leída en un string indicator.

Exercise 1

1.a) Panel Frontal

  1. Abrir un VI en blanco y construir el panel frontal mostrado en la figura 1 usando el control file path situado en la paleta Controls>>Text Controls y un indicador de cadena situado en la paleta Controls>>Text Indicators.
    Figura 1
    Figura 1 (filereader.png)

1.b) Diagrama de Bloques

  1. Construir el diagrama de bloques según se muestra en la figura 2.
    Figura 2
    Figura 2 (filereaderbd.png)
    1. OpenFileIcon.png Colocar en el diagrama de bloques el VI Open/Create/Replace File, situado en la paleta Functions>>All Functions>>File I/O. Este VI muestra una caja de diálogo para abrir o crear un fichero. Hacer clic con el botón derecho en la entrada prompt, seleccionar Create>>Constant en el menú contextual, y escribir Select Filename en la constante. Hacer clic con el botón derecho en la entrada function, seleccionar Create>>Constant en el menú contextual, y hacer clic sobre la constante con la herramienta de operaciones y seleccionar open.
    2. ReadFileIcon.png Colocar en el diagrama de bloques la función Read File, situada en la paleta Functions>>All Functions>>File I/O. Esta función lee un número determinado de bytes (count) desde el fichero comenzando por el principio del fichero.
    3. CloseFileIcon.png Colocar en el diagrama de bloques la función Close File, situada en la paleta Functions>>All Functions>>File I/O. Esta función cierra el fichero.
    4. Error.png Colocar en el diagrama de bloques el VI Simple Error Handler, situado en la paleta Functions>>All Functions>>Time & Dialog. Este VI chequea el cluster de error y muestra una caja de diálogo si ocurre un error.
    5. Completar el diagrama de bloques como se muestra en la figura 2.
  2. Salvar el VI como File Reader.vi en el directorio C:\Exercises\LabVIEW Basics I directory.

1.c) Puesta en marcha del Instrumento Virtual

  1. Mostrar el panel frontal y usar la herramienta de operaciones para hacer clic sobre el botón Browse en el control path.
  2. Navegar hasta demofile.txt y hacer clic en el botón Open or OK button.
  3. Ejecutar el VI. String Read from File muestra el contenido del fichero.
  4. Si se dispone de tiempo, se puede completar el siguiente ejercicio challenge step. Si no salvar y cerrar el VI

1.d) Desafío

  1. Modificar el VI tal que extraiga el valor numérico y lo visualice en un indicador numérico. Una vez finalizado, salvar y cerrar el VI.

    sugerencia:

    Usar la función Match Pattern para buscar el primer carácter numérico

Collection Navigation

Content actions

Download module as:

Add:

Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks