Help with my first PASM code
DRMorrison
Posts: 81
Hello,
I'm attempting to write some PASM and need help. This is my first attempt at using PASM, so be gentle.
This is what I'm trying to convert:
This code works as written, and represents one iteration thru the motor's wire combos. My oscilloscope shows the pulse width of the ON
time to be 1.48ms.
This is a method to move a 4-wire stepper in reverse. I have attempted to put something together, but am embarased to show it here.
I've played around with the timing of the 2 vars clkspd and spd, and this seems to be as fast as I can run this motor using SPIN, and
thought PASM might speed things up. Perhaps not?
THanks, Daniel
I'm attempting to write some PASM and need help. This is my first attempt at using PASM, so be gentle.
This is what I'm trying to convert:
PUB MoveCCW(num, spd) outa[10..11]~~ 'enable L293D repeat num outa[14..15] := 'output ON waitcnt(clkfreq/clkspd + cnt) 'wait outa[14..15] := 'output OFF waitcnt(clkfreq/spd + cnt) outa[12..13] := waitcnt(clkfreq/clkspd + cnt) outa[12..13] := waitcnt(clkfreq/spd + cnt) outa[14..15] := waitcnt(clkfreq/clkspd + cnt) outa[14..15] := waitcnt(clkfreq/spd + cnt) outa[12..13] := waitcnt(clkfreq/clkspd + cnt) outa[12..13] := waitcnt(clkfreq/spd + cnt) outa[10..11]~ 'disable L293D
This code works as written, and represents one iteration thru the motor's wire combos. My oscilloscope shows the pulse width of the ON
time to be 1.48ms.
This is a method to move a 4-wire stepper in reverse. I have attempted to put something together, but am embarased to show it here.
I've played around with the timing of the 2 vars clkspd and spd, and this seems to be as fast as I can run this motor using SPIN, and
thought PASM might speed things up. Perhaps not?
THanks, Daniel
Comments
Don't be embarrassed and show what you have.
It is easier for us here to help you on the first steps of learning curve if we can explain on your code snippet where the traps are hidden.
PASM can be some what confusing in the beginning (I am at the moment just one step ahead of you and got my first routines working)
Actually I am unsung the same approach: First a SPIN routine to test the Idea and after transferring that in PASM.
One question to your SPIN:
what is the difference between spd and clkspd and is that distinction required?
All the Best
Frank
spd is the value sent to the method and used as the on-time for the output to the L293D.
clkspd is the constant value used for the off-time of the output.
Pins 14 ,15 are set hi for the waitcnt(clkfreq/clkspd) period, advancing the stepper, and then are turned off. I found that laving these on for too long causes the current to go sky high.
The next waitcnt w/spd is how the user can set a speed for the motor without having the current on during the delay.
Turn on a switch, wait a little, turn off the switch, wait as much as required to achieve the desired speed.
That's a long answer, hope it makes sense.
As far as PASM, I was only able to get one waitcnt. I couldn't figure how to turn on only the 14 & 15 pins, wait, and then turn them off again.
I'm not sure, but I think that this will result in a shorter on time than off. 100-ON, and 200-OFF?
Embarrassing effort.
Daniel
The code you've posted however is not legal Spin... Assignments need a RHS...
The basic elements of PASM you need are easy, something like:
I think there is an issue with the forum when you use a % where it doesn't show characters.
Bean
Bean
I'm not sure what an RHS is. Could you explain?
I see that the percent sign and numbers that I placed in the original code block didn't make it.
It is suppose to be:
outa[14..15] := *10 'replace percent sign with the * char
here is the MoveCW method as seen in my editor:
Bean, I like the way that you have written that code; it's easy for me to understand.
Also, do I call this just like a spin method? like this?
Thanks, Daniel