B4R Question Help me about use A4988 Stepper motor library

vali khandangoll

Active Member
Hi all of you.
I want to use a a4988 stepper motor driver .
I using a dvd writer stepper motor.
I have a library that attached.
and I have written code below.

Sub Process_Globals
Public Serial1 As Serial
Public motorX As A4988
Public dir_pin As Pin
Public step_pin As Pin
Public enable_pin As Pin
Public ms1_pin As Pin
Public ms2_pin As Pin
Public ms3_pin As Pin
End Sub

Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
ms1_pin.Initialize(1,ms1_pin.MODE_OUTPUT)
ms2_pin.Initialize(2,ms2_pin.MODE_OUTPUT)
ms3_pin.Initialize(3,ms3_pin.MODE_OUTPUT)
step_pin.Initialize(5,step_pin.MODE_OUTPUT)
dir_pin.Initialize(6,dir_pin.MODE_OUTPUT)
enable_pin.Initialize(7,enable_pin.MODE_OUTPUT)

dir_pin.DigitalWrite(True)
step_pin.DigitalWrite(True)
enable_pin.DigitalWrite(True)

ms1_pin.DigitalWrite(True)
ms2_pin.DigitalWrite(True)
ms3_pin.DigitalWrite(True)
End Sub

I can not continue.
 

Attachments

  • A4988.zip
    17.7 KB · Views: 166

janderkan

Well-Known Member
Licensed User
Longtime User
I think that you should toggle the step_pin to move the motor.
B4X:
sub timStep_Tick
    step_pin.DigitalWrite(True)
    Delay(10)
    step_pin.DigitalWrite(False)
end sub
 
Upvote 0

vali khandangoll

Active Member
I think that you should toggle the step_pin to move the motor.
B4X:
sub timStep_Tick
    step_pin.DigitalWrite(True)
    Delay(10)
    step_pin.DigitalWrite(False)
end sub
thanks.
I defined timstep as timer and write your code.
but not worked.

A4988 library have 3 command.

steps(dir_pin,step_pin,enable_pin,ms1_pin,ms2_pin,ms3_pin)
and
begin(rpm,microSteps)
and
MicroSteps

I think we must use that.
 
Upvote 0

vali khandangoll

Active Member
what problem is in picture ?
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    10.4 KB · Views: 145
Upvote 0

candide

Active Member
Licensed User
this wrapper should help at A4988 management with B4R

it is wrapper for class A4988 and inherited class BasicStepperDriver.
parameters for "State" and for "Mode" are declared in B4R and can be managed by name.

Differences with arduino library:
- void setSpeedProfile1(ArrayInt* profile);
- ArrayInt* getSpeedProfile();
both are working with an ArrayInt 3 elements on B4R and with a struct 3 elements in arduino side. (conversion is done by wrapper)

with a few modifications, all examples in Arduino library can be adapted to B4R .
a B4R example is added in zip file
 

Attachments

  • rA4988.zip
    43.2 KB · Views: 157
Upvote 0

vali khandangoll

Active Member
this wrapper should help at A4988 management with B4R

it is wrapper for class A4988 and inherited class BasicStepperDriver.
parameters for "State" and for "Mode" are declared in B4R and can be managed by name.

Differences with arduino library:
- void setSpeedProfile1(ArrayInt* profile);
- ArrayInt* getSpeedProfile();
both are working with an ArrayInt 3 elements on B4R and with a struct 3 elements in arduino side. (conversion is done by wrapper)

with a few modifications, all examples in Arduino library can be adapted to B4R .
a B4R example is added in zip file
thanks again.
Solved
 
Upvote 0
Top