Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Just a little question... (http://www.chiefdelphi.com/forums/showthread.php?t=14925)

Keys 29-10-2002 16:37

Just a little question...
 
Hey everyone. I'm learning how to program right now, being taught by my team's lead programmer. I was wondering if any of you might know a good online tutorial, or maybe even a good book that teaches programming? Tutorials in both C++ and PBASIC would be cool...so if you guys know anything, let me know? Thanks.

Katie Reynolds 29-10-2002 17:34

Check online at Parallax - I'm sure they have something for PBasic! :)

- Katie

SlamminSammy 29-10-2002 19:28

This is definately Rob's (rbayer) area, but he is ironically at his CompSci class at the U of MN right now. Try looking at HowStuffWorks "Software and Programming" located at http://www.howstuffworks.com/category.htm?cat=Program . They have tutorials on C, Java, PERL, etc. In addition, http://www.techtutorials.com may also be helpful.

Jnadke 29-10-2002 20:01

1 Attachment(s)
I attached a zip file with my code from our last year's robot. Included is some programming guidelines you should follow when programming your robot (put together by one of our EEs). They are good programming ethics, your time will be much easier in the long run if you study them and follow them. Take a look at the program and you'll see what I mean.

You'll need the PBASIC documentation from Parallax: http://www.parallaxinc.com/downloads...ual%20v2.0.pdf
It contains everything you'll need for understanding the code.

You'll also need the PBASIC editor from Parallax: http://www.parallaxinc.com/downloads...p%20Editor.exe

Keys 29-10-2002 21:00

Aw, thanks everyone, this is going to help me a lot! You all rule!

rbayer 29-10-2002 22:28

I'm back now. Anyway, for learning PBASIC, follow the suggestions given in this thread.

As for learning C/C++, you're probably best off buying a book. I have C++: How To Program by Deitel and Deitel. It literally taught me everything I know about C++, and that was just the second edition. They're up to a fourth now.

As soon as I finish some of my current projects, I may go ahead and write a PBASIC/FIRST primer, covering all the basics as well as some example code, etc.

In any event, if you run into trouble with either PBASIC or C++, just ask in this forum and I (or someone else) will probably get back to you within a few hours.

--Rob

Nate Smith 29-10-2002 23:37

The CODEX
 
Check out the articles section here:
http://www.first-codex.net

Jnadke 30-10-2002 12:52

Re: The CODEX
 
Quote:

Originally posted by Nate Smith
Check out the articles section here:
http://www.first-codex.net


Ahh... I was wondering where that went... All the old links I had were inoperative. But, yeah, the codex is the best place.


As for those Design and Code Review guidelines, you're supposed to use them in the coding process. Here's the general process.

1. Figure out what your robot is going to do.

2. List all things that are going in our out of the robot controller. They need coding. List what they hook up to (That's what the documentation is in the zip file).

3. Divide the parts of the robot into clearly defined areas (subroutines) (look at my sample program, there's a drive area, a controls area, compressor area, grabber area, a window motor area, a pneumatic cylinder area, etc.). It's up to you how far you want to divide it. The more you divide it, the less the code is inter-dependent (one thing wrong messes up the entire robot = no no). However, the more you divide it, the more complex it becomes. There's a certain point where this is balanced. I won't say that my way is best. It all depends on the programmer's preference. Use the Design Review guidlines while you are writing this up. After it is completed, gather peers together and go through it.

4. Write in paragraphs (english) what each section of the robot should do.

5. Now, translate these paragraphs into PBASIC code, or into pseudocode (a hybrid form of english and the desired coding language... no specific code is formed, but an outline is formed. if statements and such should be included to illustrate structure). For example:
Code:

drive area:
if driver doesn't want to reverse controls then go do drive stuff
<switch joystick controls, so front of robot becomes back>
drive stuff:
if deadzone present then go do other side
<calculate the motor speed with the desired algorithm>
other side:
if deadzone present then go back
<calculate the motor speed with the desired algorithm>
back:
return

6. Debug the robot code. Upload it and go through all the purpose of the subroutines and make sure they do what they were intended to. This should be the longest process of coding the robot. No matter how good of a coding job you think you did, it's better to find out something doesn't work now than on the playing field.



Of course, all these recommendations depend on if you like object-oriented code. My attempt at coding was to make PBASIC object-oriented. It succeeded, but object-oriented isn't what PBASIC is intended to be. Object-oriented means that there are certain areas of the code (functions, subroutines, etc) that are designed to accomplish a specific task. These functions/subroutines are then called by the main code to accomplish these tasks.

C++ and JAVA are object-oriented programming languages. BASIC is not, however (along with many others).

rbayer 30-10-2002 14:50

Re: Re: The CODEX
 
Quote:

Originally posted by Jnadke


6. Debug the robot code. Upload it and go through all the purpose of the subroutines and make sure they do what they were intended to. This should be the longest process of coding the robot. No matter how good of a coding job you think you did, it's better to find out something doesn't work now than on the playing field.


Of course, all these recommendations depend on if you like object-oriented code. My attempt at coding was to make PBASIC object-oriented. It succeeded, but object-oriented isn't what PBASIC is intended to be. Object-oriented means that there are certain areas of the code (functions, subroutines, etc) that are designed to accomplish a specific task. These functions/subroutines are then called by the main code to accomplish these tasks.

C++ and JAVA are object-oriented programming languages. BASIC is not, however (along with many others).

If you do steps 1-5 correctly, and use pseudo-code in step 5, step six should actually be one of the shortest steps in the whole process.

As for object-oriented, what you are actually talking about is "modular" or "procedural" programming (it's NOT "functional", despite what many people/books say). Object-oriented would imply that you somehow encapsulated the data and functions into one big "object." The only real way to semi-sorta-kinda-maybe do object-oriented stuff in PBASIC is to use multiple program slots. That way, all the variables are stored in the same place as the functions that manipulate them. Even then, the data can manipulated by any object at will since everything uses one shared block of memory.

In either event, breaking your code into small pieces is a VERY good idea. It will make debugging much easier and will make it far simpler to make changes some time in the future.


All times are GMT -5. The time now is 01:17.

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