serial communication between microcontroller 8051 and matlab
조회 수: 16 (최근 30일)
이전 댓글 표시
i want to send information through matlab to 8051. to control the speed of motor.if any key is pressed the speed should up. and other key for down.
plzzzzzzzzzzzz help. i really need.
I am working through pwm. so if high pulse occur so motor get up,and if low pulse then motor speed down.
so I did this with external internpt in interrupt, so its working but with matlab its not working. im using imtool for this purpose
to understand the key i use sbuf reg in 8051,
org 0
mov tmod,#20h
mov th1,#-3
mov scon,#50h
setb tr1
here: jnb ri,here
mov a,sbuf
cjne a,#'a',n1
setb p2.0
acall delay
clr ri
sjmp here
n1: clr p2.0
acall delay
clr ri
sjmp here
delay:
mov r2,#255
h7: mov r3,#250
h8: djnz r3,h8
djnz r2,h7
ret
end
now you can understand my program easily. what will happen.
I am using keyboard
now you can get my all point.
please help
댓글 수: 0
채택된 답변
Walter Roberson
2011년 4월 15일
What serial port characteristics do you require for this interface?
What command does the microcontroller need in order to increase the speed? What command does the microcontroller need to decrease the speed?
How were you planning to notice key presses and decide which key was pressed?
When you say "key" do you mean keyboard, or do you want it to be mouse controllable as well (or instead)?
If you do mean keyboard, then will there be a graphics window also available, or does this need to work even if there is no graphics display available?
댓글 수: 4
Walter Roberson
2011년 4월 17일
With regards to the particular characters sent to the microcontroller, you should assume that this is a MATLAB newsgroup and that I might not know the 8051 assembly language that you are using.
I also do not have the Test and Measurement Toolbox, and as you had not previously mentioned that you were using that, I had no way of guessing it.
If you don't know about the graphics interface, then you had better find out, because the *supported* ways of reading individual keys from a keyboard require using the graphics interface.
When you have finished assuming that we will "just know" things you have failed to mention despite having been asked about them, read these reference pages:
http://www.mathworks.com/help/toolbox/instrument/serial.html
http://www.mathworks.com/help/toolbox/instrument/fopen.html
http://www.mathworks.com/help/toolbox/instrument/fread.html
http://www.mathworks.com/help/toolbox/instrument/fwrite.html
http://www.mathworks.com/help/techdoc/ref/figure_props.html
(KeyPressFcn)
http://www.mathworks.com/help/techdoc/ref/uicontrol_props.html#bqxoim8
http://www.mathworks.com/help/techdoc/ref/uicontrol_props.html#bqxoijj
http://www.mathworks.com/help/techdoc/ref/uicontrol.html
(Specifying the uicontrol style)
추가 답변 (3개)
muhammad yasir
2011년 4월 17일
댓글 수: 1
Walter Roberson
2011년 4월 17일
If you had answered the questions put to you without a 1 1/2 day delay, would the situation still be "urgent" ?
If you want my attention "urgently" on a Sunday afternoon, you can book my time *in advance*, and you can pay my incremental costs for having to run my household errands during the week.
Stephen Justin
2023년 2월 4일
you need to changes the hexadecimal values are properly prefixed with 0x, the th1 is set to the proper value for 9600 baud rate -3, scon is set to the proper value for serial communication 0x50
댓글 수: 1
Walter Roberson
2023년 2월 4일
The code they posted back then uses
mov scon,#50h
I would have expected that the "h" suffix would indicate hexadecimal, and so 0x50 would not be required ?
참고 항목
카테고리
Help Center 및 File Exchange에서 COM Component Integration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!