matlab help for fwrite
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
i read matlab help about fwrite it say that write binary data to device ,not decimal you answered to my question why when i use code below
s=serial('com3','baudrate',9600);
>> set(s,'flowcontrol','none');
>> set(s,'parity','none');
>> set(s,'databit',8);
>> set(s,'stopbit',1);
>> fopen(s)
>> fwrite(s,10101010,'int8')
my 8051 receive the data via serial port and display it on led as 11111110 then when i use (s,00000110,'int8') 8051 display it 00000110 what is the wrong and what is the code to send data using fwrite in binary fourm,and how i can send like this numbers -34.3 -1.1 please heeeelp
0 comentarios
Respuestas (1)
Walter Roberson
el 25 de Mzo. de 2013
fwrite(s, bin2dec('10101010'), 'int8');
fwrite(s, bin2dec('00000110'), 'int8');
Numbers such as -34.3 and -1.1 do not have a unique binary form. Use whatever form you prefer. You are going to have to write all the code for the 8051 to handle the decimal fractions, as the 8051 instruction set is strictly integer.
0 comentarios
Ver también
Categorías
Más información sobre String Parsing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!