PDA

View Full Version : Am I reading this assembler correctly?



crhomberg
- 9th November 2007, 19:52
Hi All,

I am still struggling with my stepper motor driving itīs PBL3717's.
I have a program from another guy written in assembler which works great, it rotates very slowly and also smoothly. I copied the sequence and my version seems to always be rough and bumpy movements (using the same PCB controller)
The letters I0 & I1 are the current settings for A and B coils respectively.
They are set as follows:
I0 high I1 high = No current
I0 Low I1 high = Low current
I0 High I1 Low = Medium Current
I0 Low I1 Low = High Current (full power 400mA)

I have attached the assembler version and my PBP version, If anyone is good with assembler could you please check it for me.

Best Regards

Chris

Darrel Taylor
- 9th November 2007, 20:20
Hi Chris,

I think each step has the same problem ...

'* step 1*
A=1
I0A=0
I1A=1
B=1
I0A=0 ; should be I0B
I1B=0
PAUSEUS TIME

crhomberg
- 9th November 2007, 21:16
Thanks Darrel,

Yes that was an error but even after correcting that it still is moving "jumpily"
Has that guy got some secret I don't know about?



Regards

Chris

crhomberg
- 9th November 2007, 21:22
I revised the assembler and found that it has an additional routine above.
My spanish is not great but can you figure out how it modifies the stepping?

Regards

Chris

Darrel Taylor
- 9th November 2007, 21:32
Step 12 seems to be different between the two versions. (I1B)

Other than that, it would help to see the rest of the ASM program, so I can see in which order the subroutines are called.
<br>

crhomberg
- 12th November 2007, 12:35
You have for a long time been an inspiration to me on how you can interctively work with assembler and PBP. Your Instant interrupts are a great result of that.

Thanks for checking out the code I posted, I changed the I0B's of my code but the motor continued with a jerky movement when running slowly. The project is a X-Y yoke for a CCTV camera using 2 bi-polar stepper motors. The person who designed the original camera has long since dissapeard and I need to add some new features. My problem is that assembler is worse than trying to read Chinese for me.
His version rotates slowly as smooth a silk but when I program that same PIC with my version in PBP it looks like a tractor idling. I read the datasheet of the PBL3717 and I think I have written it correctly. (I cannot change to another chip as the PCB and components have been purchased)
He definately wrote all movements to run in quarter step mode.I have attached his full code (The slave code is the second pic which just checks a parrallel bus to see what movements it must make) and my modified code that I tried on friday.

Best Regards

Christopher Rhomberg

Darrel Taylor
- 12th November 2007, 17:30
Thanks Chris,

Isn't it great that you can jump in and out of ASM at will?
The most powerfull feature of PBP.

It looks like Step 12 is still the same.
Maybe it just didn't get changed in the attached file, but I want to make sure you've tried it.
<table border=1 cellpadding=8><tr><td align=center>ASM</td><td align=center>PBP</td></tr><tr><td valign=top><pre>paso_12h:<br> bsf PORTB,0<br> bsf PORTB,1<br> bcf PORTB,2<br> bcf PORTB,3<br> bcf PORTB,4<br> bcf PORTB,5<br> movlw 11<br> movwf paso_h<br> call retardo_velocidad<br> return</pre></td><td valign=top><pre>'* step 12*<br>A=1<br>I0A=1<br>I1A=0<br>B=0 <br>I0b=0<br>I1B=1 ; should be 0<br>PAUSEUS TIME</pre>
</td></tr></table>

Looking at the rest in the mean time.

crhomberg
- 12th November 2007, 20:08
Really Darrel, You always seem to spot the errors quick.

Like usual I didn't see that small error in step 12, even though you mentioned it.
Now it is rotating very smoothly.
If you have any other nasties you can see in that code please tell me.


ManyThanks

Chris

Darrel Taylor
- 13th November 2007, 03:46
Really Darrel, You always seem to spot the errors quick.
It's a Curse, really.

I can spot things in other peoples programs like it's got a blinking red light on it.
But in my own programs, it can take weeks to find a simple bug.

er - ok well I think it works that way for everyone. I just never ask for help. :eek:


If you have any other nasties you can see in that code please tell me.
Well, if it's turning smoothly then I think the "Nasties" are gone. But I might be able to make some new ones for you.

Sorry, my other curse is the need to reduce redundant code (RRC).
So here's my idea.

Qstep VAR BYTE
Coils VAR BYTE

StepForward:
Qstep = Qstep + 1
IF Qstep >= 16 THEN Qstep = 0
GOTO DoStep

StepReverse:
IF Qstep = 0 then Qstep = 16
Qstep = Qstep - 1

DoStep:
LOOKUP Qstep,[%001101,%001111,%001100,%001010,%101000,%111000,%1 00000,%010000 _
,%000100,%000110,%000101,%000011,%100001,%110001,% 101001,%011001], Coils
PORTB = (PORTB & %11000000) | Coils
PAUSEUS TIME
RETURN
Completely un-tested.

crhomberg
- 13th November 2007, 12:20
Very neat Darrel, very neat!
Why donīt you ask when you have problems, even the best professionals can be helped by a second set of eyes to check the design.

Again,

Thank you very much

Chris Rhomberg