IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MATLAB Discussion :

syntaxe pour envoyer les données d'une variable


Sujet :

MATLAB

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2015
    Messages
    55
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Avril 2015
    Messages : 55
    Par défaut syntaxe pour envoyer les données d'une variable
    Bonsoir,

    Je voudrais envoyer sur un générateur de fonctions une onde prédéfinie (d'une variable ou d'un fichier)

    pour communiquer avec l'appareil (DG4000), j'utilise l'interface Visa TCP-IP

    par exemple, la commande suivante envoie les valeurs : 1,10,100,200,400

    fprintf(DG4000,':DATA:DAC VOLATILE,1,10,100,200,400')

    Si je veux envoyer 1000 ou 2000 valeurs.... cette façon de procédé ne peut pas fonctionner.

    Comment je peux faire pour envoyer toutes les données d'une variable tableau ou d'un fichier ?

    Merci

    Ci-dessous la syntaxe des deux commandes.

    Syntax

     

    [:TRACe]:DATA:DAC VOLATILE,[<binary_block_data>|<value>,<value>,<value>...]

     

     

    Description

     

    Download binary data block or decimal DAC value to the volatile memory.

     

     

    Explanation
     

    <binary_block_data> is the binary data to be downloaded. The range is from 0000 to 3FFF and the data length is 4 Bytes (2 pts) to 32768 Bytes (16 kpts). The binary data block starts with #.

    For example, send :DATA:DAC VOLATILE,#516384binary data

    The number 5 following # represents that the data length information 16384 holds 5 characters and 16384 represents the number of bytes of the binary data. As each waveform point holds two bytes, the number of bytes must be an even number.

    <value>,<value>,<value>...: represent the decimal DAC to be downloaded. When the data does not start with #, the decimal DAC value can be sent in character string format.

    For example, send :DATA:DAC VOLATILE,0,16883,8192,0,16383

    5 data points are sent totally.

    For data with less than 16384 points, the instrument will extend the data to 16384 points using uniform interpolation automatically.

    After this command is sent, the instrument will switch the current channel to output volatile waveform automatically and modify the interpolation mode and the number of editable points. The data downloaded using this command can be edited on the instrument.
    [:TRACe]:DATA:DAC16

     

     

    Syntax

     

    [:TRACe]:DATA:DAC16 VOLATILE,<flag>,<binary_block_data>

     

     

    Description

     

    Download the waveform edited into the DDRII.

     

     

    Explanation
     

    This command consists of two parts. The first part is the command character string ([:TRACe]:DATA:DAC16 VOLATILE,<flag>,) and the second part is the binary data (<binary_block_data>).

    <flag> represents the data transmission state and can be set to "CON" or "END". "CON": there are still data packets after the current one; "END": this is the last data packet and the data transmission is finished.

    <binary_block_data> is the binary data to be downloaded and the range is from 0000 to 3FFF. The data length must be 16 kpts (32 kBytes).

    The binary data block starts with #.

    For example, send :DATA:DAC16 VOLATILE,CON,#532768binary data

    The number 5 following # represents that the data length information 32768 holds 5 characters and 32768 represents the number of bytes of the binary data. As each waveform point holds two bytes, the number of bytes must be an even number.

    When the <flag> in the command received is END, the instrument will automatically switch to arbitrary waveform output.

    If the total length of the waveform to be downloaded is 16 kpts and the waveform is downloaded into the instrument in one operation, users can edit the data on the instrument. Otherwise, local editing is not supported.

  2. #2
    Rédacteur/Modérateur

    Avatar de Jerome Briot
    Homme Profil pro
    Freelance mécatronique - Conseil, conception et formation
    Inscrit en
    Novembre 2006
    Messages
    20 317
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Freelance mécatronique - Conseil, conception et formation

    Informations forums :
    Inscription : Novembre 2006
    Messages : 20 317
    Par défaut
    Comme ceci :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    str = sprintf(',%d' X);
     
    fprintf(DG4000,[':DATA:DAC VOLATILE' str])

  3. #3
    Membre averti
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2015
    Messages
    55
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Avril 2015
    Messages : 55
    Par défaut
    Bonjour,

    Merci pour ce coup de pouce,

    J'ai fait ce programme pour tester :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    x=[0:0.08:2*pi];
    y=8192*sin(x)+8192
    y=round (y)
    str = sprintf(',%d', y); 
    strgbf=strcat(':DATA:DAC VOLATILE',str)
    fprintf(DG4000,strgbf);
    Ça fonctionne plutôt bien, par contre le nombre de points transmis semble limité à 80, au-delà j'ai cette erreur :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    Error using icinterface/fprintf (line 159)
    The number of bytes written must be less than or equal to OutputBufferSize-BytesToOutput.
    
    Error in GBF_Wave (line 20)
    fprintf(DG4000,strgbf);
    Je suppose qu'il doit y avoir une autre façon de transmettre, car le logiciel dédié transmet jusqu'à 16 384 échantillons.
    Ou comment augmenter ce buffer ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    DG4000.OutputBufferSize=4096;

  4. #4
    Membre averti
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2015
    Messages
    55
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Avril 2015
    Messages : 55
    Par défaut C'est tout bon :)
    C'est nickel
    J'avais un programme qui récupère l'onde d'un oscilloscope, maintenant cette onde je peux la réinjecter dans le générateur de fonctions.

    Exemple :
    Courbe de décharge d'un accumulateur Li-Ion
    Nom : accu_figure.png
Affichages : 199
Taille : 10,0 Ko
    envoyé dans le générateur de fonctions et visualisé sur l'oscilloscope :
    Nom : accu.png
Affichages : 194
Taille : 22,2 Ko

    Le programme :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    load accu.mat;
    %%Connexion
    DG4000 = visa( 'ni','TCPIP::192.168.0.12::INSTR' );
    DG4000.OutputBufferSize=(6*16384);
    fopen(DG4000 );
    %% Parametres
    onde=Accumulateur;
    %% Normalisation de l'onde mini 0 maxi 16384 en entier
    maxi=max(onde);
    mini=min(onde);
    ondeY=uint16(round(onde.*16384./maxi));
    %% téléchargement onde
    str = sprintf(',%d', ondeY); 
    strgbf=strcat(':DATA:DAC VOLATILE',str);
    fprintf(DG4000,strgbf);
    %% Fin connexion
    fclose(DG4000); 
    delete(DG4000);
    clear DG4000;

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 3
    Dernier message: 13/05/2014, 14h53
  2. Réponses: 6
    Dernier message: 23/04/2009, 16h07
  3. Réponses: 3
    Dernier message: 23/04/2009, 12h44
  4. Problème pour lire les donnée d'une table externe
    Par mardoch dans le forum SQL*Loader
    Réponses: 6
    Dernier message: 17/07/2008, 16h41
  5. [Mail] Exploser les données d'une variable issu de Flash
    Par anti-conformiste dans le forum Langage
    Réponses: 1
    Dernier message: 02/11/2006, 16h23

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo