Do you have a question? Post it now! No Registration Necessary
Subject
- Posted on
February 27, 2009, 8:46 pm

hello there, i am new to this group.....i am working on a simple
project " Controlling a stepper motor in real time linux". actually i
am a student of undergrad....fact is with the help of google....i am
able to run the motor from both non-real time linux and rtlinux.....
Problem:
=======
in non-real-time the motor works fine....it gives full 360 degree
rotation with 5 - 7 degree each pulse......with rtlinux for eight
step it gives same result like non-real-time but after step eight
means end of while loop the motor rotate back at least 20 degree....i
dont no what to do....can any one help me understand what is happening
here.....
note:
===
if i use only one pthread_wait_np(); after step eight.....and disable
other.....it gives 27-30 degree rotation per pulse and never rotate
back and finish 360 degree.....
i tried my best to present my problem....
Thanks.
stepper motor driver ckt i am using ULN2003 , both programs ( linux
and rtlinux) are following:
==========================non-real-time-linux c
program==================
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <sys/io.h>
#define base 0x378 /* printer port base address */
main()
{
if (ioperm(base,1,1))
fprintf(stderr, "Error: Couldn't get the port at %x\n", base), exit
(1);
while(1){
outb(0x01, base);
sleep(1);
outb(0x03, base);
sleep(1);
outb(0x02, base);
sleep(1);
outb(0x06, base);
sleep(1);
outb(0x04, base);
sleep(1);
outb(0x0c, base);
sleep(1);
outb(0x08, base);
sleep(1);
outb(0x09, base);
sleep(1);
}
}
=================================End==============================
=============================rtlinux program========================
#include <linux/module.h>
#include <linux/kernel.h>
#include <rtl_time.h>
#include <rtl_sched.h>
#include <asm/io.h>
#include <time.h>
#include "common.h"
int period10%00000000;
int periodic_mode=0;
int one=0x01;
int two=0x03;
int three=0x02;
int four=0x06;
int five=0x4;
int six=0x0c;
int seven=0x08;
int eight=0x09;
pthread_t thread;
void *
bit_toggle(void *t)
{
pthread_make_periodic_np(thread, gethrtime(), period);
while (1){
outb(one,LPT);
one = ~one;
pthread_wait_np();
outb(two,LPT);
two = ~two;
pthread_wait_np();
outb(three,LPT);
three = ~three;
pthread_wait_np();
outb(four,LPT);
four = ~four;
pthread_wait_np();
outb(five,LPT);
five = ~five;
pthread_wait_np();
outb(six,LPT);
six = ~six;
pthread_wait_np();
outb(seven,LPT);
seven = ~seven;
pthread_wait_np();
outb(eight,LPT);
eight = ~eight;
pthread_wait_np();
}
}
init_module(void)
{
pthread_attr_t attr;
struct sched_param sched_param;
pthread_attr_init (&attr);
sched_param.sched_priority = 1;
pthread_attr_setschedparam (&attr, &sched_param);
pthread_create (&thread, &attr, bit_toggle, (void *)0);
return 0;
}
void
cleanup_module(void)
{
pthread_delete_np (thread);
}
================================End=============================
Site Timeline
- » pseudo ports
- — Next thread in » Embedded Programming
-
- » Embedded systems that can run Doom
- — Previous thread in » Embedded Programming
-
- » Using C preproc to uniquely identify structure members
- — Newest thread in » Embedded Programming
-
- » Che basetta fpga prendere per esperimenti?
- — The site's Newest Thread. Posted in » Electronics Hobby (Italian)
-