Go to Post You win Worlds by innovation. You win Worlds by determination. You win Worlds by engineering a robot so solid, that it successfully completes the game. - Zach O [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 15-09-2005, 22:38
astro1652's Avatar
astro1652 astro1652 is offline
Registered User
FRC #1652 (Team Overdrive)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Kenosha
Posts: 2
astro1652 is an unknown quantity at this point
Question Addressing I/O in Sections

I was wondering if it is possible to address sections of the I/O of the RC all at once. For example, I have a parallel LCD which uses 8 I/O lines for data. Thus, I want 8 pins of the I/O to be assigned either high or low at the same time instead of addressing them individually.

Code:
LCD_port = 5;
Assuming you can assign LCD_port a number of I/O pins, then telling it to assign 5 would turn on pins (bits) 0 and 2 (5 in binary is 101).

Is there anyway to do this that I am unaware of? Similarly, can I access just the upper and lower half of an unsigned int somehow? Please pardon me if these sound like n00b questions, as I am certainly a beginner in the C language.
  #2   Spotlight this post!  
Unread 16-09-2005, 00:11
BrianBSL BrianBSL is offline
Registered User
FRC #0190
 
Join Date: Sep 2004
Rookie Year: 2000
Location: Worcester, MA
Posts: 251
BrianBSL has much to be proud ofBrianBSL has much to be proud ofBrianBSL has much to be proud ofBrianBSL has much to be proud ofBrianBSL has much to be proud ofBrianBSL has much to be proud ofBrianBSL has much to be proud ofBrianBSL has much to be proud ofBrianBSL has much to be proud ofBrianBSL has much to be proud of
Re: Addressing I/O in Sections

Just a quick disclaimer - I'm not a programmer.

Are you looking to do it for ease or because you don't want the delay?

Have you tried it just doing them one-by-one? The digital IO of the PIC changes so quickly that I can't see it really being an issue doing them one by one. Otherwise, I'm pretty sure it would not be possible to do, as there are not 8 digital out's all on the same 8-bit port, except relay outputs, all 8 fowards are on port E and all 8 reverse's are on port D. If you used the relay outputs, you could just assign to the output byte for the respectable port (i think). If you just wanted ease, couldn't you write a function to split up your char input and assign it to the correct digital out bits?

Last edited by BrianBSL : 16-09-2005 at 00:14.
  #3   Spotlight this post!  
Unread 16-09-2005, 00:43
sciguy125 sciguy125 is offline
Electrical Engineer
AKA: Phil Baltar
FRC #1351
Team Role: College Student
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Sunnyvale, CA
Posts: 519
sciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond reputesciguy125 has a reputation beyond repute
Send a message via AIM to sciguy125 Send a message via MSN to sciguy125 Send a message via Yahoo to sciguy125
Re: Addressing I/O in Sections

I fully agree with Brian's assessment. Here's a little primer on PICs:

All the I/O lines are grouped into "ports". Each port can be viewed as a memory address. Each line corresponds to a bit in the char stored at the address. If you change whatever is at the address, you change the respective lines. If you look at the block of code in ifi_aliases.h starting at line 109, you can see which digital I/Os correspond to which ports on the processor. You'll notice that the biggest set of digital I/Os is only 7 bits wide.

As Brian pointed out, if you really need all 8 bits, it shouldn't be too hard to just write a function to handle each bit individually. Maybe something along the lines of
Code:
digital_io_01 = my_char >> 7;
digital_io_02 = (my_char & 64) >> 6; //64 is binary 010000000
digital_io_03 = (my_char & 32) >> 5; //32 is binary 001000000
...
Google "bitwise operators" if you don't know about them.
__________________

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GE/S/P a-- e y-- r-- s:++ d+ h! X+++
t++ C+ P+ L++ E W++ w M-- V? PS+ PE+
5- R-- tv+ b+ DI+++ D- G
------END GEEK CODE BLOCK------

Last edited by sciguy125 : 16-09-2005 at 00:55.
  #4   Spotlight this post!  
Unread 16-09-2005, 15:35
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: Addressing I/O in Sections

First off, I agree with Briand and sciguy.

However... theoretically, it may be possible to do what you want. There are a couple of things which have to be true: (and may not be, I've never tried doing this.)
  • The PIC ports have to be controlled by actual memory locations, not some seperate internal thing. (I think that's true.)
  • The PIC port memory locations have to be in consectutive locations every compile.
Assuming that both of those are true, you can probably create a char pointer to the first port that controls your LCD, then assign that the integer you want.
__________________

  #5   Spotlight this post!  
Unread 16-09-2005, 17:06
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Re: Addressing I/O in Sections

I'm assuming you are using an HD44780 compatible LCD. You don't need 8 pins that can be adressed as a group, only 4 if you use the LCD in 4-bit mode. All you have to do is setup the IO correctly and write to to the appropriate port register. Really, you don't actually need to have them written to at once since data is read in by the LCD only when you tell it to. I have controlled an HD44780 LCD using toggle switches before. Obviously, timing does not matter at all.

You will of course still need 3 more pins for E, R/W, and RS.
__________________
1139 Alumni

Last edited by Rickertsen2 : 16-09-2005 at 17:13.
  #6   Spotlight this post!  
Unread 16-09-2005, 22:23
devicenull devicenull is offline
Robot? We need a robot?
no team
 
Join Date: Sep 2004
Rookie Year: 1234
Location: n/a
Posts: 359
devicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nice
Re: Addressing I/O in Sections

I think he's more going for ease of use.. in which case:

#define LCD_Port digital_io_01 = digital_io_02 = digital_io_03 ...etc
  #7   Spotlight this post!  
Unread 16-09-2005, 23:01
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Addressing I/O in Sections

Quote:
Originally Posted by astro1652
...I have a parallel LCD which uses 8 I/O lines for data...
If your LCD uses the Hitachi HD44780 controller, the C18 libraries contain functions to handle the interface for you. I keep the latest version of the C18 library documentation here: http://kevin.org/frc. See page 75.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #8   Spotlight this post!  
Unread 18-09-2005, 19:28
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Re: Addressing I/O in Sections

Quote:
Originally Posted by Kevin Watson
If your LCD uses the Hitachi HD44780 controller, the C18 libraries contain functions to handle the interface for you. I keep the latest version of the C18 library documentation here: http://kevin.org/frc. See page 75.

-Kevin
wow. I'm getting rusty. I can't believe i forgot all about those.
__________________
1139 Alumni
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

vB 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
If statement in .h file or Indirect addressing? Kevin NAV code... Chris_Elston Programming 11 14-02-2005 23:39
Dynamic Input/Output Changing Paolo Control System 6 23-09-2004 19:09
Cheering Sections at Nationals Dirty Harry Championship Event 3 06-04-2004 00:30
Actual execution time measurement Dan Technical Discussion 5 24-03-2003 11:36
Programming Port I/O MikeDubreuil Programming 4 10-02-2003 17:07


All times are GMT -5. The time now is 20:27.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi