​ ​ ​ ​ stepper motor control
Results 1 to 5 of 5

Thread: stepper motor control

  1. #1
    New Member
    Join Date
    Jul 2012
    Location
    United Kingdom
    Posts
    26

    Default stepper motor control

    Sorry about this but I am at a loss with the stepper motor 28BYJ 48 control and wiring. I have an 18m2 project board which I have successfully controlled dc motors with but I am needing some help with this stepper motor. I want it to turn 2/3 of a turn in approx 5 seconds (time not critical). That seems to be 1364 pulses but I do not know how to connect the motor and cannot figure out a code. I assume that I can connect the motor directly to the project board which has the Darlington and a 5v supply but how do I connect the 5 wires. There does not seem to be a negative connection anywhere. Could anyone suggest a suitable code. Thanks for any help

  2. #2
    Senior Member
    Join Date
    May 2012
    Location
    Macduff
    Posts
    1,057

    Default

    Did you get the small driver board with it? If so you use it under picaxe control
    Time is natures way of stopping everything going wrong at once

  3. #3
    Senior Member
    Join Date
    Sep 2016
    Location
    United Kingdom
    Posts
    755

    Default

    search this forum.
    I have several. they need 4 pins to control and you turn the port bits on/off in sequence or reverse sequence to reverse. each change is a pulse.each pulse moves motor part turn. these are geared.
    The uln driver boards waste pins.
    I used a uln2803 which drives 2 motors driven from a mcp23017 i2c driver so only 2 pic lines needed.
    I posted somewhere about using with x2 and interrupt and mseries and running 2 programs.
    http://www.picaxeforum.co.uk/showthr...ghlight=stan74
    https://www.youtube.com/watch?v=Td7y...Ku1sLw&index=9
    A 100Hz --they run at 100Hz, interrupt to send 4 low bits ie motor 1 and upper 4 bits as i2c but adaptable.
    4 phase works best ie
    do
    port.00001001
    port.00000011
    port.00000110
    port.00001100
    loop
    'This will be called when the Timer overflows
    Sub motors
    ' Set the register to 6 to give us the 10ms Interrupt.
    ' Use the Timer Calc' application that is part of Mister E PIC Mutl-calc tookset to calculate the value.
    ' Ensure you set the Prescaler in the InitTimer1 shown above
    SetTimer 1, 25538 ;reset timer
    ;left stepper motor
    if lmotforward>0 then
    if lmotforward=1 Then
    lmotor++
    if lmotor=5 then lmotor=1
    else
    lmotor---
    if lmotor=0 then lmotor=4
    end if
    ;
    select case lmotor
    case 1
    lmotval=144
    case 2
    lmotval=192
    case 3
    lmotval=96
    case 4
    lmotval=48
    End Select
    Else
    lmotval=0
    end if
    ;right stepper motor
    if rmotforward>0 then
    if rmotforward=1 Then
    rmotor++
    if rmotor=5 then rmotor=1
    else
    rmotor---
    if rmotor=0 then rmotor=4
    end if
    ;
    select case rmotor
    case 1
    rmotval=9
    case 2
    rmotval=3
    case 3
    rmotval=6
    case 4
    rmotval=12
    End Select
    else
    rmotval=0
    end if

    MCP23017_sendbyte (MCP23017_addr,MCP23017_GPIOA,lmotval+rmotval) ;sets porta to lmotval+rmotval

    End Sub
    Last edited by stan74; 02-06-2018 at 00:48.

  4. #4
    Senior Member
    Join Date
    Feb 2012
    Location
    London
    Posts
    2,872

    Default

    Hi,

    Yes there should be several threads on the forum dealing with that motor. I think this might be a good pace to start.

    Cheers, Alan.

  5. #5
    New Member
    Join Date
    Jul 2012
    Location
    United Kingdom
    Posts
    26

    Default

    Thanks for the suggestions I will check them out.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •