Go to Post But you are right about one thing, it is downright un-American. The Triplets are Canadian. - rourke [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 26-01-2002, 13:43
DanL DanL is offline
Crusty Mentor
FRC #0097
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: Somerville, MA
Posts: 682
DanL is just really niceDanL is just really niceDanL is just really niceDanL is just really niceDanL is just really nice
Send a message via AIM to DanL
Rookie Programmer has question about the default code

Hey guys, I'm taking a look at the code, and I've got a small question. On this part:
Code:
'========== MAIN PROGRAM =====================================================
'=============================================================================

'---------- Input & Output Declarations --------------------------------------

Output	COMB
Input		COMA
Input		COMC

Output	7	'define Basic Run LED on RC => out7

Output      8	'define Robot Feedback LED => out8	=> PWM1 Green
Output      9	'define Robot Feedback LED => out9	=> PWM1 Red
Output      10	'define Robot Feedback LED => out10	=> PWM2 Green
Output      11	'define Robot Feedback LED => out11 => PWM2 Red
Output      12	'define Robot Feedback LED => out12 => Relay1 Red
Output      13	'define Robot Feedback LED => out13 => Relay1 Green
Output      14	'define Robot Feedback LED => out14 => Relay2 Red
Output      15	'define Robot Feedback LED => out15 => Relay2 Green


'---------- Initialize Inputs & Outputs --------------------------------------

Out7  = 1		'Basic Run LED on RC
Out8  = 0		'PWM1 LED - Green
Out9  = 0		'PWM1 LED - Red
Out10 = 0		'PWM2 LED - Green
Out11 = 0		'PWM2 LED - Red
Out12 = 0		'Relay1 LED - Red
Out13 = 0		'Relay1 LED - Green
Out14 = 0		'Relay2 LED - Red
Out15 = 0		'Relay2 LED - Green
I know this part controls the LEDs, but I've got two questions. First of all, what does "Output" do? Meaning, what does it mean when the code says, "Output 7". And my second question, whats the relationship between "Output 7" and "Out7 = 1"? I take it 1 means the LED goes on and 0 means the LED is off, but how does it know that "Out7" sends to the "Basic Run LED"?
__________________
Dan L
Team 97 Mentor
Software Engineer, Vecna Technologies
  #2   Spotlight this post!  
Unread 26-01-2002, 13:55
Jan Olligs's Avatar
Jan Olligs Jan Olligs is offline
Registered User
#0448 (Crandroids)
 
Join Date: Jan 2002
Location: Bloomfield Hills, MI
Posts: 103
Jan Olligs is on a distinguished road
I am not the programmer on my team and I have never worked with BASIC stamps, just with Atmel AVRs, which are programmed in assembler, but most microcontrollers have a similar syntax, so here is my explanation:
On microcontrollers, most of the ports (except, for example, for the analog ones) can be either input or output. To tell the controller how you would like to access the port, whether as input or output, you have to define it in teh initialization statements. This can obviously be done by writing 'Output' followed by the port number. From there on, you cann access it by the internal aliases out[port number].
Take this as a temporay help, I bet that someone who knows the BASIC Stamp really well is going to post a reply sometime later this day.
Good luck!
__________________
I have great faith in fools - my friends call it self-confidence. --- Edgar Allen Poe
  #3   Spotlight this post!  
Unread 26-01-2002, 17:11
Joe Johnson's Avatar Unsung FIRST Hero
Joe Johnson Joe Johnson is offline
Engineer at Medrobotics
AKA: Dr. Joe
FRC #0088 (TJ2)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Raynham, MA
Posts: 2,648
Joe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond repute
You should download the Parallax manual (V2.0 is worth getting if you have the older manual -- much clearer in my opinion).

Output is a Pbasic command that makes a pin an output on a Stamp2.

What it REALLY does is set a bit in the DIRS word.

There are 3 words that you should get to know if you are using Stamp2's a lot (not so much if you only use them for FIRST, but it is still good to know).

DIRS is a word that sets the direction of data flow of the I/O pins 0-15

INS is a word that reflects the status of the voltage on the I/O pins 0-15.

OUTS is a word that determines the output value of the I/O pins, if DIRS is set to the output state (which I can't recall whether it is a 1 or a 0 off the top of my head). Actually, the Stamp2 can only TRY to set the values to match OUTS, if something else is trying to make it something else, then it is a tug of war and the best man wins. With perhaps one of the battlers broken or wounded ;-)

Anyway, Output X sets bit X of DIRS to output status.

OUT1 is simply an alias for bit1 of OUTS. It is exactly the same as OUTS.bit1

Hope this helps.

Joe J.
  #4   Spotlight this post!  
Unread 26-01-2002, 19:59
DanL DanL is offline
Crusty Mentor
FRC #0097
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: Somerville, MA
Posts: 682
DanL is just really niceDanL is just really niceDanL is just really niceDanL is just really niceDanL is just really nice
Send a message via AIM to DanL
Quote:
Originally posted by Joe Johnson
You should download the Parallax manual (V2.0 is worth getting if you have the older manual -- much clearer in my opinion).
Ahh, thanks, thats the one bit of information I didn't take a look at. Also thanks for your explanation, I see how it works now.
__________________
Dan L
Team 97 Mentor
Software Engineer, Vecna Technologies
Closed Thread


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
How long does it take you to load the default code? vegasmcse Robotics Education and Curriculum 10 03-11-2003 21:41
robot goes haywire with the one joystick default code Miles Programming 7 24-01-2003 14:58
Default Robot Code lvhsrobotics Programming 2 10-01-2003 16:55
2003 PBasic default code from Innovation First ttedrow Programming 0 06-01-2003 11:18
default code archiver 2001 2 23-06-2002 22:53


All times are GMT -5. The time now is 02:11.

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