Go to Post How are you supposed to conceptualize without a complete grasp of what your trying to do? - Aren_Hill [more]
Home
Go Back   Chief Delphi > Other > FIRST Tech Challenge
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 29-05-2006, 09:45
tacman1123 tacman1123 is offline
Registered User
AKA: Tac Tacelosky
FRC #1900
Team Role: Mentor
 
Join Date: May 2006
Rookie Year: 2006
Location: Washington, DC
Posts: 17
tacman1123 is an unknown quantity at this point
Send a message via AIM to tacman1123
Vex Library and Sample Code

I'm not an experienced C programmer, but have enough programming experience to make significant changes to a working program or library. I've been using EasyC, and finally got MPLab working, with the EasyC library and also with the VexCode library.

Is there something in between -- a simplified but open source library? For example, I want to make a fairly small change -- the Arcade2() function in EasyC sets the RC to an arcade-style controller, and maps the controller to a motors in a particular direction. I need to dampen the output, and limit it, so that the extremes of the joystick are not 0 and 255 but rather 100 and 150. I can't see where to modify the code to do this (obviously, I can't modify the EasyC). I've poked around the VexCode c and can't find where the RC is read, but even if I could, it appears that so much of the code is very low-level.

What I'm really looking for is a library (like the EasyC library, but with source code) that I can modify. Also, a set of high-level calls (reading a switch value, or setting a motor) using the VexCode, rather than EasyC, library would be helpful.

Right now, it appears that my choices are very high-level, limited functionality with EasyC, or low level bit manipulation, PWM and lots of hex values. Is there a way to say
Code:
   if (get_input(1) == 0) { // limit switch pressed
      set_motor(1, motor_speed);
   }
without having to write get_input() and set_motor(), but with the ability to modify them?

Thanks!

Tac
Reply With Quote
  #2   Spotlight this post!  
Unread 29-05-2006, 16:53
foobert foobert is offline
Registered User
no team
 
Join Date: May 2005
Location: oakland, ca
Posts: 87
foobert is a jewel in the roughfoobert is a jewel in the roughfoobert is a jewel in the rough
Re: Vex Library and Sample Code

Quote:
Originally Posted by tacman1123
Code:
   if (get_input(1) == 0) { // limit switch pressed
      set_motor(1, motor_speed);
   }
without having to write get_input() and set_motor(), but with the ability to modify them?
well, gee, if you're not going to read your inputs and check your outputs it doesn't seem like there's much left for you to do.

if you just want to hide implementation details you can always use defines. for instance...

#define LIMIT_SWITCH_PRESSED get_input(1) == 0

...

if (LIMIT_SWITCH_PRESSED)
set_motor (1, motor_speed / 5 + 100);

which will damp your motor speed to values between 100 and 150. maybe another definition might help, e.g.

#define set_left (a) set_motor (1, (a) / 5 + 100)

so you get

if (LIMIT_SWITCH_PRESSED) set_left (motor_speed);
Reply With Quote
  #3   Spotlight this post!  
Unread 29-05-2006, 17:01
tacman1123 tacman1123 is offline
Registered User
AKA: Tac Tacelosky
FRC #1900
Team Role: Mentor
 
Join Date: May 2006
Rookie Year: 2006
Location: Washington, DC
Posts: 17
tacman1123 is an unknown quantity at this point
Send a message via AIM to tacman1123
Re: Vex Library and Sample Code

I'm hoping I'm missing something really obvious. I've looked though the ifi_*.c files, and the .h files, and everything is very low-level. I was using get_input(1) as an example, but I don't believe there is a get_input function. Is there one? If so, where is it?

Is there sample code somewhere that turns two motors on and goes for 5 seconds, or reads a switch (or even better, the remote control unit)? Right now, it looks like if you want to simply go forward for 5 seconds, you have immerse yourself in hundreds of lines of code. Again, I keep hoping there's some high-level function calls documented somewhere that I just can't see (again, beside the ones in EasyC).


Tac
Reply With Quote
  #4   Spotlight this post!  
Unread 29-05-2006, 20:02
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
Re: Vex Library and Sample Code

WPILib may be of some help to you, check it out here: http://www.chiefdelphi.com/forums/sh...ad.php?t=42036
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
Reply With Quote
  #5   Spotlight this post!  
Unread 29-05-2006, 22:50
foobert foobert is offline
Registered User
no team
 
Join Date: May 2005
Location: oakland, ca
Posts: 87
foobert is a jewel in the roughfoobert is a jewel in the roughfoobert is a jewel in the rough
Re: Vex Library and Sample Code

Quote:
Originally Posted by tacman1123
I'm hoping I'm missing something really obvious. I've looked though the ifi_*.c files, and the .h files, and everything is very low-level. I was using get_input(1) as an example, but I don't believe there is a get_input function. Is there one? If so, where is it?

Is there sample code somewhere that turns two motors on and goes for 5 seconds, or reads a switch (or even better, the remote control unit)? Right now, it looks like if you want to simply go forward for 5 seconds, you have immerse yourself in hundreds of lines of code. Again, I keep hoping there's some high-level function calls documented somewhere that I just can't see (again, beside the ones in EasyC).


Tac
oops. sorry, thought you were maybe talking about some existing easyC code about which i know nothing.

to test for a limit switch closed on pin 1 in the analog/digital section of the rc and then send the damped signal from channel 1 of the radio to a motor connected to motor port 1 on the rc, use

if (rc_dig_in01 == 0)
pwm01 = pwm_in1 / 5 + 100;

the names used are all defined in ifi_aliases.h. the code would probably go into user_routines.c which runs every 18.5 ms.
Reply With Quote
  #6   Spotlight this post!  
Unread 30-05-2006, 07:39
tacman1123 tacman1123 is offline
Registered User
AKA: Tac Tacelosky
FRC #1900
Team Role: Mentor
 
Join Date: May 2006
Rookie Year: 2006
Location: Washington, DC
Posts: 17
tacman1123 is an unknown quantity at this point
Send a message via AIM to tacman1123
Re: Vex Library and Sample Code

Quote:
Originally Posted by Matt Krass
WPILib may be of some help to you, check it out here: http://www.chiefdelphi.com/forums/sh...ad.php?t=42036
Thanks -- this is the type of library I'm looking for, and I've written to Brad asking about availability for Vex.
Reply With Quote
  #7   Spotlight this post!  
Unread 30-05-2006, 07:46
tacman1123 tacman1123 is offline
Registered User
AKA: Tac Tacelosky
FRC #1900
Team Role: Mentor
 
Join Date: May 2006
Rookie Year: 2006
Location: Washington, DC
Posts: 17
tacman1123 is an unknown quantity at this point
Send a message via AIM to tacman1123
Re: Vex Library and Sample Code

Quote:
Originally Posted by foobert
to test for a limit switch closed on pin 1 in the analog/digital section of the rc and then send the damped signal from channel 1 of the radio to a motor connected to motor port 1 on the rc, use

if (rc_dig_in01 == 0)
pwm01 = pwm_in1 / 5 + 100;

the names used are all defined in ifi_aliases.h. the code would probably go into user_routines.c which runs every 18.5 ms.
This is exactly what I'm looking for -- thanks! Is there documentation on this anywhere, besides reading the source code comments? How does one know what rc_dig_in01, pwm01 and pwm_in1 are?

Or sample programs, simpler than the VexCode on vexlabs.com? Something like the GearToothTest that Brad has in WPILib, mentioned in the previous post?

Again, thanks very much, I feel like I'm at least getting closer to understanding how to program without EasyC.

Tac
Reply With Quote
  #8   Spotlight this post!  
Unread 31-05-2006, 08:25
foobert foobert is offline
Registered User
no team
 
Join Date: May 2005
Location: oakland, ca
Posts: 87
foobert is a jewel in the roughfoobert is a jewel in the roughfoobert is a jewel in the rough
Re: Vex Library and Sample Code

Quote:
Originally Posted by tacman1123
This is exactly what I'm looking for -- thanks! Is there documentation on this anywhere, besides reading the source code comments? How does one know what rc_dig_in01, pwm01 and pwm_in1 are?

Or sample programs, simpler than the VexCode on vexlabs.com? Something like the GearToothTest that Brad has in WPILib, mentioned in the previous post?

Again, thanks very much, I feel like I'm at least getting closer to understanding how to program without EasyC.

Tac
arrrgh, you wouldn't believe the long insightful answer i had for you when my connection timed out...

the short answer is study the sample code and refer to the 18f8520 datasheet, (watch any ad for a prescription med on the tele for a list of possible side effects), and have a look at theEntropyWorks.com, (a fine example of good intentions and what becomes of them).

anyway, to use pin 1 for input initialize io1 = 1 and to set it to output io1 = 0. when the rc powers up all pins are set to input so that you need not worry that the attached chainsaw on your deathbot will gobble your arm before you can jump clear.

must go to work...
Reply With Quote
  #9   Spotlight this post!  
Unread 31-05-2006, 09:44
tacman1123 tacman1123 is offline
Registered User
AKA: Tac Tacelosky
FRC #1900
Team Role: Mentor
 
Join Date: May 2006
Rookie Year: 2006
Location: Washington, DC
Posts: 17
tacman1123 is an unknown quantity at this point
Send a message via AIM to tacman1123
Re: Vex Library and Sample Code

Upgrading to EasyC 2.0 solved half my problem, as there is now a call GetRxInput(rx, channel) that gets the values I was looking for.

I think Brad Miller's WPILib will solve some of the rest of the problems, but I'll have to wait until that's out to see.

Thanks for your reply.

Tac
Reply With Quote
  #10   Spotlight this post!  
Unread 01-06-2006, 08:19
foobert foobert is offline
Registered User
no team
 
Join Date: May 2005
Location: oakland, ca
Posts: 87
foobert is a jewel in the roughfoobert is a jewel in the roughfoobert is a jewel in the rough
Re: Vex Library and Sample Code

Quote:
Originally Posted by tacman1123
Upgrading to EasyC 2.0 solved half my problem, as there is now a call GetRxInput(rx, channel) that gets the values I was looking for.
i'm guessing that rx is receiver 1 or 2 and that channel is 1 through 6. since there's no way to return an error indication, if we get rx 10, channel 9, we'll just return the first channel from the first receiver.

Code:
unsigned char GetRXInput (unsigned char rx, unsigned char channel) {
  unsigned char bar;

  switch (rx * 6 + channel) {
    default:
    case 1 : bar = PWM_in1;  break;
    case 2 : bar = PWM_in2;  break;
    case 3 : bar = PWM_in3;  break;
    case 4 : bar = PWM_in4;  break;
    case 5 : bar = PWM_in5;  break;
    case 6 : bar = PWM_in6;  break;
    case 7 : bar = PWM_in7;  break;
    case 8 : bar = PWM_in8;  break;
    case 9 : bar = PWM_in9;  break;
    case 10 : bar = PWM_in10;  break;
    case 11 : bar = PWM_in11;  break;
    case 12 : bar = PWM_in12;  break;
  }
  return bar;
}
don't forget to include ifialiases.h.
Reply With Quote
  #11   Spotlight this post!  
Unread 01-06-2006, 16:33
Vexguy365 Vexguy365 is offline
Registered User
FRC #0365
 
Join Date: May 2006
Location: Delaware
Posts: 4
Vexguy365 is an unknown quantity at this point
Re: Vex Library and Sample Code

I have tried writing the code in MPLab but have yielded disatsrous results. I have EasyC v.1 but lost my CD after unisntalling it . Can anyone e-mail me the install file on the CD? I still have all of my other info such as installation key etc. but need the install file one the CD to reinstall it. e-mail me at beattieboy@comcast.net. Thanks - VEXguy365
Reply With Quote
Reply


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 Sensor Sample Code nonother FIRST Tech Challenge 2 08-05-2006 16:49
Is there a sample code? The Stargazer Programming 3 17-02-2005 19:22
sample limit switch code??? tml240 Programming 5 17-02-2004 17:13
Sample Code (Line travel) cgav Programming 1 21-01-2004 09:37
ADC problems with C library and new code Larry Barello Programming 1 09-01-2004 22:31


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

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