|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#16
|
||||
|
||||
|
Re: Help, I'm a world class computer programming genius yet I'm totally lost.
Quote:
Quote:
Quote:
The only place I'm finding references to this is from FRC code that has been commented out with the explaination that it would generate a 40KHz PWM with a 50% duty cycle... The documentation for FIRST MPLAB programming is scattered around the Internet. Be sure to check the FIRST web site's Documents and Updates Section http://www.usfirst.org/community/frc...nt.aspx?id=452 in Section 8 check the Additional Technical Resources link. Check on the IFI Robotics web site under the Operator Interface documentation for tidbits on variables used http://www.ifirobotics.com/oi.shtml and the FRC Robot Controller page for documentation, FRC source code and supporting programs http://www.ifirobotics.com/rc.shtml. I already mentioned the Vex Labs web site for Vex related versions. Since you've found Chief Delphi you should check the white papers some have valuable programming information. One last reference you may want to look at is the Microchip datasheets for the Vex's PIC18F8520 and the FRC controller's PIC 18F8722. If I have trouble finding the datasheets from official FIRST sources I get on www.digikey.com and enter the processor model number, select a processor, select the Technical/Catalog Information link to get a listing of the processors to find the datasheets. At 448 pages the PIC 18F8722 datasheet is not light reading. I noticed you list the St. Louis area for your location, you might want to attend the local robotics club's monthly meeting next Saturday. They usually have members involved with FIRST. Their information is at www.robomo.com. Starting to learn MPLAB programming within the 6 week build period is not an ideal situation, I learned that a couple of years ago. Having such a late start I would suggest that you give the EasyC Pro a chance. I'm not fond of their licensing scheme handicapping our programmers so I suggest our team members try programming with WPILib which is a library accessed within the MPLAB environment. Since EasyC seems to be using the WPILib you get the same functionality without the drag and drop GUI. Quote:
Vince |
|
#17
|
|||
|
|||
|
Re: Help, I'm a world class computer programming genius yet I'm totally lost.
Quote:
It sounds like I have about six weeks of documentation to read at this point with only four weeks left to completion!! It's clear to me now that FIRST does not really expect any robotics teams to build a robot from ground zero in six weeks; the learning curve simply to read documentation is quite steep even for a professional in the industry much less a high school student. I have to say that this is all very intimidating for a brand new team that is just getting off of the ground. It doesn't help when PBS is filming the entire thing the whole time! Kevin, you don't have to convince me about state machines. AI programming is my absolute favorite code to work on in computer games. I use a combination of state machines with memory to create AI's that avoid 'brain lock'. The other thing I really care about when writing AI's is to have them always dealing with lots of problems simultaneously in parallel. I use a combination of state machines, memory, modular systems, and interrupts to create AI's that behave in a very natural way. I typically break systems out into various components (path finding, vision processing, emotional state, goal oriented behavior, etc.) and run all of these systems simultaneously in parallel feeding back to an interrupt driven state machine which runs via a scripting language on a virtual machine. A state machine, coupled with memories to avoid 'brain lock' allows a system to be extremely reactive and adaptive to its environment. However, as my friend John Miles (http://www.thegleam.com/ke5fx/) likes to remind me, I need to learn to walk first before I start getting too far ahead of myself. By the way, if you don't know who John Miles is, he is an engineer worth knowing... I do have one question in response to some of the answers I have received in this thread. Why does it make any difference if I'm programming for a VEX or FRC controller? They both effectively have the same PIC micro-controller and execute the same basic logic. I mean, worst case scenario I link to a different script, what does it matter which controller I run the C code on? Thanks, John Last edited by jratcliff : 13-01-2008 at 02:29. |
|
#18
|
|||||
|
|||||
|
Re: Help, I'm a world class computer programming genius yet I'm totally lost.
John,
First, I'll apologize now for lying in my last post about it being my last long winded post of the night.... To answer your last question first, in the broadest sense, it doesn't matter too very much if you're programming on Vex or FRC. The fundamental structure of the code is rather similar. Superficially, the inputs to the Vex controller are more limited and only consist of those few PWM_in# variables that tell you the position of the radio controller's sticks. These are equivalent to the p#_x, p#_y, etc on the FRC. The Vex controller doesn't have any equivalent of p#_sw_top, etc. Similarly, the vex's pwm## variables are equivalent to the same on the FRC. The FRC also has the relay#_fwd/rev variables that don't have vex equivalents. Digital IOs, analog inputs, and the serial ports are all mostly equivalent. The lack of physical space on the Vex brain meant IFI had to multiplex the analog inputs with the digital IOs, but this is not the case on the FRC controller. Finally, because the FRC system plugs into a computer controlled field, the FRC controller receives bits instructing it to enter Disabled mode or Autonomous mode. Both as as they imply. In Disabled, your receive valid input from the operator console, but all outputs of the robot are disabled by the master processor, save the digital and analog IOs. In Autonomous, outputs are enabled, but the robot is intended to be on its own, so all inputs received from the operator console are invalid. The final operating mode is Teleop, which is the default if not in the other two modes. Inputs and outputs are both valid in this mode. Now, here's the good news. Those massive tomes about the PIC microprocessors? You honestly barely need to read them. Nearly all of the onboard peripherals on the user PIC are either taken up by IFI or routed to pins on the exterior of the robot controller the are buffered or otherwise rendered useless for most advanced functions. If you're really determined, you mostly need to read up on three things. Interrupts, Timers, and CCPs. In that order, preferably. If you're really pressed for time, Kevin Watson has a LOT of functionality already coded up and in highly bug-tested form. If you're feeling more adventurous, I would look into Kevin's C18 3.10 version code or the restructured C18 2.4 code mentioned in this thread. This simple bit of restructuring makes the program flow much more intuitive and easier to follow. That said, a large percentage of robots out there get by with little more than the "joystick 1 makes this motor go, button 3 makes this light blink" kind of code you mentioned earlier. After getting that far, I'd make it your primary goal to get some encoders on your robot's wheels/drive motors and attempt to implement a PID control on your drive speed. Robot drivetrains are notoriously poorly balanced and it can be easy to spot teams without PID control, as the robot will make a very graceful, large diameter arc whilst attempting to drive straight across the field. If you get that far, implementing a useful autonomous mode is fairly easy. You can use the encoder to measure the distance your robot has traveled use that to transition a state-machine design to get your robot driving down the field and making a left turn or whatever it seems appropriate to do. So, like I said, you don't strictly need all the extra knowledge in those tomes. It CAN come in handy, of course. We used such esoteric knowledge one year to count the pulses on an encoder at rates much higher than it would be feasible to count them using interrupts. But by and large, you mostly need the info in all the IFI guides and manuals and the lack of time to make using Kevin Watson's code seem like a great idea. |
|
#19
|
|||
|
|||
|
Re: Help, I'm a world class computer programming genius yet I'm totally lost.
I have been doing this for 11 years now. I have given seminars on programming. You do not need to go to great detail for this. When you have time read Kevin's stuff at your lesure but for now you can put it to good use. I have several presentations you can use and as you have a background in C most of the gooey details should be pretty easy to master. You can get these at www.frc272.com.Ideas.
Good luck |
|
#20
|
|||
|
|||
|
Re: Help, I'm a world class computer programming genius yet I'm totally lost.
Sorry for messing up the URL in my last post. The presentations are at www.frc272.com/Ideas (Capital I in Ideas)
Sorry, fat fingers... |
|
#21
|
|||
|
|||
|
Re: Help, I'm a world class computer programming genius yet I'm totally lost.
PWM
Pulse Width Modulated output.(byte) Range 0-255, mid range =127. Joystick output. This applies to Speed controller via a control cable (White, red, black). This tells Speed controller how much voltage and polarity. (forward or reverse). You assign joystick value to pwm output. pwm01 = p3_y; // left driver joystick Relay Separate module connected via control cable to Spike Relay controller. Has two variables _fwd _rev. When controlling motor it will apply full power in foward or reverse. relay1_fwd = 1; relay1_rev = 0; To turn it all off ... relay1_fwd = 0; relay1_rev = 0; Once you compile your code you must download it to micro. Go ti IFI for loader and instructions. Ther eis a default code base that helps get you started. |
|
#22
|
||||
|
||||
|
Re: Help, I'm a world class computer programming genius yet I'm totally lost.
very short winded answer.
open default project; learn user_routines.c - used for default tele operation learn user_routines_fast.c - used for hybrid/auton operation download several kevin.org projects, like adc and encoder carefully READ the readme.txt in these projects. they are precise and step by step. use something like WINDIFF and examine the differences between the kevin projects and the default project. There you will see how he incrementally added features to the default project. I use TREECOMP and WINDIFF to do deltas on the projects. There are other tools that do the same. This is about the fastest quickstart I can think of for an experienced programmer. I would do all of that before jumping into processor datasheets and stuff. There is a LOT of framework that is already done. All you have to do is add your algorithms and go. |
|
#23
|
||||
|
||||
|
Re: Help, I'm a world class computer programming genius yet I'm totally lost.
Quote:
|
|
#24
|
|||
|
|||
|
Re: Help, I'm a world class computer programming genius yet I'm totally lost.
Part of the acronym soup for this group is PID. It's a shorted version of proportional-integral-differential control. The idea is to use a sensor to measure an actual output, compare it to the commanded output, and adjust until they converge. I think you can get by with a proportional term only the most of the time. There are lots of samples on these forums.
You can also use the technique to move from "relative" to "absolute" position. The basic example is a servo, which moves to a fixed position based on the input command. Instead of saying "go forward" or "go backwards" you call tell it to "go to position X". The sensors commonly used are: 1) Gyro - analog sensor measures angular velocity. By sampling at a fixed interval integrating the output you can convert the value to a relative angle (think compass). 2) Encoder - device that measures rotational distance by being physically coupled to the thing you want to measure. As the shaft rotates it outputs a series of "ticks". They have a fixed number of "ticks" per rotation. By counting the ticks you can measure distance, and by accruing the distance over time you can measure speed. A quardature encoder allows you to determine both distance AND direction. 3) Potentiometer (pot) - variable resistor that outputs an analog value relative to the position of the shaft. This is useful for measuring a joint with a fixed arc (like an arm). For the arm application you can compare the output of the pot to the commanded value and drive the motor until the two values match. Using this stuff you can write code to make your robot drive the way you want. For a simple tank-style robot I like to break it down into two commands: forward and rotation. Using a gyro or encoders you can more closely relate your forward/rotation commands to the actual performance of the system. Good luck! |
|
#25
|
|||||
|
|||||
|
Re: Help, I'm a world class computer programming genius yet I'm totally lost.
Another important resource for specific hardware info is the IFI FAQ Forum
OI FAQs RC FAQs Victor Speed controller FAQs In my opinion the most important of which is the Outputs Steps FAQ. |
|
#26
|
|||
|
|||
|
Re: Help, I'm a world class computer programming genius yet I'm totally lost.
HAH! NOW aren't you sorry you didn't listen to your mother when she told you to stop coding, get off that computer and ...build a Circuit! (Sorry, I'm mainly a Tech Type...)
One thing I'm not sure anyone mentioned was the Dashboard Monitor. The robot may be a pile of parts but if you can tether the Robot controller, power up the Operator Interface and using the Dashboard Program, download and At least see the effects on the PWM and buttons. The with minimal hardware just power a relay or use a switch to see the inputs. Things like that. You could do some simple programming while the robot is being build instead of waiting. Hope this was a useful suggestion. Good luck Steve |
|
#27
|
|||
|
|||
|
Re: Help, I'm a world class computer programming genius yet I'm totally lost.
I faced the same difficulty a few years ago when I started mentoring my daughter's team. I found that picking up a copy of "Programming and Customizing PICmicro Microcontrollers" by Myke Predko explained the odd acronyms and machine-specific identifiers.
While a lot of the book concentrates on basic architecture, you'll probably be more interested in the sections on timers and interrupts, including CCP. It beats trying to figure things out from datasheets. I picked up my copy at a Borders bookstore. I'd also suggest looking at the MPLAB C18 User's Guide (available on microchip.com) especially the section on "ISO Divergences." It also discusses interrupt handling. As everyone else has said, Kevin Watson's code is pretty much the definitive model for programming the robot controller. The other place to help get up to speed is the white paper section of Chief Delphi and some of the kickoff seminars on the FIRST website. Good luck. |
|
#28
|
|||
|
|||
|
Re: Help, I'm a world class computer programming genius yet I'm totally lost.
OOPS! I Meant to say... Power Up the Robot controller... the Operator Interface will get it's power from the Robot controller... My Bad.
Steve Quote:
|
|
#29
|
|||
|
|||
|
Re: Help,....
Thanks all for the excellent advice. I have been reading documentation today and I think I have a handle on the flow of control now.
I did run into one weird problem, I wonder if anyone else is having. I tried downloading the latest version of the MPLAB-IDE from the microchip website and every time I download any version I get CRC errors when I try to unzip the file. Has anyone else experienced this? To answer a few points that were raised in the thread. (1) I am mentoring a total of six students on our FRC team in programming. I spent four hours giving them a one on one training course on Saturday; these were all Freshmen with little to no programming experience with the exception of my son. (2) My son is really interested in taking a leadship position on the team. He has been programming for quite some time and is really excited about contributing not just this year, but in years to come. My personal goal is to give him enough experience working with the VEX robot at home that he can be much more involved on the FRC project at school. The robotics club meets frequently but with my work schedule the only time I can make available is on Saturday. (3) The reason I am focusing on MPLAB and C, rather than Easy C, is because that is easier for me personally at this time. I'm sure the youth will have opportunities to be exposed to the Easy C paradigm at future events throughout the year. However, in the short term, it is much easier for me to just program in native C code since that is a high iteration cycle path. Yesterday I felt a bit lost in all of the acronyms but a morning of reading yet more documentation is going a long way towards getting me up to speed. Thanks all for the help getting started, it is my hope that I will be of assistance to the general FRC community in years to come and I certainly want to help mentor students in the St. Louis area after this season has completed. Thanks, John & Alex |
|
#30
|
|||
|
|||
|
Re: Help, I'm a world class computer programming genius yet I'm totally lost.
It is true that the programming system is far too extensive to learn within six weeks. For experienced teams, that's not a problem, because in the past four years, the only changes that have been made were tweaking and debugging. For new teams, that's a different story. The only advice I can really offer is that of all the info you'll find in the documentation, you'll only ever use maybe 10% of it. IFI does take care of a LOT of stuff for you, so you don't really have to worry about it.
I've read a good deal of the documentation myself, little by little over the years, so I have a fairly good idea of what the controller is capable of, but I've never read them too far in-depth. I'd recommend the same to you, at least until the main season's over. As much as possible, use the default stuff IFI provides and utilize resources like the IFI Default Code Manual, Kevin Watson's stuff (as if that hasn't been said enough already), and particularly this site. There's always someone here knolwedgable and willing enough to answer questions, or at least show you where to find the solution. Plus, odds are someone's already asked most of your questions before. And I agree with you on the EasyC point. When they introduced EasyC after my first two years of just straight C, I gave it a shot and found myself confused to no end. I eventually worked out a few basics, but found that it was just so much easier to use straight C, and in the end, the code produced was smaller and more efficient. Besides, C isn't the hard part of programming the FRC or FVC controller. The hard part, like you said, is integrating what you know with the hardware specifics of the PIC controller. Last edited by Jake M : 13-01-2008 at 17:35. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| AHHH! I'm a lost newbie! I need help! | lkdjm | Programming | 8 | 28-01-2006 08:41 |
| i'm in the charleston area, and i'm looking to help out a team near here... | dickymon | General Forum | 2 | 05-08-2002 16:40 |
| OK...so I'm totally out of the loop... | Markfuscius | 3D Animation and Competition | 8 | 03-02-2002 02:39 |