|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 |
|
|
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 |