|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Omni Vex code in easyc?
So im a noob at codeing and im trying to do omni drive in easy c. I would be able to maby do it in mplab but i don't got access to that software. im wondering how to go about doing it in easy c?
any suggestions. o ps.....its v.5 not the shiney new version 2.0. theres not that big of a difference though. any help would be greatly appreciated. |
|
#2
|
||||
|
||||
|
Re: Omni Vex code in easyc?
|
|
#3
|
|||
|
|||
|
Re: Omni Vex code in easyc?
When you say Omni drive, what are trying to say?
Are you thinking about a Mecanum drive? That will be hard to do, since there are not Vex Mecanum wheels (unless you fabricate your own) Are you thinking about a Holononmic drive? 4 wheel 90 degree offset. That would be four omni wheels, one on each face of a square bot. Are you thinking about a 3 wheel 120 degree offset or Kiwi drive? This is a good drive description video Thanks! Foster |
|
#4
|
|||
|
|||
|
Re: Omni Vex code in easyc?
yes....im thinking the 4 wheel 90* off set. Sorry for not clarifying
|
|
#5
|
|||
|
|||
|
Re: Omni Vex code in easyc?
If you search for holonomic drive, you can find a number of posts about it.
Arthur Dutra wrote this code (and posted it) to support a holononmic drive. One joystick stick moves forward/back and side-side (and diagonally) for translation motion. The other joystic moves left/right to rotate, both can be moved at the same time. The platform consists of four omni wheels mounted at 180 degrees from the next corner (ie two go "forward / backwards" two go "left / right" Code is for the WPILibrary, so it should work fine with EasyC. Let us know how you make out. Code:
#include "API.h"
void main ( void )
{
int LF; // Left Front
int RF; // Right Front
int LR; // Left Rear
int RR; // Right Rear
int leftx;
int lefty;
int rightx;
int spin;
while ( 1 )
{
// Get Data
leftx = GetRxInput ( 1 , 4 ) ; // Left Joystick, X Axis
lefty = GetRxInput ( 1 , 3 ) ; // Left Joystick, Y Axis
rightx = GetRxInput ( 1 , 1 ) ; // Right Joystick, X Axis
// Half the input signal (so code does not overflow past 255)
leftx = leftx / 2 ;
lefty = lefty / 2 ;
spin = rightx / 2 ;
// Drive Code Algorithim
LF = RR = lefty - leftx + 127 ;
RF = LR = 255 - lefty - leftx ;
RR = 255 - RR ; // Reverse Direction of RR motor
LR = 255 - LR ; // Reverse Direction of LR motor
// Spin Code Algorithim
RF = RF - spin + 63 ;
RR = RR - spin + 63 ;
LF = LF - spin + 63 ;
LR = LR - spin + 63 ;
// Code overflow prevention
if ( LF < 0 )
{
LF = 0 ;
}
else if ( LF > 255 )
{
LF = 255 ;
}
if ( RF < 0 )
{
RF = 0 ;
}
else if ( RF > 255 )
{
RF = 255 ;
}
if ( RR < 0 )
{
RR = 0 ;
}
else if ( RR > 255 )
{
RR = 255 ;
}
if ( LR < 0 )
{
LR = 0 ;
}
else if ( LR > 255 )
{
LR = 255 ;
}
// Set Motors
SetMotor ( 1 , RF ) ;
SetMotor ( 2 , LF ) ;
SetMotor ( 3 , LR ) ;
SetMotor ( 4 , RR ) ;
}
}
|
|
#6
|
|||
|
|||
|
Re: Omni Vex code in easyc?
stupid question but how do i upload this into easy c....this looks like its for mp lab.
Last edited by xanarchyx : 21-10-2008 at 21:03. |
|
#7
|
||||
|
||||
|
Re: Omni Vex code in easyc?
Just look at the code and match it in EasyC with blocks, you can't just copy and paste.
|
|
#8
|
||||
|
||||
|
Re: Omni Vex code in easyc?
With easyC Pro you can.
|
|
#9
|
|||
|
|||
|
Re: Omni Vex code in easyc?
ok ill try and match it...but i got pro, i haven't been able to figure out how to manually code....like i know you can....im just missing it.
|
|
#10
|
||||
|
||||
|
Re: Omni Vex code in easyc?
Here is the easiest way to do what you wish.
1.) Right click on User Functions -> Add New -> Name it omni and click ok 2.) Click on the project tab. 3.) Right Click on the function name -> Convert to 'C' Code -> Yes 4.) After you function will look like this.... #include "Main.h" void omni ( void ) { <---Paste the code in here } 5.) Paste the code provided between the braces starting at the variables and ending with the last brace. 6.) Rename SetMotor to SetPWM 7.) Goto the UserInclude.h File and under where it says "Add User Code Here" Add a line : void omni (void ); This should work, I tested it out. |
|
#11
|
||||
|
||||
|
Re: Omni Vex code in easyc?
Why is it necessary to cap the values at the maximums and minimums? Does the processor not automatically do this? I've always found it easier to subtract values from full drive and having the motors that need to be full power just have values greater than 255 and subtracting values from the other wheels instead of just starting from half power for everything. That way, you get full speed, but everything still works fine. I've never done a holonomic function, but this usually works fine for homemade arcade drives and the similar.
Also, please correct me when I say the obvious thing I'm missing, but the algorithm doesn't quite look right: Code:
LF = RR = lefty - leftx + 127 ;
RF = LR = 255 - lefty - leftx ;
I'm designing a robot to drive this way for practicing during Elevation, and I've not yet had time to start (notice the 4 weeks between BEST competition and VEX). Any clue what I'm missing? |
|
#12
|
||||
|
||||
|
Re: Omni Vex code in easyc?
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 2008 Omni Drive Code Help | Vasily Zaitsev | Technical Discussion | 5 | 27-01-2008 00:57 |
| pic: vex omni drive | 1902_Battery_SGT | FIRST Tech Challenge | 6 | 28-05-2006 17:55 |
| pic: simple omni vex bot | colin340 | FIRST Tech Challenge | 15 | 05-05-2006 17:16 |
| EasyC Default Code | Team 1649 | Programming | 13 | 29-01-2006 11:52 |
| Vex Easyc vs Mplab | Joohoo | Programming | 17 | 27-01-2006 08:22 |