Send hexadecimal data with serial port
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all,
I am trying to send hexadecimal data by serial port using Matlab. I hace to send and receive data with a Texas Instruments microcontroller. Before try to do it with Matlab i sent and received the information with the program Serial Port Monitor (https://www.eltima.com/products/serial-port-monitor/?gclid=Cj0KCQjw5fDWBRDaARIsAA5uWTjq8_6dvxvJzJkknNUNkBUclh-IZraahmq6h-X49BpkmV5BgrwNTXUaAjVGEALw_wcB). The results are these:

I have to send the data in hexadecimal format as you can see, and the results were ok, i received what i am searching.
The problem is when i try to do with Matlab the same previous process that i did with Serial Port Monitor. I am using this Matlab code:
clear all; close all; clc; s = serial('COM3');
set(s,'BaudRate',9600);
fopen(s);
fprintf(s,'fe fe fe fe 68 99 99 99 99 99 99 68 23 0a 60 00 34 12 78 56 bc 9a f0 de 2b 16A')
out = fscanf(s)
fclose(s)
delete(s)
clear s
With Serial Monitor Program you can watch all that is sending and receiving by serial port (Although you don't send data with Serial Monitor Program, as in this case, which i am sending and receiving with Matlab). The results are these:

I am sending data in Ascii and i pretend to send in hexadecimal (I have done a lot of modifications to the previous code and i can't solve the problem). I want to do the same thing that you can see in the first image, but with Matlab. Can someone help me?
Thanks in advance.
Miguel
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Acquisition Toolbox Supported Hardware finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!