|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Pressure Switch code
I am having a problem with our compressor, spikes, and RC. I need to get the pressure switch to tell the spike that is connected to the compressor to turn on unto it read 120psi. Yet I don't even have a spike switching to fwd or rev?
I have this code in right now if(digital_io_18 == 0) { relay1_fwd == 1; } if(digital_io_18 ==1) { relay1_fwd == 0; } Can some let me know what I am doing wrong? Thank you |
|
#2
|
|||
|
|||
|
Re: Pressure Switch code
Your if statements match mine but I think it should be relay1_fwd = 1; not relay1_fwd == 1;
== is for comparing, = is for assigning values If thats not it, double check that you have the digital i/o set to input. Also check that your code is actually being called. I had my code in user_routines.c/default_routine() which wasn't being called, once i stuck the code in user_routines.c/Process_Data_From_Master_uP() it worked. Also make sure your not in disabled mode. I made the that mistake earlier this week user_routines.c/User_Initialization() digital_io_18 = INPUT; //DIGITAL I/O set to input; Good luck |
|
#3
|
|||||
|
|||||
|
Re: Pressure Switch code
Along with the == vs = confusion, you're reading the wrong thing to test the pressure switch. Writing to digital_io_18 is for configuring the pin as either an input or an output. You want read from rc_dig_in18, which gives you the value of the pin.
|
|
#4
|
||||
|
||||
|
Re: Pressure Switch code
You can just do it all in one line.
Code:
relay1_fwd=!rc_dig_in18 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PRESSURE SWITCH | Mr. Steve | Pneumatics | 20 | 01-12-2005 10:20 |
| Pressure switch code | kingpin3787 | General Forum | 11 | 22-02-2004 21:52 |
| HELP US PLEASE?!?!(pressure switch code) | kingpin3787 | General Forum | 1 | 21-02-2004 15:13 |
| pressure switch | Michael Long | Pneumatics | 1 | 11-02-2003 11:21 |
| pressure switch | Antonio | Pneumatics | 10 | 31-01-2003 03:52 |