Shop OBEX P1 Docs P2 Docs Learn Events
transfer spin to assem — Parallax Forums

transfer spin to assem

ratronicratronic Posts: 1,451
edited 2007-05-31 14:46 in Propeller 1
I am trying to pass a number from a spin top obj to an assm servo obj following Graham's data transfer in the
assm step by step routines for an example. My top spin = h48c and the objects I am is using a trimmed down
version of the a48c Tri-axis accelerometer and my own serv1 servo object. I am using 1.5 ms for center. That's
the problem I am having is taking the y axis raw # (which I am) and adding 120000 to it (which I can) and sending it to my serv1 routine (where I am having the problem). I only get the start time # I started it with (1.5ms) . The off time is always set at 20ms. I have tried everything I can think of but I can't seem to update
the on time # (starts with 1.5ms) with y axis # with 120000 to it from the accelerometer routine.· Can anybody look at my code
and tell me why I am going wrong? My end result is I am at the start of a balancing bot and I know I have far to go but this is holding me up. Thanks Dave.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Fix it if ain't broke·
D Rat


Dave Ratcliff· N6YEE

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,548
    edited 2007-05-31 03:42
    ratronic,

    Take a closer look at your 'H48C obj.spin' program·and make sure it is·providing the correct return values for 'H48c.y'.... I modified your 'ah48c.spin' to look like this...

    [b]'ah48c.spin[/b]
    

    [b]con[/b]  
         [b]_clkmode[/b] = [b]xtal[/b]1 + [b]pll[/b]16x   
         [b]_xinfreq[/b] = 5_000_000
    
     
    [b]obj[/b]
        sr : "serv1"
    '   lcd : "debug_lcd"
    '  h48c : "h48c obj"
    
    [b]var[/b]
    
    [b]long[/b] ya
    [b]pub[/b] main
    
         sr.start(120000)
    '     h48c.start(2,0,1)
    '     lcd.start(6,19200,4)
    '     lcd.backlight(true)
    '     lcd.cursor(0)
         [b]repeat[/b]               
    '       ya := h48c.y + 120000
           ya := 120000 
           sr.out(ya)
    '       lcd.cls
    '       lcd.dec(ya)
           [b]waitcnt[/b](15000000 + [b]cnt[/b])        
    
    
    




    ... After connecting a scope to pin #7 and manually changing values for 'ya' , the 'serv1.spin' program you provided appears to function properly.

    Hope this helps toward diagnosing your problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 5/31/2007 3:47:09 AM GMT
  • ratronicratronic Posts: 1,451
    edited 2007-05-31 04:08
    Beau , I see that you fixed the # by adding the line ya := 120000 , I am trying to update the y axis + 120000. I get that # ok.
    My problem is sending the 120000 + y axis which varies by the position of acc chip which is about in the range of +or- 250 +
    120000. I can get the total # and display it. But I can't seem to send it to the serv1 object. It doesn't vary the on time of 120000 I started the object which. I can see on the scope it stays at 120000 I started it whith.?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Fix it if ain't broke·
    D Rat


    Dave Ratcliff· N6YEE
  • Beau SchwabeBeau Schwabe Posts: 6,548
    edited 2007-05-31 04:40
    ratronic,

    "I see that you fixed the # by adding the line ya := 120000 , I am trying to update the y axis + 120000. I get that # ok."

    Right, I understand that, my test was to make sure that the serv1 object was indeed working properly. Changing ya to 80000 produced a pulse width of 1000uS ...
    likewise changing ya to 160000 produces a pulse width of 2000uS.

    If the values returned from 'h48c.y' only ranges from +or- 250 then that is likely your problem....

    250 + 120000 = 120250 ... divide this by 80 and you get·1503.125 uS for a pulse width
    -250 + 120000 = 119750 ... divide this by 80 and you get·1496.875 uS for a pulse width

    ...a deviation of only 6.25uS is barely enough for a standard servo to register any change at all. Looks like the value returned from h48c.y needs to be scaled to something
    the servo can actually recognize.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • ratronicratronic Posts: 1,451
    edited 2007-05-31 14:46
    Beau, I figured it out thank you! You were right the raw y axis # was so small no wonder I didn't see it at all on the scope. So what I did is multiply the y axis x 160 then add 120000 to it. Now I can see it on the scope! I now get a range that goes· +/- .5 ms difference from 120000. Thanks for pointing me in·the wright direction!! I have attached corrected code if you want look at it. Thanks again!! Dave

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Fix it if ain't broke·
    D Rat


    Dave Ratcliff· N6YEE
Sign In or Register to comment.