BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Sat Jul 21, 2018 4:32 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: "serin" command can not communicatie with matlab file
PostPosted: Wed Oct 24, 2012 5:59 am 
Offline
New User

Joined: Tue Oct 23, 2012 1:30 pm
Posts: 1
SOS. I tried to use "serin" command to recieve data from matlab file on a BasicATOMPro 40 Module and Basic ATOM USB Dev Board by using USB cable, and I can watch data signal produced through DB-9 3 Pin by scope, but it did not work, why? Who can help me?

(1) The program in BasicAtomPro 40 is as follows.
temp var byte
main
serin S_In, IO9600, [wait("L"), Dec temp]
HPWM 10, 2048, temp
goto main
end

(2) The Matlab program is to send serial communication data.
s1=serial('com10', 'BaudRate',9600);
fopen(s);
RMPM=250;
for LMotor=0:10:RMPM
fprintf(s1,'%c','L');
pause(0.1);
fprintf(s1,'%d\r',LMotor);
end
fclose(s1);


Top
 Profile  
 
 Post subject: Re: "serin" command can not communicatie with matlab file
PostPosted: Fri Oct 26, 2012 6:11 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
I expect your IO9600 is wrong. UNless you have a pullup resistor on the serial pin of the AtomPro module. IO9600 is inverted(eg normal serial) Open Drain at 9600 bps. Open Drain means the pin only pulls low. It does not go high. Use I9600 and see what happens.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: "serin" command can not communicatie with matlab file
PostPosted: Fri Apr 19, 2013 5:02 pm 
Offline
New User

Joined: Wed Apr 10, 2013 5:06 pm
Posts: 2
I met the exactly same problem!
My code in Basic atom pro40 is like this:
' and drives the robot wheels.
' Status WORKS!
S_l con P11 'S_l Direction control bit L motor
S_r con P8 'S_r Direction control bit R motor
DIS_l con P12 'DIS Disable output L motor controller
DIS_r con P7 'DIS Disable output R motor controller
i var word
LSpeed var word
RSpeed var word
HIGH DIS_l 'Disable L Motor
HIGH DIS_r 'Disable R Motor
Pause 1
LOW S_l 'Direction L Motor
HIGH S_r 'Direction R Motor
Pause 1
LOW DIS_l 'Enable L Motor
LOW DIS_r 'Enable R Motor
LSpeed = 0
RSpeed = 0
main:
SERIN S_IN, i9600, [WAIT("L"), DEC LSpeed]
HPWM 9, 2048, 4*LSpeed
SERIN S_IN, i9600, [WAIT("R"), DEC RSpeed]
HPWM 10, 2048, 4*RSpeed
goto main
end


My code in matlab is:
%MatLab test program
ser = serial('COM4');
set(ser, 'BaudRate',9600, 'DataBits',8, 'Parity', 'none', 'StopBits',1, 'FlowControl', 'none')
fopen(ser);
for LeftMotor = 0:1:255
RightMotor = 255-LeftMotor
fprintf(ser,'%c','L')
fprintf(ser,'%d\r',LeftMotor);
pause(0.1)
fprintf(ser,'%c','R')
fprintf(ser,'%d\r',RightMotor);
pause(0.1)
end
fclose(ser);


I can see the number from matlab command window. However the it seems the microcontroller cannot receive data as my two motors do not work.


Top
 Profile  
 
 Post subject: Re: "serin" command can not communicatie with matlab file
PostPosted: Mon Apr 29, 2013 6:36 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
1. this was a very old post you bumped.
2. Just showing your code doesn't tell us anything about how you have your hardware setup. What you are trying to talk to, etc... There are 2 sides to every communications and most like it isn't the Atom side that's not working as you are specifying in the code above. So we need to know more to figure out what you may need to change to get it to talk to whatever you are trying to talk to.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO