Shop OBEX P1 Docs P2 Docs Learn Events
retrieving using basic stamp data from matlab — Parallax Forums

retrieving using basic stamp data from matlab

aylnayln Posts: 1
edited 2013-11-20 09:03 in BASIC Stamp
hi,

Im working on a project on boe bots and ım using matlab with a connection to basic stamp. I made the connection but ı need to use a basic stamp variable in matlab but ı cant get the variable from basic stamp. Matlab has to check the data which is described in basic stamp and do its job. So far I have the codes below..

basic stamp:
Code:

.......
busy           VAR     Byte
   GOSUB checkConnection
   SEROUT TX, Baud, [busy]
   busy=0
DO  
    numberOfPulses = 0  
DO    
    SEROUT TX, Baud, [busy]    
    busy=1     
    SERIN RX, Baud, [command]    
       IF     (command = "0") THEN      numberOfPulses = numberOfPulses * 10 + 0    
       ELSEIF (command = "1") THEN      numberOfPulses = numberOfPulses * 10 + 1
 ........

this goes on and ı need to check busy variable from matlab.

matlab:

Code:
function [] = go(deviceNo, command)          
      fid = fopen('Main.bs2','busy');    
      b=fread(fid); 
      while(b == 0)    
         if(deviceNo == 1)       
            commandArray = char(command);
         .......    
  end
end

fopen for openıng the file and fread to retrieving variable.

I dont know whats wrong ?? please help

Comments

  • PublisonPublison Posts: 12,366
    edited 2013-11-17 12:35
    ayln,

    Welcome to the forums!

    Your blog will be deleted, as this is the appropriate forum to post to. A blog may not be view for days, but these forums are active by the minute.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-11-20 09:03
    It's not clear from the code snippet you pasted what is happening and typically you would not have multiple DO...LOOP constructs unless they had conditionals to exit the loop. I see two DO statements but no matching LOOP statements. In any event it does look like you're serially sending the data to MATLAB assuming the baud rates match. I'm not familiar with how you would receive the data in MATLAB but I did wonder why the Main.bs2 is included in the fopen?
Sign In or Register to comment.