serial tranmission data from matlab to avr

Status
Not open for further replies.

mf1364

Full Member level 3
Joined
Dec 4, 2007
Messages
185
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,700
I sent a string to micro with matlab like this '16' and with val() command i changed it to a numeric value but i dont know why the results of mathamatical analysis are completely wrong like this 16*2=212
do y know what is problem ?and programs for matlab and micro are :
*********************matlab***********
clc
s=serial('com1','baudrate',38400,'databits',8)
fopen(s)
% for i=1:4
%b=['1';'2';'3';'4']
d=Addresses(1,1).edit8
fprintf(s,'%s','16')
fclose(s)
*****************************micro(bascome)****************
$regfile = "m32def.dat"
$crystal = 8000000
$baud = 38400
Config Serialin = Buffered , Size = 20
Enable Interrupts
Dim N As String * 10
Dim Ar0(85) As Word
Dim B As Word
Dim C As Word
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2
Cls
Do
N = Waitkey()
B = Val
Ar0(1) = B
C = B * 2
Lcd C
Loop
End
*******************
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…