Need speed but ASM is too much to tackle.
T Chap
Posts: 4,223
In cases where Spin is not fast enough, is there any alternative to assembly? I see people discussing C and similar languages but have no idea what is going on with those languages either. Is there a compromise to get more speed with a simpler learning curve than asm?
I have looked at asm enough to consider it too much a time investment to solve what I need done. A consultant for a fee seems the only option at the moment to handle one section of code for a project that requires up to 50k instructions per second. Right now the Spin equivalent is not even at 10% the speed needed. What I am considering now is scaling the speed down by 10% just to get the working idea done, then seeing if someone can convert it for a reasonable fee.
I have looked at asm enough to consider it too much a time investment to solve what I need done. A consultant for a fee seems the only option at the moment to handle one section of code for a project that requires up to 50k instructions per second. Right now the Spin equivalent is not even at 10% the speed needed. What I am considering now is scaling the speed down by 10% just to get the working idea done, then seeing if someone can convert it for a reasonable fee.
Comments
Sometimes you can play tricks with counters etc to do something quicker but in general if you want more speed asm is the way to go. Using multiple cogs together is another option too but it doesn't sound like that will be an option.
I learnt pasm while programming up a project and that was over two weeks, if you know what you need to do (which you do because you have the spin) it can be fairly straight forward to get something working. Especially with a little help [noparse];)[/noparse]
Cheers,
Graham
There's no middle ground between Spin and PASM, the best you have is an alternative language such as ImageCraft C which runs at near PASM speed but hides the complexity of PASM from you. There's also JDforth which can improve upon Spin performance but again you'll have a learning curve there. I don't know of any other languages which target the Propeller.
You maybe able to find someone to translate what you have into PASM. If it's a simple piece of code someone may do that for free or cheaply. More complicated and it may well cost serious money. It would all depend on what it is.
To explain a little more detail. The code is related to driving a motor with pulses, reading an encoder and comparing the two. The max speed of the encoder and pulses is around 48k per sec each. The rotary obj already is making the position available in a variable, but instructions are required to create new pulses (a counter is not an option, no pins to sacrifice for ctra). The pulses are virtual, and do nothing but count and create a speed profile by which an asm PWM object models the value of. Then the compare and correct instructions are required, with a number of if pos > new position type instructions that keep track of things. The fastest I can run the Spin variation is around 6k pulses per sec.
For now, just to keep making progress, I will scale the whole thing down to 10% resolution (divide the encoder by 10), and translate it as it goes. Actually the parts are quite simple, there are just quite a few phases to the motion, including reverse, ramp up, ramp down, etc, that make it look big. I will post the spin version soon and get opinions on how complex or easy it might be to translate.
LCC runs at 5.0 MIPS
& PASM runs at 20MIPS.
@ Originator, PASM doesn't look that hard, in fact it seems a bit easier than spin (in concept) to me. DeSilva's tutorial on PASM takes you from blinking the LED to more complex tasks, setting Registers (CTR,VCFG,CLK,DIR,IN,OUT, ect..)·in PASM isn't much more difficult than doing it in spin. You should be familiar with the "IF" structure, most ASM tasks can be performed with this type of· conditional structure. Shifting, REVersing bit patterns, add, sub, shift, rotate, multiply, divide, can all be done in PASM, maybe easier than SPIN. Study and give yourself alittle time to learn it. If your doing something with shifting out opperations, look at this thread. The VSU hardware can do more than video.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
E3 = Thought
http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.
your description is a little confusing but it seems simple enough for an early asm attempt.
Graham
I found PASM much easier and friendlier than any other ASM i've seen
I say you muster up the courage and go through those examples. I started with FullDuplexSerial object and it was a very good base.
Funny thing is, i have not touched spin at all! all PASM baby
What is the desired servo loop time? 1000 loops per second is usually heaps. That should be easy to achieve, even in Spin. It sounds like you need to decouple the parts some more. Specifically, the pulse output routine.
Actually, do the output pulses represent position stepping or is it more like PWM or the "servo" pulses of hobby controllers? If they are real position steps then a servo loop is not needed. The drive is performing that function for you already. All you need to do is output the pulses at a pre-calculated rate and length. Using the precise feedback only for end of move corrections or error checking, if needed.
object just to experiment with it. This is just a program that generates pulses that reflect
actual distance on the motor/encoder. It is going to be a closed loop servo of sorts. The
PWM will chase the pulses, trying at all times to reflect the error between current position and new position.
So far this is working great but needs a lot of work still, I have not gotten the boards back
yet from assembly to test the actual motion.
It is currently sending out a PWM duty (0-1000) based on the pause between pulses (accel).
That may change if I can get PID to chase the position error in a better way.
Unless scale the encoder down, the default count is 16000 per revoltion, or 4000 per inch. I a
testing with it reduces by /10, which may actually suffice at 400 per inch, in which case the
spin can handle it. However, since the max speed will be 12 inches a second, that would mean
4800 instructions a second just to compare the encoder against the current position, not to mention
correction instructions, and all the other code below.
I definitely intend to get started on learning PASM. Thanks for the tips guys. The code is already at
around 1800 lines for the entire project, and no where near done.
Where does this stuff below rate in terms of complexity if I study the tutorials for a bit?
Post Edited (Originator) : 10/6/2008 12:53:43 AM GMT
What I would do is shift the PID to it's own Cog for the short term. And late incorporate it with the Duty program. The PID servo loop can run, tracking a target value, on it's own at a higher loop rate than what the profile generator needs to.
Next would be to modularise the profile building routines into tidy, well documented functions. This can be a pain keeping a tidy structure but you will be rewarded later on.
Hey guys, can someone please explain to me why it appears that that there is no resister or cell that stores the name 'loop', yet the jmp seems to know where to go?
According to the Celo-Cel5, loop and ex01Aa do not get written into any 'cells'.
Thanks.
the label loop also on the same line as the instruction)
There is a symbol table inside the compiler (assembler), which stores the address 'loop', and the compiler
places this stored value every time 'loop' is used as source or destination in an instruction.
Hope that helps
Andy