serial communication between microcontroller 8051 and matlab
6 views (last 30 days)
Show older comments
muhammad yasir
on 15 Apr 2011
Commented: Walter Roberson
on 4 Feb 2023
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 Comments
Accepted Answer
Walter Roberson
on 15 Apr 2011
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 Comments
Walter Roberson
on 17 Apr 2011
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)
More Answers (3)
muhammad yasir
on 17 Apr 2011
1 Comment
Walter Roberson
on 17 Apr 2011
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
on 4 Feb 2023
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 Comment
Walter Roberson
on 4 Feb 2023
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 ?
See Also
Categories
Find more on COM Component Integration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!