Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 22nd, 2013, 9:33 AM   #1
Roydavies209
Newbie
 
Join Date: Apr 2013
Posts: 6
Rep Power: 0 Roydavies209 is on a distinguished road
polling several pins

Hey

a few years ago I did some basic assembly coding for a project in uni, and now I've decided to use it again for a personal project but I have forgotten a lot of it since then and need some help getting back into it.

Now basically I want to write a program that will constantly poll several pins and when one reads high sned a 8 bit code to 2 other pins ( for transfer via usb)

could someone just give me some help on the commands I would need etc?

Thanks in advance
Roydavies209 is offline   Reply With Quote
Old Apr 22nd, 2013, 9:37 AM   #2
Ancient Dragon
Achieved Level 70

 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 4,345
Rep Power: 10 Ancient Dragon will become famous soon enoughAncient Dragon will become famous soon enough
Re: polling several pins

what operating system? Under MS-Windows and *nix you can't access the hardware directly, but must use either an existing device driver or write your own which runs at the kernel level. Other than that advice, I don't have the slightest clue how to do what you are asking.
__________________
PFO's FAQ is here
Forum Rules

There is no cow level (Diablo III)
If you never push yourself you will never improve (Diablo III)
Ancient Dragon is offline   Reply With Quote
Old Apr 22nd, 2013, 9:44 AM   #3
Roydavies209
Newbie
 
Join Date: Apr 2013
Posts: 6
Rep Power: 0 Roydavies209 is on a distinguished road
Re: polling several pins

ahh its for an external device run by a PIC18f4550, forgot to add that

I pretty much have switches etc on a number of pins and need to poll those pins and if they are high just send a signal to a pin

about the driver, im gonna be using the HID device driver already in windows but for now I though it may be best to get the program running as a stand alone device for now
Roydavies209 is offline   Reply With Quote
Old Apr 22nd, 2013, 10:19 AM   #4
Ancient Dragon
Achieved Level 70

 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 4,345
Rep Power: 10 Ancient Dragon will become famous soon enoughAncient Dragon will become famous soon enough
Re: polling several pins

you still have to use a device driver to access the usb port. I did something similar in my programs 20 years ago under MS-DOS 6.X, but not with MS-Windows or *nix. With MS-DOS there was no problem having direct access to hardware such as serial and parallel ports.
__________________
PFO's FAQ is here
Forum Rules

There is no cow level (Diablo III)
If you never push yourself you will never improve (Diablo III)
Ancient Dragon is offline   Reply With Quote
Old Apr 22nd, 2013, 10:22 AM   #5
Roydavies209
Newbie
 
Join Date: Apr 2013
Posts: 6
Rep Power: 0 Roydavies209 is on a distinguished road
Re: polling several pins

ahh I see, will have to look into that first then, thanks
Roydavies209 is offline   Reply With Quote
Old Apr 22nd, 2013, 1:27 PM   #6
sixstringartist
Programming Guru

 
Join Date: Jun 2005
Posts: 1,333
Rep Power: 13 sixstringartist will become famous soon enough
Re: polling several pins

You're going to have to be more specific on what you're stuck on. I assume you have the developers manual for the 18f4550 and the MPLab IDE?

I recommend using C and not assembly unless you specifically want to develop your asm skills.

Your polling loop can trigger at some frequency to call the polling routine, then you need to read from the particular pin your input is on.
i.e.
c Syntax (Toggle Plain Text)
  1. void processInput(void)
  2. {
  3. uint8_t in = RA1; //read from PortA pin 1
  4.  
  5. if(in)
  6. {
  7. //do stuff
  8. }
  9. return;
  10. }

If your input needs to be debounced you'll have to do it differently by keeping track of the previous input and executing after polling high more than once (or however many times is required by your circuit).

c Syntax (Toggle Plain Text)
  1. uint8_t processInput(uint8_t previous)
  2. {
  3. uint8_t in = RA1; //read from PortA pin 1
  4.  
  5. if(!previous)
  6. return in;
  7.  
  8. if(in)
  9. {
  10. //do stuff
  11. }
  12. return in;
  13. }
sixstringartist is offline   Reply With Quote
Old Apr 24th, 2013, 5:52 AM   #7
Roydavies209
Newbie
 
Join Date: Apr 2013
Posts: 6
Rep Power: 0 Roydavies209 is on a distinguished road
Re: polling several pins

ahh I see, c looks a lot simpler than what I've seen of assembler, i'll give that a go thanks
Roydavies209 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to generate pins dongreat Other Programming Languages 1 Mar 18th, 2012 3:13 AM
I Am Searching for a Free Online Polling Service lrh9 Coder's Corner Lounge 0 Dec 20th, 2011 9:04 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:44 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC