Go to Post It'd be nice if, one day, people just concentrated on how to inspire your own team and your own community. Let others decide on how to inspire theirs. - George1902 [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 05-01-2007, 01:12
Generalx5's Avatar
Generalx5 Generalx5 is offline
Hard Core Inventor
AKA: Jun(John) Zheng
FRC #1346 (Trobotics)
Team Role: Student
 
Join Date: Nov 2005
Rookie Year: 2004
Location: CANADA
Posts: 94
Generalx5 will become famous soon enough
Talking Why it works with an underscore?

I have a code written up for my own custom encoder involving optical sensors, yes its a optical encoder, using quadrature.

My question is why the compiler will find a syntax error if I didn't use an underscore in my variables.

For instance, I have this before:

-------------------------------------------------------------
/*** DEFINE USER VARIABLES AND INITIALIZE THEM HERE ***/

unsigned char Sen1;
unsigned char Sen2;
unsigned char Sen3;
unsigned char Sen4;
unsigned char Sen5;


-------------------------------------------------------------
along with

-------------------------------------------------------------
void Process_Data_From_Local_IO(void)
{

Sen1 = rc_dig_in05;
Sen2 = rc_dig_in06;
Sen3 = rc_dig_in07;
Sen4 = rc_dig_in08;
Sen5 = rc_dig_in09;


after I changed it to:

-------------------------------------------------------------
/*** DEFINE USER VARIABLES AND INITIALIZE THEM HERE ***/

unsigned char Sen_1;
unsigned char Sen_2;
unsigned char Sen_3;
unsigned char Sen_4;
unsigned char Sen_5;

-------------------------------------------------------------
void Process_Data_From_Local_IO(void)
{

Sen_1 = rc_dig_in05;
Sen_2 = rc_dig_in06;
Sen_3 = rc_dig_in07;
Sen_4 = rc_dig_in08;
Sen_5 = rc_dig_in09;


-------------------------------------------------------------
Im new at programming so im open to harassment.

************************************************** ***************
Another question is how do you set a value under certan conditions in programming?

For instance, I have 5 sensors like the above. When all 5 sensors reads a certain encoding for example all 0's how do I set this reading to a specific digit, so I can later call up on again. This makes it easier for changing later due to so many sensor reading combinations.

The idea im getting at is something like:

if (rc_dig_in01 = 0,rc_dig_in02 = 0,rc_dig_in03 = 0,rc_dig_in04 = 0,rc_dig_in05 = 0) == 10
if (rc_dig_in01 = 0,rc_dig_in02 = 0,rc_dig_in03 = 0,rc_dig_in14 = 0,rc_dig_in15 = 1) == 20

and after all these are set, I can have another routine that can use those numbers:

if (20) turn on solenoid 3 etc etc.

Last edited by Generalx5 : 05-01-2007 at 01:37. Reason: Added the second part under the * line
 


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
A poximity sensor that works with IFI gear Validius Control System 10 16-03-2005 21:56
A poximity sensor that works with IFI gear Validius Electrical 10 16-03-2005 21:56
Why is Dave hanging out with these guys? JohnBoucher NASA Discussion 1 17-12-2004 10:38
RoboEmu 1.06 (works with XP and 2k) rbayer Programming 4 20-10-2002 21:47
Are you a team with very little money, why/ mnkysp6353 General Forum 6 09-10-2001 21:30


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

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