Shop OBEX P1 Docs P2 Docs Learn Events
SPIN -> Assembly — Parallax Forums

SPIN -> Assembly

LafetLafet Posts: 23
edited 2007-08-15 03:20 in Propeller 1
Hi,

I'm beginner. Help me please. How it is possible put into Assembly this programme in SPIN?


PUB Rotary  | i
repeat 
   repeat i from 0 to 5
      pwm.output(PIN_SEQ[i],PWM_PIN[i],70)
      repeat 6
          waitpeq(%10000, %10000, 0)
          waitpne(%10000, %10000, 0)
        
DAT

PWM_PIN byte  0, 1, 2, 0, 1, 2
PIN_SEQ byte  %001, %101, %100, %110, %010, %011

[/i][/i]



"pwm.output" is Assembly in object file "pwm.spin"

Thank you very much. Lafet

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-14 01:12
    Rather than "how do I convert this Spin program to assembly", how about starting with a description of what you want to accomplish and why you believe it needs to be done in assembly.
  • Tom G N SDTom G N SD Posts: 2
    edited 2007-08-14 01:58
    Hi yall,

    Ok I totally get the "what are you tryin' to do", but what other good references are out there for those tryin' to learn the code who are beginner programmers? Other than the manual and the forum....anyone brave enough to offer classes yet?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    can you please pass the jelly....
  • deSilvadeSilva Posts: 2,967
    edited 2007-08-14 02:23
    @Lafet. You see, this is a longer strory:
    (a) The code you posted makes not much sense, but I assume I understand what you intend to do.
    (b) The object PWM you posted consists of a machine language part which is not well adapted to its interface. The assembly part regularly looks for modulation date that is provided only once in the beginning... It seems, this PWM is still unfinished
    (c) But WRT to your purpose it looks best you just add (SPIN) code to this object!
    (d) The speed possible in machine language may be needed for your intend or maybe not, but you are far better off by using a timer/counter. How to programm a timer for PWM application is well explained in AN001.

    So, I do not think translating your program into assembly language makes any sense..
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-14 02:43
    Tom G N SD,
    There are books being written, some piecemeal on this forum, and some quietly in the background. There is a lot of information already available in the forums and in the Hydra and Propeller manuals. If you want classes, do you have enough money to pay for plane fare, housing, tuition (pricey), etc.? I'm sure there are several people who would be willing to put on a nice 3 or 4 day workshop in a resort-y place for $500-$750 per person, minimum 15 attendees, transportation and accomodations not included, 2-3 months' advanced booking required, Propeller tools provided at cost.
  • LafetLafet Posts: 23
    edited 2007-08-14 21:16
    Program have to after 6 received impulses on P4 change sequence driving BLDC motor. The MOSFET driver is connected 3-wire and but one pin is driven PWM (PWM_PIN byte 0, 1, 2, 0, 1, 2 = P0, P1, P2, P0, P1, P2).
    PIN_SEQ byte %001, %101, %100, %110, %010, %011 is mask for setting P2..P0 to High or Low.
    PWM drives always pin, which is in sequence ones with logical value (%001 = P0, %101 = P1, ...).
    To 15.000 revolutions is duration impulse on P4 17 microseconds. I think, that the SPIN is slow.

    Lafet
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-14 21:41
    Spin should be able to count 6 pulses, one every 17us, and do something very simple after 6 pulses. Something as simple as:
    repeat
       repeat 6
          waitpne(0,%1000,0)
          waitpeq(0,%1000,0)
    ' do something very simple
    
    


    The action after 6 pulses has to involve very little action
    because the next pulse will start very quickly. If the pulse is short
    so you don't have to wait for it to end, then you won't need the
    waitpeq.
    Spin can "bit bang" asynchronous serial I/O at over 19.2KBaud. That's
    about 50us per bit and the code involved in that loop is a little more complex
    than what you need here. It's worth trying to see if you can do this in Spin.

    Other options include using the edge detection mode for one of the cog counters
    and having your Spin program sit in a loop waiting for the edge count to reach 6,
    then resetting the count and changing the BLDC motor information. The counters
    can count edges at about a 40MHz rate and can be administered from Spin.

    Post Edited (Mike Green) : 8/14/2007 9:46:42 PM GMT
  • LafetLafet Posts: 23
    edited 2007-08-14 23:27
    Thank you very much Mike.
  • Tom G N SDTom G N SD Posts: 2
    edited 2007-08-15 01:08
    Thanks for the guidance, I will see what I can come up with. Just bought the education kit and some accessories. This should be exciting.

    take care

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    can you please pass the jelly....
  • scotch18scotch18 Posts: 4
    edited 2007-08-15 03:20
    Mike --

    RE the propeller conference.

    I'd be willing to attend. Would you if there were at least 15 paying attendees? It could really be something...

    John
Sign In or Register to comment.