Shop OBEX P1 Docs P2 Docs Learn Events
help calling spin from assembly — Parallax Forums

help calling spin from assembly

madjackmadjack Posts: 9
edited 2008-04-01 13:08 in Propeller 1
Hello
I am new to spin and assembly programming and I’m having some difficulty with calling
back from assembly to spin.
My first program here is a hyper terminal connection in spin that loads and starts an assembly program that runs a stepper motor driver. The drives I am using are geared and are also micro stepping at 2000 resolution.· It takes 6000 steps to get one full revolution of the step motor. This drive can ramp up to a high frequency and back down & stop. It works fairly well but I need it to call back to spin at the end of the drive so that hyper terminal can tell the parent system the drive is completed, then reset the propeller. This call back is were my problem is.
To load the assembly code, with hyper terminal connected you need to;
1.)·Send an integer representing the pin the modulated out put will be on
2.)·Send a value between 1 & 79 to set a ramp, 1 = slow 79 = real fast
3.)·A value in steps from 10 to as high as the system can count representing steps
4.)·And a 1 or a zero for motor rotation that is an output at pin 0
····· All entrees followed by carriage returns
The system expects 57600 baud & no hand shaking via the “Full Duplex Serial Plus” object.
Thanks in advance to anyone willing to look at my code
Jack

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-31 20:22
    In Wait in the spin code, you have "while bizy := 0". This should be "while bizy == 0"
  • madjackmadjack Posts: 9
    edited 2008-03-31 20:34
    Hello Mike
    · I have tried it both ways and it still get hung up ·in “Wait”
    I must have more problems in my code that I can’t find
    ·Thanks for looking at it
    Do you have any other thoughts?

    I just cant find what I have done and have little experiance with spin & assembly.

    Jack
  • AribaAriba Posts: 2,685
    edited 2008-03-31 20:56
    Your _finished pointer in the Assembly code points to csteps and not to cfinished, because you don't read csteps in the initialization.
    Try it with this change:
    add p,#4
    rdlong _finished,p
    to
    add p,#8
    rdlong _finished,p


    Andy
  • madjackmadjack Posts: 9
    edited 2008-03-31 21:06
    Muchas grassias Mr. Ariba
    That was it.
    I still need a little delay before the reboot so that hyper terminal can
    Get a full “done” flag.

    Thank you all for your help

    Jack
  • StefanL38StefanL38 Posts: 2,292
    edited 2008-03-31 21:25
    Hello Jack,

    of course as a theme for itself, it could be very interesting how to get back from assembler to SPIN.

    hm - to me it seems very strange why you want to REBOOT the propeller after EACH SINGLE stepping-command ??

    could you explain the advantage ?

    I would implement an idle-mode. The driver-cog is started at the beginning and remains in idle-mode

    then the interface-cog setups the details pin, lowSp, ramp, rampInc, steps
    and finally sets another flag for "GO"

    then interface-cog is waiting for the flag "finished"

    the driver-assembly-cog waits for the flag "GO".
    If "GO" received, generates the stepping-signals.
    After finishing, sets the flag "finished and returns to idle-mode

    cognew takes some time because 2kB of RAM has to be copied from HUB-RAM to COG-RAM and AFTER that the cog can start working

    REBOOT takes some SECONDS because the propellerchip has to to his FULL bootsequence.
    If you want to drive more than one "stepline" in sequence it will be interrupted be the reboots
    and that's what i do not understand at all

    The flags "GO" and "finsihed" are just another two longs defined in sequence to pin, lowSp, ramp, rampInc, steps
    that you can easyly access them from assembler

    So please tell me what is the advantage of all the cognews, and cogstops and the rebooting ?

    best regards

    Stefan

    Post Edited (StefanL38) : 3/31/2008 9:37:09 PM GMT
  • madjackmadjack Posts: 9
    edited 2008-03-31 23:29
    blush.gif·

    Hello Stefan

    Thanks for the input. Any and all input is welcome as I wish to learn this technology.

    I don’t have a good reason for stopping the cog and rebooting other than it is a short cut to get back to the start of my program. As I gain more ability with spin and assembly programming I will no doubt want to explore and add to this but at this point I’m struggling to crawl. Walking will have to wait until I get the bugs out of crawling.

    The current application I would like to lend this first program to would not be very demanding of the propeller as the equipment already has a control system. At this point I just need the propeller to be ready to modulate one out put at a time and flag the parent system when it has finished a drive sequence.

    I do wish to gain the ability to control 2 & 3 axis at a time and create circular and other more complex moves. But for now I am going to have to step on my tail a little.

    If you see anything else that seems odd please show me the way.

    I will listen to all of it.

    Jack

  • StefanL38StefanL38 Posts: 2,292
    edited 2008-04-01 05:16
    Hello Jack,

    ah now i can see. OK that's one way to go.

    i think to code an idle mode will be easy for you just compare to values if not zero jump back to loopstart
    if zero "GO"

    To move 2 axis at the same time you can use the "Bresenham-Algorithm"

    The "Bresenham-Algorithm" needs only addition and substraction of INTEGERs to calculate everything
    it does NOT need multiplication or division or floating-point-calculation

    by googling i found this PDF

    www.khwarzimic.org/takveen/helix.pdf

    there are o lot more hits for this keyword

    Also search the propellerforum about steppermotors

    search.parallax.com/search?q=+%2B%22f%3D25%22&btnG=Google+Search&client=parallax&lr=&num=100&output=xml_no_dtd&site=parallax&ie=&oe=&sort=&proxystylesheet=parallax

    best regards

    Stefan
  • madjackmadjack Posts: 9
    edited 2008-04-01 13:08
    Thanks Stefan
    I'm a little slow so this may take soon time as I also have to juggle a few other situations
    I will more than likely post more questions to this thread in a week or so
    Or start another one

    Stefan
    I want to try all the suggestions you have given

    Thanks to all as other posts as well have been a huge part of my learning

    Best regards to all

    Jack
Sign In or Register to comment.