Go to Post I don't know about the rest of you but our robot was 100% built by team 226. Our team consists of students, parents, teachers, engineers, and alumni. - Matt Reiland [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 13-01-2007, 20:00
Unsung FIRST Hero
Greg Marra Greg Marra is offline
[automate(a) for a in tasks_to_do]
FRC #5507 (Robotic Eagles)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2005
Location: San Francisco, CA
Posts: 2,031
Greg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond repute
EasyC OI Inputs?

What is up with how EasyC handles input from the OI? I was trying to reprogram our 2005 bot for drivers to practice, and I decided to use EasyC to get familiar with it and because our programming team was considering using it.

[edit] aha! EasyC doesn't yell at you if you are using a "char" instead of an "unsigned char" to store motor data, probably because WPILib bases its drive code on a -127 to 127 range instead of the usual 0-255. This means that sometimes "0" is the 'neutral' value and other times it's 127. The other functions from WPILib (the "drive" library, anyways) appeare to be based on a -127 to 127 scale. When I looked I couldn't find this in the documentation, so made an educated guess the wrong way.

Why does the "drive" library use a different metaphor than the rest of the program? I find this rather confusing. [/edit]

I wasn't able to figure out what was going on, so I just went back to MPLAB and reprogrammed the robot there. Tried and true, I suppose

Last edited by Greg Marra : 13-01-2007 at 20:37.
  #2   Spotlight this post!  
Unread 13-01-2007, 20:13
mluckham's Avatar
mluckham mluckham is offline
Registered User
FRC #0758 (Sky Robotics)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Ontario, Canada
Posts: 116
mluckham will become famous soon enoughmluckham will become famous soon enough
Re: EasyC OI Inputs?

Worked fine for me today.

Although I started off trying to use pwm14 and pwm15 for motor outputs, then found that only pwm1-12 are supported.

Are you having a conflict with int (signed) and unsigned char - whether in your variables to hold raw joystick values, or the printf?
  #3   Spotlight this post!  
Unread 14-01-2007, 23:39
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 592
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: EasyC OI Inputs?

Quote:
Originally Posted by Greg Marra View Post
Why does the "drive" library use a different metaphor than the rest of the program? I find this rather confusing. [/edit]
It would have been nice if everything worked using the -127 - +127 metaphor since it makes much more sense than having an arbitrary value of 127 for stopped. The reason the rest of the code doesn't do that is because of easyC compatibility. It had the SetPWM functions that did the 0-255 thing.

But the drive library make some things incredibly easy to do, especially around control problems. For example, you can use a gyro to drive in a straight line with this fairly simple program:

Code:
void main(void)
{
    int heading;
    InitGyro(1);             // initialize gyro on port 1
    TwoWheelDrive(2,1);      // Setup 2 motor drive robot (ports 1 & 2)
    StartGyro(1);             // start gyro sampling
    while (1)
    {
        heading = GetGyroAngle(1); // get the current heading
        Drive(80, heading/2); // turn towards the error
    }
}
And that's the whole program, no other files required.

So we use the drive stuff, but it isn't necessary. It helps with the bookkeeping of remember which way all the motors need to go and basically decouples the driving and turning values so you can think of them independently.
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
  #4   Spotlight this post!  
Unread 17-01-2007, 14:51
mluckham's Avatar
mluckham mluckham is offline
Registered User
FRC #0758 (Sky Robotics)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Ontario, Canada
Posts: 116
mluckham will become famous soon enoughmluckham will become famous soon enough
Re: EasyC OI Inputs?

Brad,

I tried including the WPILib downloaded from Internet (I did run the setup script that came with that).

Following the EasyC tutorial to "Add a Library", we found that the Add Library failed in EasyC due to a pre-existing definition for TwoWheelDrive() in API.H.

As a result, there is no Drive() function available.

Any suggestions?
  #5   Spotlight this post!  
Unread 22-01-2007, 08:34
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 592
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: EasyC OI Inputs?

Quote:
Originally Posted by mluckham View Post
Brad,

I tried including the WPILib downloaded from Internet (I did run the setup script that came with that).

Following the EasyC tutorial to "Add a Library", we found that the Add Library failed in EasyC due to a pre-existing definition for TwoWheelDrive() in API.H.

As a result, there is no Drive() function available.

Any suggestions?
The problem is that the easyC guys added an identical set of functions as block code. And it's documented all over the place in the help file and examples so they didn't want to change/remove it. So if you're using easyC you can use their functions and if you're using WPILib with some other development environment (MPLab or eclipse) you can use the ones built in.

The way I resolved the name conflicts was to add the file "BuiltIns.h" which only contain definitions for the Drive functions, then include "API.h" which has everything else. So use "BuiltIns.h" if you are using MPLab and "API.h" if you are using easyC and plan on importing the block-code versions of the functions.

Brad
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
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 inputs Andrew Blair FIRST Tech Challenge 22 31-05-2006 18:17
Analog Inputs bush Programming 5 13-03-2006 17:49
Kickoff easyC workshop integrated into EasyC help file Dan Larochelle Programming 0 11-01-2006 06:12
PWM inputs? ghansel Control System 7 14-09-2005 17:57
Joystick Inputs Jatheon4316 Programming 12 06-02-2005 17:25


All times are GMT -5. The time now is 18:35.

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