My orignal code tracked the valve as to if it was open or not. But I need to know when the air cylinder reaches the end limit. When the slave sees this limit switch it turns on the _done line. Then I tried simpler code as in this "test" program and it still does not work. Here is my test code. @ DEVICE pic16F877, hs_osc, wdt_off, pwrt_off, bod_off, lvp_off,cpd_off,wrt_off, protect_off DEFINE OSC 20 '20 MHz crystal ' - - - -SETUP PORTA for OUTPUT- - - - - - - ADCON1 = 7 ' Set PORTA and PORTE to digital TRISA = %00000000 ' set PortA for all output PortA = %00000000 ' turn all lines on PortA OFF ' - - - -SETUP PORTB for INPUT- - - - TRISB = %01111111 ' sparein, trig, emer on PORTB to input Main_done var PORTB.0 ' Main Air Supply done line Clamp_done var PORTB.1 ' Clamp done line Index_done var PORTB.2 ' Index done line Tilt_done var PORTB.3 ' Tilt done line TV1_done var PORTB.4 ' Transverse1 done line TV2_done var PORTB.5 ' Transverse2 done line Counter_done var PORTB.6 ' Counter done line ' var PORTB.7 ' not used ' - - - -SETUP PORTC for OUTPUT- - - - TRISC = %00000000 ' set PortC for all output PortC = %00000000 ' turn off all portC Main var PORTC.0 ' Main Air Supply Valve Clamp var PORTC.1 ' Clamp Valve Index var PORTC.2 ' Index Valve Tilt var PORTC.3 ' Tilt Valve TV1 var PORTC.4 ' Transverse1 Valve TV2 var PORTC.5 ' Transverse2 Valve Counter var PORTC.6 ' Subract from Mechanical Counter ' var PORTC.7 ' not used ' - - - -SETUP PORTD for OUTPUT - - - - TRISD = %11110000 ' set PortD for 4 output & 4 input PortD = %00000000 ' turn off all portD ' - - - -SETUP PORTE for OUTPUT- - - - TRISE = %00000111 ' set PortE for all input PortE = %00000000 ' turn off all portE '-------------------------------------------------------- ' = = = = = = = = = = ' = TEST Program = ' = = = = = = = = = = test: Main = 1 'Master signals Slave to turn ON While Main_done = 0 'Wait till Slave signals that its done Wend Clamp = 1 'Master signals Slave to turn ON While Clamp_done = 0 'Wait till Slave signals that its done Wend Index = 1 'Master signals Slave to turn ON While Index_done = 0 'Wait till Slave signals that its done Wend Main = 0 'Master signals Slave to turn OFF While Main_done = 0 'Wait till Slave signals that its done Wend Clamp = 0 'Master signals Slave to turn OFF While Clamp_done = 0 'Wait till Slave signals that its done Wend Index = 0 'Master signals Slave to turn OFF While Index_done = 0 'Wait till Slave signals that its done Wend goto test = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ----- Original Message ----- From: "Olin Lathrop" To: Sent: Monday, August 20, 2001 4:02 AM Subject: Re: [PIC]: ===== >B to C > > Sometimes when the master activates the slave, the slave may already be in > > that position and the _done line will already show high (finished), never > > showing (low)busy. Here is a piece of the code that the Master uses to > talk > > to slave. Does this piece of code require that it sees the "low" first > then > > exits when it goes "high"? > > I haven't looked at your code, but it might be simpler to have a valve > open/closed line instead of command busy/done line. That way you not only > know when the slave has finished a command, but you also always know what > state the valves are in. If the master ever commands a slave to open its > valve and that valve is already open, then the slave will do nothing and the > master sees the command completing immediately. > > > ******************************************************************** > Olin Lathrop, embedded systems consultant in Littleton Massachusetts > (978) 742-9014, olin@embedinc.com, http://www.embedinc.com > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > > > -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads