c program for stepper motor in controlling the movement of a camera - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

c program for stepper motor in controlling the movement of a camera

i need help its urgent

a sourcecode for linux in c for the stepper motor


pls....

help

Comments

  • sumitxshahsumitxshah Posts: 20Member
    : i need help its urgent
    :
    : a sourcecode for linux in c for the stepper motor
    :
    :
    : pls....
    :
    : help

    Here is the code for controlling stepper motor...Hope u can compile it in Linux 9 (2.4 ker)
    /* Stepper.c */
    #include /* for printf() */
    #include /* for ioperm() */
    #include /* for usleep() */

    #include "port.h"

    #define PORT 0x378
    #define TIME 1000

    void clockwise(){
    int i;
    /* i've got one rotor cycle in 12 loops */
    for (i=0; i<12; i++){
    port_out(PORT, 0x01); /* 0001 */
    usleep(TIME);
    port_out(PORT, 0x03); /* 0011 */
    usleep(TIME);
    port_out(PORT, 0x02); /* 0010 */
    usleep(TIME);
    port_out(PORT, 0x06); /* 0110 */
    usleep(TIME);
    port_out(PORT, 0x04); /* 0100 */
    usleep(TIME);
    port_out(PORT, 0x0c); /* 1100 */
    usleep(TIME);
    port_out(PORT, 0x08); /* 1000 */
    usleep(TIME);
    port_out(PORT, 0x09); /* 1001 */
    usleep(TIME);
    }
    }

    void counter_clockwise(){
    int i;
    for (i=0; i<12; i++){
    port_out(PORT, 0x08); /* 1000 */
    usleep(TIME);
    port_out(PORT, 0x0c); /* 1100 */
    usleep(TIME);
    port_out(PORT, 0x04); /* 0100 */
    usleep(TIME);
    port_out(PORT, 0x06); /* 0110 */
    usleep(TIME);
    port_out(PORT, 0x02); /* 0010 */
    usleep(TIME);
    port_out(PORT, 0x03); /* 0011 */
    usleep(TIME);
    port_out(PORT, 0x01); /* 0001 */
    usleep(TIME);
    port_out(PORT, 0x09); /* 1001 */
    usleep(TIME);
    }
    }


    int main(){
    int i;
    if (ioperm(PORT, 1, 1) == -1)
    printf("There's something wrong...
    ");


    for (i=0; i<30; i++)
    clockwise();

    return 0;
    }


    /* port.h */

    #ifndef PORT_H
    #define PORT_H

    static inline int port_in( int port )
    {
    unsigned char value;
    __asm__ volatile ("inb %1,%0"
    : "=a" (value)
    : "d" ((unsigned short)port));
    return value;
    }

    static inline void port_out( unsigned short int port, unsigned char val ){
    __asm__ volatile (
    "outb %0,%1
    "
    :
    : "a" (val), "d" (port)
    );
    }

    #endif





    With Regards...
    Sumit Shah.

  • spsidpatelspsidpatel Posts: 3Member
    Hi,
    Sumit I want help in program of controlling stepper motor in 'C' language, Actually I am doing 1 embedded systrm project in which i have to run the motor from pulses can you tell me How can i program? And the motor is 5 wire unipolar.
    Regards
    Sid
  • spsidpatelspsidpatel Posts: 3Member
    Hi,
    Sumit I want help in program of controlling stepper motor in 'C' language, Actually I am doing 1 embedded systrm project in which i have to run the motor from pulses can you tell me How can i program? And the motor is 5 wire unipolar.
    Regards
    Sid
Sign In or Register to comment.