Vous suivez désormais cette question
- Les mises à jour seront visibles dans votre flux de contenu suivi.
- Selon vos préférences en matière de communication il est possible que vous receviez des e-mails.
Reading ADC data from MSP430 to Matlab via serial port
- setup serial communication.
- create array to store uart values
- calculate voltage values
- plot live values
19 commentaires
- I haven't yet experimented this circuit on the workbench where i will apply known strain to test my circuit so I don't think I have limit to specific number of samples needed. Lets assume I will be watching matlab data and plot while experimenting so I have not clear answer for this.
- the data from adc is sampled channel by channel so I am taking data from ads as 1 sample per channel and then proceding to next channel.
- this means that i am trasnferring data to serial port in above mentioned way.
- If i want to record it i first have to seperate data which UART is pushing out as 8 bit(adc samples 24 bit of data for single sample) hence I would have to record 4 byte and sort it into 1 row and then switch to another row to record one more sample ..........
- Write numbers in character form, either decimal or hexadecimal, with non-number between the entries. Either put newline after each individual number or put newline at the end of a group of samples; or
- Write numbers in binary using a fixed number of bytes per entry, so that you can ask to read a fixed number of bytes with no delimiter; or
- At the beginning of each burst of numbers, write a byte (or two) which is the number of bytes that follow in that packet, with no end of line. The input side reads the size (fixed size) and uses the size to read that many bytes; or
- use a variable length binary stream with a fixed termination byte, with the binary stream having been carefully adjusted so that it never accidentally includes the termination character. For example you might use newline, and everywhere that newline would have been sent as data send 255 0 and everything 255 would have been sent, send 255 255.
- you can continue to send in binary, and do binary reads using fread() (for serial) or read() (for serialport). If you are not always sending the same number of bytes or if not everything is the same binary data type, then you may need to add some extra bytes to indicate how the following data is to be treated. If you use this fread() binary approach, you do not put any delimiters between values and you do not send newline; OR
- you can switch to sending the numbers as text. If you send as text, put a space between the values and put newline at the end of the line. On the MATLAB end, fscanf() will read the entire line of values, returning a numeric vector.
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Une erreur s'est produite
Impossible de terminer l’action en raison de modifications de la page. Rechargez la page pour voir sa mise à jour.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asie-Pacifique
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)