Go to Post This is an engineering competition. Do some. - JVN [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 08-03-2006, 20:30
P1h3r1e3d13's Avatar
P1h3r1e3d13 P1h3r1e3d13 is offline
Unregistered User
FRC #0295
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2006
Location: San Diego/Granite Bay
Posts: 46
P1h3r1e3d13 is an unknown quantity at this point
Question Pointers in EasyC

Can EasyC deal with pointers? I know the camera capture command uses them (but I don't know why), but I haven't found a way to implement them myself.

I do remember getting an error message when I tried that seemed to indicate it was possible. I had tried to do something like:
Code:
PWM_1_value = &PWM01
(though I probably have the syntax and names wrong here) and when it gave me a dialog box saying something like "You tried to use a pointer without initializing it." When I try to initialize *PWM01 as a variable, it won't let me, of course ("invalid variable name," or some such).



P.S.: "PWM01" is a guess at what name I tried to use. I don't remember what it's actually called, but I think I somehow knew when I tried that.
  #2   Spotlight this post!  
Unread 09-03-2006, 07:41
koenig3456 koenig3456 is offline
Programming Coach
None #0681 (EARTH Squad)
Team Role: Coach
 
Join Date: Jan 2006
Location: Pennsylvania
Posts: 16
koenig3456 is an unknown quantity at this point
Re: Pointers in EasyC

You can declare pointer variables by putting 'User code' blocks at the beginning of your function. For example, the following code declares two variables and makes the pointer variable point at the value variable and sets the value to 4.

unsigned char *pointer;
unsigned char value;

pointer = &value;
*pointer = 4;
  #3   Spotlight this post!  
Unread 11-03-2006, 19:28
P1h3r1e3d13's Avatar
P1h3r1e3d13 P1h3r1e3d13 is offline
Unregistered User
FRC #0295
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2006
Location: San Diego/Granite Bay
Posts: 46
P1h3r1e3d13 is an unknown quantity at this point
Question Re: Pointers in EasyC

Beautiful! Thanks.

Now does anyone know what names to use to point to say, a certain PWM or relay value?
  #4   Spotlight this post!  
Unread 12-03-2006, 08:48
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Pointers in EasyC

Why don't you just assign a variable to the PWM Control block?


PWM_01 = 160;

SetPWM ( 1 , PWM_01 ) ;

You can do the same with a relay.

Relay_1_FWD = 1;

SetRelay ( 1 , Relay_1_FWD , Relay_1_REV ) ;

Is that what your trying to do?
Attached Thumbnails
Click image for larger version

Name:	pwm.jpg
Views:	50
Size:	14.6 KB
ID:	4117  

Last edited by Kingofl337 : 12-03-2006 at 09:15.
  #5   Spotlight this post!  
Unread 12-03-2006, 18:46
P1h3r1e3d13's Avatar
P1h3r1e3d13 P1h3r1e3d13 is offline
Unregistered User
FRC #0295
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2006
Location: San Diego/Granite Bay
Posts: 46
P1h3r1e3d13 is an unknown quantity at this point
Re: Pointers in EasyC

Hmm... why didn't I think of that?

That would be a workable work-around (redundant?), though it would be kinda tedious to use two blocks each time I set a PWM.

What I'm actually trying to do is set up the OI LEDs to show PWM, relay, and switch values, like they do with the default code, but with EasyC. It's sounding like there's no way to point to PWM values, like in "hard" C, but then how does the camera do it for pan and tilt?

Anyway, it's not really critical; maybe I'll just have the LEDs blink in pretty patterns for the sake of my easily amused teammates. (Yeah, I guess that includes me.)
  #6   Spotlight this post!  
Unread 12-03-2006, 21:36
Kingofl337's Avatar
Kingofl337 Kingofl337 is offline
You didn't see anything....
AKA: Adam
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 1998
Location: Manchester, NH
Posts: 861
Kingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond reputeKingofl337 has a reputation beyond repute
Send a message via Yahoo to Kingofl337
Re: Pointers in EasyC

Can you explain in more detail what you are trying to do? Are you trying to make
an LED go active when the camera locks on?
  #7   Spotlight this post!  
Unread 13-03-2006, 00:02
P1h3r1e3d13's Avatar
P1h3r1e3d13 P1h3r1e3d13 is offline
Unregistered User
FRC #0295
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2006
Location: San Diego/Granite Bay
Posts: 46
P1h3r1e3d13 is an unknown quantity at this point
Re: Pointers in EasyC

Well, sort of. I want to show how far left or right or up or down the camera is pointing (relative to the bot) using multiple OI LEDs per axis. (Something along the lines of an LED for "too far left," an LED for "locked on," and an LED for "too far right.") That way we can manually turn the bot to point at the goal by centering the pan, and tell if our shooter's in range by the tilt angle.

I thought I knew how to do it using the capture command's pan and tilt outputs, but when I tried, it didn't seem to work, and I don't know enough about the camera and EasyC's camera commands to tell why.

Do the servos have to be plugged into the camera board to get those values? Does servo tracking have to be enabled? Why are the camera's outputs pointers? And if the camera can get servo outputs from the controller (as opposed to the camera board), how can I?

That last I originally wanted to know in order to emulate what the default code does with the LEDs. Then I learned that the default code's LEDs just show the OI inputs, so it's mainly just a curiosity now.

Is that enough info, or way too much?


Edit: No longer just a curiosity, as I found out the "hard" c camera code reads PWM output values, and I will probably need to to make our EasyC camera code work. How does "hard" c do it?

Last edited by P1h3r1e3d13 : 13-03-2006 at 23:02. Reason: New info
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
EasyC Wish List dcbrown Programming 32 14-08-2006 09:24
EasyC Timer and Gyro questions TubaMorg Programming 11 09-02-2006 21:19
EasyC v2.0 is mandatory for FVC! skimoose FIRST Tech Challenge 7 14-01-2006 18:37
Kickoff easyC workshop integrated into EasyC help file Dan Larochelle Programming 0 11-01-2006 06:12


All times are GMT -5. The time now is 23:00.

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