Quote:
|
Originally Posted by xchezhd
I'm trying to use the min function on digital_in14 to limit the reverse on PWM11. The motor is activated by the p3_sw_trig.
Exactly how do I use it? just call it every loop in process_data_from_local_io
==> xchezhd
|
...hmmm I suppose you are refering to:
void Limit_Switch_Min(unsigned char switch_state, unsigned char *input_value); ... in UserRoutines.c
so I'd try something like:
/* set up a temp char variable */
unsigned char lnTemp ;
/* with your input switch wired "normally open", rc_dig_in14 is normally pulled hi...ie 1 or the enum OPEN. So, closing the switch will set it 0, or CLOSED. Then if pwm11 is < 127, Limit_Switch_Min will set it back to 127
*/
lnTemp = pwm11 ;
Limit_Switch_Min(rc_dig_in14, &lnTemp) ;
pwm11 = lnTemp ;
We didn't use this function, and, in fact, chose to wire our limit switches, normally closed. That way, they return 0 or false all of the time and 1 or true, when tripped....just a matter of taste, really...
so looking at it our way:
if (rc_dig_in14)
{
if ( pwm11 < 127)
pwm11 = 127 ;
}
...hope that helps,
Eric