en tiempo real de transmisión y recepción a través de ethernet.docx

15
En tiempo real de transmisión y recepción a través de Ethernet Comunicarse entre dos modelos de Simulink Real-Time ™ a través de Ethernet. Este ejemplo muestra cómo utilizar los bloques en la biblioteca xpcethernetlib para la comunicación entre dos equipos de destino a través de Ethernet. Los datos de la señal es enviada por el modelo transmisor, xpcEnetDemo1Tx , que se ejecuta en un equipo de destino, TargetPC1, al modelo de receptor, xpcEnetDemo1Rx , se ejecuta en el segundo equipo de destino, TargetPC2.Los bloques en xpcethernetlib permiten Ethernet "en bruto" en tiempo real IO. Requerimientos Para ejecutar este ejemplo, tendrá dos equipos de destino, cada uno con un instalado y configurado dedicada tarjeta Ethernet (además de la tarjeta Ethernet utilizado para el enlace Ethernet entre los equipos de desarrollo y de destino). Consulte la documentación en tiempo real Simulink en comunicaciones Ethernet basados en modelos para obtener más detalles. Una vez configurado, establecer el bus PCI y ranura en el bloque "Ethernet Init" de xpcEnetDemo1Tx y xpcEnetDemo1Rx a la de la tarjeta Ethernet instalada en TargetPC1 y TargetPC2 respectivamente. Abierto, Construir, y descargar el modelo de Tx a TargetPC1 Haga clic aquí para abrir el modelo Tx: xpcEnetDemo1Tx . Este modelo lleva un oscilador con una señal de onda cuadrada y envía las señales de salida de entrada del oscilador y para el equipo de destino Rx usando prima Ethernet. open_system ('xpcEnetDemo1Tx')%%%%%%est es el comando

Upload: reinaldo-condori-ccacya

Post on 06-Nov-2015

4 views

Category:

Documents


0 download

TRANSCRIPT

En tiempo real de transmisin y recepcin a travs de EthernetComunicarse entre dos modelos de Simulink Real-Time a travs de Ethernet.Este ejemplo muestra cmo utilizar los bloques en la bibliotecaxpcethernetlibpara la comunicacin entre dos equipos de destino a travs de Ethernet.Los datos de la seal es enviada por el modelo transmisor,xpcEnetDemo1Tx, que se ejecuta en un equipo de destino, TargetPC1, al modelo de receptor,xpcEnetDemo1Rx, se ejecuta en el segundo equipo de destino, TargetPC2.Los bloques enxpcethernetlibpermiten Ethernet "en bruto" en tiempo real IO.RequerimientosPara ejecutar este ejemplo, tendr dos equipos de destino, cada uno con un instalado y configuradodedicadatarjeta Ethernet (adems de la tarjeta Ethernet utilizado para el enlace Ethernet entre los equipos de desarrollo y de destino).Consulte la documentacin en tiempo real Simulink en comunicaciones Ethernet basados en modelos para obtener ms detalles.Una vez configurado, establecer el bus PCI y ranura en el bloque "Ethernet Init" dexpcEnetDemo1TxyxpcEnetDemo1Rxa la de la tarjeta Ethernet instalada en TargetPC1 y TargetPC2 respectivamente.Abierto, Construir, y descargar el modelo de Tx a TargetPC1Haga clic aqu para abrir el modelo Tx:xpcEnetDemo1Tx.Este modelo lleva un oscilador con una seal de onda cuadrada y enva las seales de salida de entrada del oscilador y para el equipo de destino Rx usando prima Ethernet.open_system ('xpcEnetDemo1Tx')%%%%%%est es el comando

% Abra el modelo.mdlOpen = 0;sistemas = find_system ( tipo , block_diagram ' ); si ~ cualquier (strcmp (sistemas, 'xpcEnetDemo1Tx' )) mdlOpen = 1; open_system ( 'xpcEnetDemo1Tx' ); final

% Construir el modelo y descargar en el equipo de destino Tx, TargetPC1. set_param ( 'xpcEnetDemo1Tx' , 'RTWVerbose' , 'off' ); % Configurar para una acumulacin no detallado. rtwbuild ( 'xpcEnetDemo1Tx' ); % Construir y descarga de aplicaciones .### A partir procedimiento de construccin en tiempo real Simulink para el modelo: xpcEnetDemo1TxAdvertencia: Este modelo contiene bloques que no manejan tiempo de la muestracambios en tiempo de ejecucin. Para evitar resultados incorrectos, nico cambioel tiempo de la muestra en el modelo original, y luego reconstruir el modelo. ### Completar con xito el procedimiento de construccin para el modelo: xpcEnetDemo1Tx### Buscando objetivo: TargetPC1### Modelo Descargar en destino: TargetPC1% Cierre el modelo si lo abrimos. si (mdlOpen) bdclose ( 'xpcEnetDemo1Tx' ); finalAbierto, Construir, y descargar el modelo de Rx a TargetPC2Haga clic aqu para abrir el modelo Rx:xpcEnetDemo1Rx.Este modelo recibe los datos enviados porxpcEnetDemo1Txy descomprime los datos para su visualizacin en un mbito objetivo.% Abra el modelo.mdlOpen = 0;sistemas = find_system ( tipo , block_diagram ' ); si ~ cualquier (strcmp (sistemas, 'xpcEnetDemo1Rx' )) mdlOpen = 1; open_system ( 'xpcEnetDemo1Rx' ); final

% Construir el modelo y descargar en el equipo de destino Rx, TargetPC2. set_param ( 'xpcEnetDemo1Rx' , 'RTWVerbose' , 'off' ); % Configurar para una acumulacin no detallado. rtwbuild ( 'xpcEnetDemo1Rx' ); % Construir y descarga de aplicaciones .### A partir procedimiento de construccin en tiempo real Simulink para el modelo: xpcEnetDemo1RxAdvertencia: Este modelo contiene bloques que no manejan tiempo de la muestracambios en tiempo de ejecucin. Para evitar resultados incorrectos, nico cambioel tiempo de la muestra en el modelo original, y luego reconstruir el modelo. ### Completar con xito el procedimiento de construccin para el modelo: xpcEnetDemo1Rx### Buscando objetivo: TargetPC2### Modelo Descargar en destino: TargetPC2% Cierre el modelo si lo abrimos. si (mdlOpen) bdclose ( 'xpcEnetDemo1Rx' ); finalEjecute ambos modelosUtilizando las variables de objeto Simulink en tiempo realtgTxytgRx, inicie los modelos.start (tgTx); % Comience el modelo Tx. start (tgRx); .% Comience el modelo Rx pausa (5); % Deje que los modelos funcionan durante al menos 5 segundos.Visualizar el mbito Tx Target ComputerTomar una instantnea de la pantalla de vdeo del ordenador de destino Tx.Plotted son los datos de la seal que se enva al equipo de destino a travs de Rx prima Ethernet.tgTx.viewTargetScreen

Visualizar el Rx Target Computer ScopesTomar una instantnea de la pantalla de vdeo del ordenador de destino Rx.Plotted son los datos de la seal recibida desde el equipo de destino a travs de primas Tx Ethernet.tgRx.viewTargetScreen

Deje de ambos modelosCuando haya terminado, detener a los modelos que se ejecute.stop (tgTx); % Detenga el modelo Tx. stop (tgRx); % Detenga el modelo de Rx.

% EOF xpcEnetDemo1.m

En inglesReal-Time Transmit and Receive over EthernetCommunicate between two Simulink Real-Time models over Ethernet.This example shows how to use blocks in the libraryxpcethernetlibto communicate between two target computers over Ethernet. Signal data is sent by the transmitter model,xpcEnetDemo1Tx, running on one target computer, TargetPC1, to the receiver model,xpcEnetDemo1Rx, running on the second target computer, TargetPC2. The blocks inxpcethernetlibenable "raw" Ethernet for real-time IO.RequirementsTo run this example, you will need two target computers, each with an installed and configureddedicatedEthernet card (in addition to the Ethernet card used for the Ethernet link between the development and target computers). Refer to the Simulink Real-Time documentation on model-based Ethernet communications for details. Once configured, set the PCI Bus and Slot in the "Ethernet Init" block ofxpcEnetDemo1TxandxpcEnetDemo1Rxto that of the Ethernet card installed in TargetPC1 and TargetPC2 respectively.Open, Build, and Download the Tx Model to TargetPC1Click here to open the Tx model:xpcEnetDemo1Tx. This model drives an oscillator with a square wave signal and sends the oscillator input and output signals to the Rx target computer using raw Ethernet.% Open the model.mdlOpen = 0;systems = find_system('type', 'block_diagram');if ~any(strcmp(systems, 'xpcEnetDemo1Tx')) mdlOpen = 1; open_system('xpcEnetDemo1Tx');end

% Build the model and download to the Tx target computer, TargetPC1.set_param('xpcEnetDemo1Tx','RTWVerbose','off'); % Configure for a non-Verbose build.rtwbuild('xpcEnetDemo1Tx'); % Build and download application.### Starting Simulink Real-Time build procedure for model: xpcEnetDemo1TxWarning: This model contains blocks that do not handle sample timechanges at runtime. To avoid incorrect results, only changethe sample time in the original model, then rebuild the model. ### Successful completion of build procedure for model: xpcEnetDemo1Tx### Looking for target: TargetPC1### Download model onto target: TargetPC1% Close the model if we opened it.if (mdlOpen) bdclose('xpcEnetDemo1Tx');endOpen, Build, and Download the Rx Model to TargetPC2Click here to open the Rx model:xpcEnetDemo1Rx. This model receives data sent byxpcEnetDemo1Txand unpacks the data for display in a target scope.% Open the model.mdlOpen = 0;systems = find_system('type', 'block_diagram');if ~any(strcmp(systems, 'xpcEnetDemo1Rx')) mdlOpen = 1; open_system('xpcEnetDemo1Rx');end

% Build the model and download to the Rx target computer, TargetPC2.set_param('xpcEnetDemo1Rx','RTWVerbose','off'); % Configure for a non-Verbose build.rtwbuild('xpcEnetDemo1Rx'); % Build and download application.### Starting Simulink Real-Time build procedure for model: xpcEnetDemo1RxWarning: This model contains blocks that do not handle sample timechanges at runtime. To avoid incorrect results, only changethe sample time in the original model, then rebuild the model. ### Successful completion of build procedure for model: xpcEnetDemo1Rx### Looking for target: TargetPC2### Download model onto target: TargetPC2% Close the model if we opened it.if (mdlOpen) bdclose('xpcEnetDemo1Rx');endRun both ModelsUsing the Simulink Real-Time object variablestgTxandtgRx, start the models.start(tgTx); % Start the Tx model.start(tgRx); % Start the Rx model.pause(5); % Let the models run for at least 5 sec.Display the Tx Target Computer ScopeTake a snapshot of the Tx target computer video display. Plotted is the signal data that's sent to the Rx target computer via raw Ethernet.tgTx.viewTargetScreen

Display the Rx Target Computer ScopesTake a snapshot of the Rx target computer video display. Plotted is the signal data received from the Tx target computer via raw Ethernet.tgRx.viewTargetScreen

Stop both ModelsWhen done, stop the models from running.stop(tgTx); % Stop the Tx model.stop(tgRx); % Stop the Rx model.

% EOF xpcEnetDemo1.mWas t