LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-29-2003, 05:33 AM   #1
jacs
LQ Newbie
 
Registered: Oct 2003
Posts: 7

Rep: Reputation: 0
PWM Signal


Hi

Stupid question but I made a program with an LCD and a slider with Kdevelop and RH 9. This thing works and I have manage to access parallel port also and changed some led connected. Problem for me is that I need to have a routine that is running all the time and looking for changes from the slider to get my PWM signal.

So what I'm looking for is where in my files should I put in this routine or should it be done with pthreads? Or do I have bad luck thinking.

Regards
Jacs
 
Old 10-29-2003, 09:05 PM   #2
xexix
Member
 
Registered: Oct 2003
Location: Long Island, N.Y., U.S.A
Distribution: Gentoo, Slackware
Posts: 79

Rep: Reputation: 15
It all depends on how much precision you need with your slider. If you need high precision you may need to use real time extensions such as RTAI (http://www.aero.polimi.it/~rtai/), otherwise you might find the the slider doesn't respond smoothly on your system. Although threads would a decent solution without resorting to using real-time stuff, you can try the fork() system call to have the parallel port checking routine as a background process.

vague example (put this somewhere in your main):

int main(void) {
int cpid, status;

cpid = fork();

if (cpid < 0) {
exit(1); /* fork failed */
} else if (cpid == 0) { /* child process */
/* insert your parallel port reader function */
} else { /* parent process */
/* your stuff */
}

/* after your done with your stuff make sure to kill the child */

kill(cpid, SIGKILL);
wait(&status); /* wait for child to finish */
}

you may find this interesting:
http://www.linuxgazette.com/node/view/100
 
Old 10-30-2003, 01:16 AM   #3
jacs
LQ Newbie
 
Registered: Oct 2003
Posts: 7

Original Poster
Rep: Reputation: 0
Thank you, shall try this when I come home from work. What it shall do is to do like this I think.

outb(1,0x378);
usleep(slider1->value());
outb(0,0x387);

Okay the value of the PWM signal shall be between 1mS to 2mS. Trying to make a program so that I can connect my servos on my planes that I'm building to see it's function with out grabbing my radio and receiver from other planes. And yes I'm only want the signal from the port not to drive the servos (have an external source for that).

There is also a windows program with a PIC 16F84 driven by the serial port but I what to make it by myself.

After reading the link you sent I have to rethink the hole thing again.

Regards
Jacs

Last edited by jacs; 10-30-2003 at 01:24 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
squid stops due to signal 6 and signal 25 simplyrahul Linux - Software 3 05-28-2011 01:05 AM
What's a SIGNAL? wmcase Linux - General 5 03-16-2004 08:51 PM
Signal 6: Unknown Signal <=> Error with MAYA4.X under Linux SOLVED!!!! Faeroon Linux - Software 9 05-09-2003 01:57 PM
Signal: 6 (Unknown Signal) - Problems running a program Faeroon Linux - Software 86 01-14-2003 12:08 AM
signal 11 jbrealey Linux - Newbie 2 10-08-2002 10:07 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration