Go to Post The real question is has anybody ever learned anything actionable from a game hint or red herring. - Joe Ross [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-06-2005, 11:39
ImmortalAres ImmortalAres is offline
Registered User
no team
 
Join Date: May 2005
Location: Clarkson University
Posts: 33
ImmortalAres is an unknown quantity at this point
Programming a 2nd PIC

In order to easily handle the analysis of PWM signal input I'm using a second PIC (PIC18F452) to do the calculation and plan on using the RC as the Master device where the two PICs communicate through the TTL serial line on the RC and a serial port on the demo board (PICDEM 2 Plus demonstration board from Microchip). I have a question about the programming of the 2nd PIC. Since both 40 pin PIC's are of the PIC18Fxx2 family their pin configuration and registers associated with each are the same. Does this then make it possible to transport the code that I had working on the RC to this 2nd PIC directly? Or do I have to completely rewrite my own code?

(Essentially I don't know what's in that RC box and if there is more to it then just a PIC and tracks that attach the pins to the headers for signal input on the outside)

Any advice would be greatly appreciated
  #2   Spotlight this post!  
Unread 15-06-2005, 12:59
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: Programming a 2nd PIC

Quote:
Originally Posted by ImmortalAres
In order to easily handle the analysis of PWM signal input I'm using a second PIC (PIC18F452) to do the calculation and plan on using the RC as the Master device where the two PICs communicate through the TTL serial line on the RC and a serial port on the demo board (PICDEM 2 Plus demonstration board from Microchip). I have a question about the programming of the 2nd PIC. Since both 40 pin PIC's are of the PIC18Fxx2 family their pin configuration and registers associated with each are the same. Does this then make it possible to transport the code that I had working on the RC to this 2nd PIC directly? Or do I have to completely rewrite my own code?

(Essentially I don't know what's in that RC box and if there is more to it then just a PIC and tracks that attach the pins to the headers for signal input on the outside)

Any advice would be greatly appreciated
You can't just program it with a project from the RC, the RC has 2 pic chips in it (a master processor, and the user processor that you program) and therefore a lot of the IO (tho mostly output) you do on the user processor actually goes through the master processor. You would have to start your project from scratch, but you could certinally reuse functions that you wrote for the RC on the demo board.
  #3   Spotlight this post!  
Unread 15-06-2005, 13:47
fowlerm's Avatar
fowlerm fowlerm is offline
Bringing .NET to Robots
AKA: Matthew Fowler
FRC #0312 (Heatwave); FRC #1369 (Minotaur)
Team Role: Engineer
 
Join Date: Apr 2005
Rookie Year: 2001
Location: St. Petersburg, FL, USA
Posts: 78
fowlerm has a spectacular aura aboutfowlerm has a spectacular aura aboutfowlerm has a spectacular aura about
Re: Programming a 2nd PIC

The two PICs in the RC are 18F8520 80-pin devices The Microchip C18 compiler can build for the 452's so the code that does your calculation shouldn't have to be rewritten (if it's in C). You will need to create a new project in MPLAB from scratch and use a linker file for the 452 instead of the 8520. There is no need to include RC specific code in your new project, but you may want to look at ifi_aliases.h and ifi_picdefs.h to get an idea of how to define aliases for the hardware registers. Keep in mind that the 452 doesn't have all of the hardware that the 8520 has, so you may want to look at the 452's spec sheet to make sure you haven't aliased a register that doesn't exist. You can reuse some of the IFI code, like the serial driver, this may save you some time in getting you project up and running.
  #4   Spotlight this post!  
Unread 16-06-2005, 00:51
Gdeaver Gdeaver is offline
Registered User
FRC #1640
Team Role: Mentor
 
Join Date: Mar 2004
Rookie Year: 2001
Location: West Chester, Pa.
Posts: 1,356
Gdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond repute
Re: Programming a 2nd PIC

I knew you would be back on line asking for help with the pic demo board. First, unless I missed something, the demo board doesn't support in circuit programming. I believe you have to use a separate chip programmer. This means that you have to pop the processor out- program it- pop it back in - test - pop it out- reprogram - pop it in - test. This isn't very productive.
Second, using the pic compiler and IDE provide allot of power, but add complexity to the proto typing effort. There is allot of initializing that has to be done for both the processor, C compiler, linker and assembler. IFI has done this for us. You'll have to duplicate it and strip out the stuff they set up for the dual processor. Third, if your using the free software from microchip , the optimizer is left out. Your code will take more memory in most cases. If you use the IFI provided software, they had it customized for the IFI controller. Don't Know if it affects working with other chips. There are other options out there that might be better for experimentation and proto typing.
What worked for me is the Kronos robotic dios chip and a work board
http://www.kronosrobotics.com/xcart/...52&cat=0&page=
http://www.kronosrobotics.com/xcart/...68&cat=0&page=
The work board has a solderless bread board for proto typing. The Dios chip is the same chip your using only it has a powerful basic interpreter on it. They have examples on site for sonar sensors, Sharp IR senors, digital compasses, serial communications, PWM, quadrature, timers, etc. Allot of work has been done for you. You can make a program change and 3 seconds later your code is running. I've used this set up with some students that just couldn't get started this year with programming on our team. I spent a couple hours with them and this setup. They're off and running teaching me now.
  #5   Spotlight this post!  
Unread 16-06-2005, 11:32
ImmortalAres ImmortalAres is offline
Registered User
no team
 
Join Date: May 2005
Location: Clarkson University
Posts: 33
ImmortalAres is an unknown quantity at this point
Re: Programming a 2nd PIC

the demo board supports programming through the mplab ICD2 through an rj-11 plug on the board. and yea, i quickly became aware of how i had to rewrite the start up, pic def, and alias file myself. Which i have no problem doing excpet for the fact that I seriously got lost in the pic def file. They're defnining things in structs that I can't find anywhere on the data sheet (ie the following)

Code:
extern volatile near unsigned char       RCSTA2;
extern volatile near union {
  struct {
    unsigned RX9D:1;
    unsigned OERR:1;
    unsigned FERR:1;
    unsigned ADEN:1;
    unsigned CREN:1;
    unsigned SREN:1;
    unsigned RX9:1;
    unsigned SPEN:1;
  };
  struct {
    unsigned RCD8:1;
    unsigned :5;
    unsigned RC9:1;
  };
  struct {
    unsigned :6;
    unsigned NOT_RC8:1;
  };
  struct {
    unsigned :6;
    unsigned RC8_9:1;
  };
} RCSTA2bits;
i got the first struct and i undersntad what's going on but what on earth is RCD8:1 or the :5 doing. i'm quite lost there.

maybe i'm approaching this totally wrong

any advice?
  #6   Spotlight this post!  
Unread 16-06-2005, 11:34
ImmortalAres ImmortalAres is offline
Registered User
no team
 
Join Date: May 2005
Location: Clarkson University
Posts: 33
ImmortalAres is an unknown quantity at this point
Re: Programming a 2nd PIC

thanks for the advice on that other prototyping board, it sounds extremely useful
  #7   Spotlight this post!  
Unread 16-06-2005, 11:46
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,334
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: Programming a 2nd PIC

Quote:
Originally Posted by ImmortalAres
the demo board supports programming through the mplab ICD2 through an rj-11 plug on the board. and yea, i quickly became aware of how i had to rewrite the start up, pic def, and alias file myself...
You should just use the processor specific header file provided by the compiler. The filename is "p18f452.h" and will be located in the "h" subdirectory located in the compilers directory.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #8   Spotlight this post!  
Unread 16-06-2005, 11:46
fowlerm's Avatar
fowlerm fowlerm is offline
Bringing .NET to Robots
AKA: Matthew Fowler
FRC #0312 (Heatwave); FRC #1369 (Minotaur)
Team Role: Engineer
 
Join Date: Apr 2005
Rookie Year: 2001
Location: St. Petersburg, FL, USA
Posts: 78
fowlerm has a spectacular aura aboutfowlerm has a spectacular aura aboutfowlerm has a spectacular aura about
Re: Programming a 2nd PIC

I believe RCD8:1 means RCD8 is defined as an alias for the first bit of the structure, and the :5 is a placeholder so the next 5 bits are not aliased as anything, and then RC9 is defined as an alias for the 7th bit of the structure.
  #9   Spotlight this post!  
Unread 16-06-2005, 12:13
ImmortalAres ImmortalAres is offline
Registered User
no team
 
Join Date: May 2005
Location: Clarkson University
Posts: 33
ImmortalAres is an unknown quantity at this point
Re: Programming a 2nd PIC

wow, so that .h file just saved me 3 days thanks for the heads up on that. that's exactly what i needed
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
VEX programming Gene F Programming 14 08-08-2006 22:21
Organizing a programming team. scitobor 617 Programming 7 28-01-2005 19:18
'Fix It Window' and Programming.... JMac Programming 19 25-01-2005 18:57
Programming and Electronics — Getting Started Sidney San Martín Technical Discussion 7 12-01-2005 15:25
pic: Match 0105: 2nd highest score in the nation CD47-Bot Extra Discussion 6 31-03-2003 11:14


All times are GMT -5. The time now is 06:19.

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