Stepper motor

Başlatan Cesar35, 03 Mayıs 2022, 17:52:20

Cesar35

Hi
to all
About stepper motors, there is a possibility to make a limit in the program in picbasic. Could someone help me with this
already thank you

SYMBOL  RX_IN=PORTA.3
'***************************************************************

RX VAR BYTE            'Declared Byte For LCD Splash Screen
I  VAR BYTE
'****************************************************************


Main:                   
    Serin2 RX_IN,84,[WAIT("CMD"),RX]
   
    If RX = "A" Then PARA_CIMA
    If RX = "B" Then PARA_BAIX
    If RX = "C" Then ESQ
    If RX = "D" Then DIR
    Goto Main

PARA_CIMA:

    For i = 0 To 4
    LookUp i,[1,2,4,8],PORTB 
    pause 5 
    Next i
    Goto Main

PARA_BAIX:       
    For i = 0 To 4
    LookUp i,[8,4,2,1],PORTB
    pause 5 
    Next i
    Goto Main


ESQ:     
    For i = 0 To 4
    LookUp i,[16,32,64,128],PORTB 
    pause 5 
    Next i
    Goto Main

DIR:       
    For i = 0 To 4
    LookUp i,[128,64,32,16],PORTB 
    pause 5 
    Next i
    Goto Main
    END

ete

Cesar,
You could not get any reply because your request is not understandable.
I could not understand really what do you want. ?
What kind of limit do you need.?

Ete

Cesar35

I am sorry
Let me explain better and leave the engine in the position I want. When it reaches the end of the course it stops. As it is controlled by a pot
thanks

ete

Cesar,
Still there is a problem. I look your program
- LookUp i,[1,2,4,8],PORTB  this line turn the step motor one fixed direction let say Right side by using Single phase drive.

-  LookUp i,[8,4,2,1],PORTB this line turn the step motor rever side again by using single phase drive.

- LookUp i,[16,32,64,128],PORTB  I do not know what is this code. Like there is another step motor and it is connected to the pins RB4 -RB7 and the code turn that motor right side again in single phase drive.

- LookUp i,[128,64,32,16],PORTB  this code turn the second motor to the reverse direction.

Now if you use that program if you give the right commands as A-B-C-D two motors will turn as requested.
I think you want to stop the motor when it is turn one complete cycle.
Each commant turn the motor one step and if you use 1,8 degree/step motor you need 200 puls (command) to make one tour. In this case you need one variable like (LIMIT VAR BYTE) and as soon as you turn in one direction you need to increase the LIMIT variable as LIMIT=LIMIT+1 then you need to control it if you reach to the number of 200 or not. If you reach to the 200 you can stop the motor by giving PORTB=0 command. Meanwhile you clear also the LIMIT variable as LIMIT=0.

You can use different variables for two motor. As I told you I do not understand very well what do you need. For that reason I can not help you more. Sorry.

Ete

Powered by EzPortal