Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Technical Discussion (http://www.chiefdelphi.com/forums/forumdisplay.php?f=22)
-   -   Rookie help (http://www.chiefdelphi.com/forums/showthread.php?t=31880)

doyler 20-12-2004 13:57

Rookie help
 
I am new to programming and extremely new to a lot of mechanical stuff in general, so my team gave me something to work on over the holidays, but I am very confused.
I will try and be as specific as possible to receive help

They gave me an edubot controller, a battery, a charger, 2 servos, a serial to usb converter, and something called a BEI GyroChip

I know what the battery, charger, and serial -> usb cable do/are for, but how would i hook up the rest of thie stuff to the control

Thanks

Mark McLeod 20-12-2004 14:52

Re: Rookie help
 
Quote:

Originally Posted by doyler
... 2 servos, ... and something called a BEI GyroChip

... how would i hook up the rest of the stuff to the control

The servos plug into any PWM available on your controller. Setting the value (0-254) of the PWM will turn the servo to a particular spot. The same spot everytime you use a particular value.

The gyro plugs into an analog input on the controller (one of the first inputs based on User_Initialization() in user_routines.c). If it doesn’t already have a connector attached you’ll have to make one out of a PWM cable. You get values from it doing something like “x = Get_Analog_Value(rc_ana_in01);“ The neutral position of the gyro will be close to 512. When the gyro is twisted slowly in one direction you’ll get numbers between 0 and 512 only while you are twisting it. Do the same in the other direction and you’ll get numbers between 512 and 1023. If you keep track of these numbers you can tell if your robot is driving straight or not and correct. It can also be used to make precise turns, to say 45 degrees if you calibrated it.
This particular gyro is no longer "street legal" to use on your competition robot, but it's good to learn with. This one will be overly sensitive to turns or sudden movements that are too quick, and will more easily lose track of the original robot heading.

Do a search on “gyro” for a lot of threads on the subject.

doyler 20-12-2004 15:14

Re: Rookie help
 
the gyro has a pwm, and my only job is to make the sensors move or something

sensors go to pwm out? if so, the black is on top right
the gyro goes to analog in with the black on botton?

if all this is correct thank you and i will probably have questions later about what all these do and what / how to code

Mark McLeod 20-12-2004 15:21

Re: Rookie help
 
Quote:

Originally Posted by doyler
sensors go to pwm out? if so, the black is on top right
the gyro goes to analog in with the black on botton?

if all this is correct thank you and i will probably have questions later about what all these do and what / how to code

Yes, black on the outside, or the pin furthest from the controller, of each connector.
The gyro is a sensor and the servos are specialized motors.

doyler 20-12-2004 15:30

Re: Rookie help
 
um, i have 4 pwm out pins, but only three holes, does the closest one not matter for these servos?

Mark McLeod 20-12-2004 15:33

Re: Rookie help
 
Quote:

Originally Posted by doyler
um, i have 4 pwm out pins, but only three holes, does the closest one not matter for these servos?

Leave the inside pin unconnected. It's a duplicate power pin.

doyler 20-12-2004 15:41

Re: Rookie help
 
I can use any 2 pwm out pins right
And I just put the gyro in the first digital in spot

Mark McLeod 20-12-2004 15:47

Re: Rookie help
 
Quote:

Originally Posted by doyler
I can use any 2 pwm out pins right
And I just put the gyro in the first digital in spot

Yes, any pwms will do for the servos.

If you are starting with the default EDU code, that arranges for the first two inputs to be analog, so either 1 or 2 will work.

doyler 20-12-2004 15:49

Re: Rookie help
 
Will the default EDU code have stuff that i can just upload and make it work, just to learn the workings?

Mark McLeod 20-12-2004 15:55

Re: Rookie help
 
Quote:

Originally Posted by doyler
Will the default EDU code have stuff that i can just upload and make it work, just to learn the workings?

Yes. Start with that. Also get the EDU documentation from the innovationfirst.com website:
http://innovationfirst.com/FIRSTRobo...04-Jan-14a.pdf
http://innovationfirst.com/FIRSTRobo...10-15-2003.pdf
http://innovationfirst.com/FIRSTRobo...t_02-16-04.zip

doyler 20-12-2004 16:01

Re: Rookie help
 
And I just use MPLAB IDE to mess with it right?

Also, what kind of code am i looking for just to make these things move for starters

What code(s) will I have to upload as well?

Mark McLeod 20-12-2004 16:17

Re: Rookie help
 
Quote:

Originally Posted by doyler
And I just use MPLAB IDE to mess with it

Also, what kind of code am i looking for just to make these things move for starters

Yes, learn to use MPLAB.
How about putting something like this where it says "/* Add your own code here. */" in the file "user_routines.c" in the routine "Process_Data_From_Master_uP"
Code:

static unsigned char servo1=0; //Put these two lines right before the "Getdata" call
static unsigned char counter=0; // ditto
 
//Put these lines after "Add your own code"
 
if (counter < 20) // about half a second in the slow loop
counter++;
else
{
counter = 0;
 
if (servo1 < 255)
        servo1++; // servo1 will slowly step through each of it’s positions
else
        servo1 = 0; // servo1 will quickly reset to the zero position
}
pwm03 = servo1;


doyler 20-12-2004 16:21

Re: Rookie help
 
Thank you, i will fiddle and learn from that code (is user routines akin to autonomous cause i dont know how im gonna make them move if it isnt)

1 more question (i hope) how and what do i upload to my controller now?

Mark McLeod 20-12-2004 16:35

Re: Rookie help
 
Quote:

Originally Posted by doyler
Thank you, i will fiddle and learn from that

1 more question (i hope) how and what do i upload to my controller now?

Here are the basic steps:
  1. You’ll need to install MPLAB, IFI_Loader, and the mcc18 compiler on your computer.
  2. Download the default EDU code from http://innovationfirst.com/FIRSTRobo...umentation.htm (this will have a default.hex file that can be downloaded into the controller without having to edit anything with MPLAB) Save the original .zip file so you can restore the default code if some edit goes terribly wrong.
To edit the default code:
  1. Start MPLAB
  2. Select File -> Open Workspace…
  3. Browse to the EDU default code folder
  4. Open Default.mcw
  5. Make your code changes
  6. Use the “Build All” icon or select Project -> Build All (this will create a .hex file)
Start IFI_Loader
  1. Browse to the default code folder
  2. Select “Default.hex”
  3. Connect the serial cable from your computer to the EDU controller
  4. Turn on the EDU controller
  5. Press the “Prog” button until the program light turns orange
  6. Click on “Download” in IFI_Loader
Your program will start running.

doyler 20-12-2004 16:39

Re: Rookie help
 
C:\...\EDU_Default_02-16-04\user_routines.c:249:Error: syntax error
Halting build on first failure as requested.
BUILD FAILED: Mon Dec 20 16:36:48 2004

here is the snippet i edited

Code:

/*******************************************************************************
* FUNCTION NAME: Process_Data_From_Master_uP
* PURPOSE:      Executes every 17ms when it gets new data from the master
*                microprocessor.
* CALLED FROM:  main.c
* ARGUMENTS:    none
* RETURNS:      void
*******************************************************************************/
void Process_Data_From_Master_uP(void)
{
  Getdata(&rxdata);  /* Get fresh data from the master microprocessor. */

  Default_Routine();  /* Optional.  See below. */

  /* Add your own code here. */

  static char servo1=0;
  static char counter=0;
 
  if (counter < 20) // about half a second in the slow loop
    counter++;
  else
  {
    counter = 0;
    if (servo1 < 254)
          servo1++; // servo1 will slowly step through each of it’s positions
    else
            servo1 = 0; // servo1 will quickly reset to the zero position
  }
  pwm03 = servo1;

  printf("PWM OUT 7 = %d, PWM OUT 8 = %d\n",(int)pwm07,(int)pwm08);  /* printf EXAMPLE */

  Putdata(&txdata);            /* DO NOT CHANGE! */
}

(sorry if i am being annoying, im just new at this)


All times are GMT -5. The time now is 15:46.

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