Shop OBEX P1 Docs P2 Docs Learn Events
With a little help from my friends..... — Parallax Forums

With a little help from my friends.....

PliersPliers Posts: 280
edited 2010-12-04 05:54 in Propeller 1
I have written a motion control program in assembly.
It checks sensors and controls the motor direction and speed.
The motor is controlled with acceleration and de acceleration subroutines.
It is my most extensive program ever. I’m looking forward to posting the project when finished.

My next step is to build in some diagnostics concerning the motion, but I’m having difficulty getting the data out of the assembly program.

I was hoping someone would show me how to make this sample program work.
CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000
OBJ
  pst   :  "Parallax Serial Terminal"
var
  byte cog 
  byte Data
  long Data1
  long Data2 
Pub Main
data2 := 500
  pst.Start(56000) 
repeat    
     Data := pst.charin
     if data== "a"     'I send the character "a" from visual basic
      pst.char("Q")   'I get back a"Q". Simple testing for my comunications
     if data == "b"    'Now when I send a "b". I want it to start a cog that returns data.
       cog := cognew(testing,0)
       pst.dec(data1)
        pst.dec(data2)
       cogstop(cog)       
dat
testing  org 0
         wrlong testData1, data1     ' trying to get data back to the spin program
         wrlong testData2, data2     ' trying to get data back to the spin program
         jmp #testing        
testData1 long 123
testData2 long 456  
I don’t have any problems with the visual basic interface.

No rush on this request.
Very best regards, Steve.

Comments

  • PliersPliers Posts: 280
    edited 2010-12-03 10:12
    Ok, this works.
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    OBJ
      pst   :  "Parallax Serial Terminal"
    var
      byte cog 
      byte Data
      long Data1 
    Pub Main
    data1 := 7 
    pst.Start(56000) 
    repeat    
         Data := pst.charin
       if data== "a"     'I send the character "a" from visual basic
        pst.char("Q")   'I get back a"Q". Simple test for my comunications
      if data == "b"    'Now when I send a "b". I want it to start a cog that returns data.
           cog := cognew(@testing,@data1)   'Start a Cog 
           pst.dec(data1)                'Send the data1
           cogstop(cog)                   'Stop the cog
    dat
    testing  org 0
             mov addr, PAR
             wrlong testData1, addr   'Trying to get data back to the spin program       
             jmp #testing        
    testData1 long 123  
    addr    res 1                      'PAR address 
    

    To get multiple values out, I will need to do an array.
  • StefanL38StefanL38 Posts: 2,292
    edited 2010-12-03 10:14
    Hello,

    oops ! Parallax changed the look and feel of the forum.
    I hope this will not change every week as a new fashion^2

    Somehow the getting started sticky-thread vanished

    took me some searching to find this again

    Assembley-Language-Help-List

    I tried to find that PASM-beginner tuotrial that shows how to exchange data between SPIN (=HUB-RAM and PASM (COG-RAM) but I could not find it
    EDIT it's more or less hidden behind the Propeller-HYDRA-Key-Thread-Index

    best regards

    Stefan
  • PliersPliers Posts: 280
    edited 2010-12-03 12:09
    I thought this would clear things up for me, but it does not work.
    var
      long delay 
      byte cog 
      long Data[2] 
    Pub Main
      delay := 4000
      Dira[16..23]~~
      data[0] := 0
      data[1] := 1
      cog := cognew(@testing,@data)   
      waitcnt(delay+cnt) 
      cogstop(cog)                       
    repeat
      if data[0] == 0
       outa[16]~~    
      if data[1] == 111
       outa[18]~~      
    dat
    testing  org 0
             mov addr, PAR
             wrlong testData0, addr   
             add addr,#4
             wrlong testData1, addr          
             jmp #testing        
    testData0 long 3
    testData1 long 111 
    addr    res 1
    
    I want LED16 off and LED18 on.
    I get LED16 on and LED18 off.
  • PliersPliers Posts: 280
    edited 2010-12-04 05:54
    I found my mistake.
    Now back to conquering the world.
    var
      long delay 
      byte cog 
      long Data[2] 
    Pub Main
      delay := 400000
      Dira[16..23]~~
      data[0] := 0
      data[1] := 1
      data[2] := 2
      cog := cognew(@testing,@data[0])   
      waitcnt(delay+cnt) 
      cogstop(cog)                       
    repeat
      if data[0] == 3
       outa[16]~~    
      if data[1] == 4
       outa[18]~~  
    dat
    testing  org 0
             mov addr, PAR
             wrlong testData0, addr   
             add addr,#4
             wrlong testData1, addr          
             jmp #testing        
    testData0 long 3
    testData1 long 4
    addr    res 1
    
Sign In or Register to comment.