Searching \ for '[PIC]: ===== >B to C' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/languages.htm?key=c
Search entire site for: '===== >B to C'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: ===== >B to C'
2001\08\19@134757 by Raymond Choat

flavicon
face
Ok I am sending an on/off signal from a 16f876  Port C.2 to a 16f877 Port
B.2 and my master program does not see it. The slave pic boards have been
tested and work. Here is program I am using in MASTER Pic. What is to happen
is Master signals Slave to run and Slave then signals Master when its done.
Then Master goes to next section of code to run next Slave but not before
last slave signals done.

This program will cycle through everypart turning everything on and off but
never waits for slave pics to signal its done. It just continues and runs
all six sections. So for some reason it looks like the Master is not seeing
the slave saying when its done. Where did I go wrong?
Could something in my Epic programmer be set wrong? My wiring is like so.

16f877(Master)  <------------------------[ 220 ohm ]----< 16f876(Slave)

resistor is for zap protection
line is only 14inches long.
Here is program:


====================================================
====================================================

@ 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

= = = = = = = = = = = = = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = = = = = = = = = =


Thanks Wrong Way Ray (Ray Choat)
spam_OUTrcTakeThisOuTspamkenai.net

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2001\08\19@144706 by Bob Barr

picon face
Raymond Choat wrote:
>
>Ok I am sending an on/off signal from a 16f876  Port C.2 to a 16f877 Port
>B.2 and my master program does not see it. The slave pic boards have been
>tested and work. Here is program I am using in MASTER Pic. What is to
>happen
>is Master signals Slave to run and Slave then signals Master when its done.
>Then Master goes to next section of code to run next Slave but not before
>last slave signals done.
>
>This program will cycle through everypart turning everything on and off but
>never waits for slave pics to signal its done. It just continues and runs
>all six sections. So for some reason it looks like the Master is not seeing
>the slave saying when its done. Where did I go wrong?
>Could something in my Epic programmer be set wrong? My wiring is like so.
>

Depending on what your slaves are doing, I have to wonder what their
'finish' state is and how quickly they can respond to the next 'go' command.
You may need a simple handshake between your main and slaves to ensure that
each slave starts and *then* gives a valid 'done' response.

If you issue the 'go', wait for 'not done', and then wait for the 'done'
response, main will be able to check that each slave actually runs its
process. Your main code may be proceeding on invalid 'done' signals.

Regards, Bob



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu


2001\08\19@162709 by Raymond Choat

flavicon
face
My slave (16f876pic board) runs a 24volt air valve. The Master (16f877) runs
6 of these slaves. The Master activates slave by signaling a LOW signal that
was held high. This signal is working as each valve will turn on and off
with the test program run. The Slave tells Master that it has finished (or
end limit was reached) by sending a HIGH signal from its port C to the
Masters port B. Signal is low when slave is busy and high when it is
finished.  I checked with digital probe and signals are correct. The signal
to the slave is correct and signal back from slave is correct. So it must be
how the Master sees this busy/finished signal from the slave. It seems
simple what I am trying to do "Turn on slave and wait till slave is done,
then continue". None of the signals timing or speed is real critical.

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"?

Main = 0                         'Master signals Slave to turn OFF
While Main_done = 0   'Wait till Slave signals that its done with a high
signal
Wend                             'Then continue

Is there a better way of doing this with PBP?





{Original Message removed}

2001\08\19@201923 by Bob Barr

picon face
Raymond Choat wrote:
{Quote hidden}

Simple things between two (or more processors) are rarely as simple as they
may appear to be. :=)

No, your code does not require that the master see a low before it sees a
high. What I'm suggesting is that it should be changed so that it does.

The timing of the interactions between master and slave processors can
create all sorts of problems that aren't immediately obvious.


How quickly can a slave respond to the master's 'main = 0' port change?
Unless it's instantaneous (or faster), a 'race condition' between the two
processors can result.

Since the slave has to detect the port change and can only then respond by
dropping its '_done' line, your master processor can be checking the
condition of the _done signal well before the slave has had any chance to
drop it.

In this case, _done doesn't just mean 'done', it also means 'not responded
to yet'. If this happens, the master 'thinks' that the slave is finished
when it had just seen the change command and had not yet responded to it.

Without a clear indication from the slave that it has seen the command, the
master can't know whether the _done indication is valid or not.

By having the slaves go busy in response to every command, the master can
'see' the slave go busy. (At this point, the master knows that the command
has been accepted by the slave.) The master can then wait for the _done
indication when the slave completes its processing (or immediately if no
processing is needed).


Regards, Bob


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu


2001\08\20@084341 by Olin Lathrop
face picon face
> Ok I am sending an on/off signal from a 16f876  Port C.2 to a 16f877 Port
> B.2 and my master program does not see it.

Is that because it's not there or because the master has a bug?  Look at the
line with a scope or artificially create the signal with a switch.  This
will at least isolate the problem to the master or the slave.  It seems
pointless to go digging around in the code until you know which unit is
having the problem.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, EraseMEolinspam_OUTspamTakeThisOuTembedinc.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


2001\08\20@084347 by Olin Lathrop

face picon face
> 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, olinspamspam_OUTembedinc.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


2001\08\20@112716 by Raymond Choat

flavicon
face
I have already tested the slave boards using a switch on input and an led on
the output. Seems to work perfect. So I am 98% sure its in the MASTER or
Master Program. When the Master and Slave is hooked together and tested I
get correct signals also but the Master still does not "Pause" till   _done
signal is recieved from slave. I have never had something so simple be
sooooo hard.
Wrong Way Ray (Ray Choat)

{Original Message removed}

2001\08\20@113341 by Raymond Choat

flavicon
face
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 removed}

2001\08\20@123919 by Bob Barr

picon face
Raymond Choat wrote:
>
>I have already tested the slave boards using a switch on input and an led
>on
>the output. Seems to work perfect. So I am 98% sure its in the MASTER or
>Master Program. When the Master and Slave is hooked together and tested I
>get correct signals also but the Master still does not "Pause" till   _done
>signal is recieved from slave. I have never had something so simple be
>sooooo hard.
>Wrong Way Ray (Ray Choat)
>

Don't be so convinced that you're doing something so simple that it just
*has* to work.

In theory, you are, indeed, performing a simple task.

Back in the real world, however, getting 2 microprocessors (each running
their separate programs at multi-megahertz rates) is not necessarily all
that simple.

Unless you can flip your switch in microseconds and see the LED light in the
same microsecond kind of time frame, your manual test isn't doing anything
close (speedwise) to what your master micro is doing. Your test may be
comforting but its results are not a reflection of the 'real world' in which
your system is operating.

Getting a reliable command/response handshake going between your master and
its slaves will go a long way toward resolving your problem.

Regards, Bob



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\08\20@202546 by Raymond Choat

flavicon
face
Got it fixed. Something you said gave me the idea to look more at my timing
of things. Then I got the idea that maybe the slave is not fast enough
putting the _busy signal to low (showing busy) that would have the Master
wait. So I just added the pause below and it worked. Thanks for bouncing the
ball with me.

Here is the pause I added to my MASTER program.

           Clamp = 1                               'Master signals Slave to
turn ON
           pause 100                              ' pause allows slave to
turn _done to low showing busy
           While Clamp_done = 0          'Wait till Slave signals that its
done then continue
           Wend

It usually is something this simple that can stump me, must be getting
old....ha.

Thanks Again
Wrong Way Ray (Ray Choat)


{Original Message removed}

2001\08\20@204315 by Bob Barr

picon face
Raymond Choat wrote:
>
>Got it fixed. Something you said gave me the idea to look more at my timing
>of things. Then I got the idea that maybe the slave is not fast enough
>putting the _busy signal to low (showing busy) that would have the Master
>wait. So I just added the pause below and it worked. Thanks for bouncing
>the
>ball with me.
>

Glad to see that you got things working. As long as your speed requirements
aren't particularly high, this approach will certainly work. Giving the
slave enough time to recognize and respond to its incoming command will let
your master always see a valid '_busy' signal.

If you encounter a similar situation with tighter speed constraints, you may
find that using a fixed delay is too slow to meet your comm  requirements.
In that case, a 'wait for busy', 'wait for not busy' handshake mechanism
will allow communication to run as fast as your slaves will allow.

Regards, Bob

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\08\21@142814 by Barry Gershenfeld

picon face
> I got the idea that maybe the slave is not fast enough
>putting the _busy signal to low (showing busy) that would have the Master
>wait. So I just added the pause below and it worked.
>           pause 100                              ' pause allows slave to

And towards that goal of fast, and reliable, what you can do without
making it too complex is to write a loop that checks for that _busy
signal to change, but is limited by a count.   So that if the signal
never went busy, you loop would just wind up running for "100", but
if the signal changed while the loop was polling, it would exit
immediately and thus not slow things down any more than necessary.

Barry

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\08\21@220905 by Raymond Choat

flavicon
face
Thanks for the idea, I will consider it.
Thanks Wrong Way Ray (Raymond Choat)

----- Original Message -----
From: "Barry Gershenfeld" <@spam@barryKILLspamspamZMICRO.COM>
To: <KILLspamPICLISTKILLspamspamMITVMA.MIT.EDU>
Sent: Tuesday, August 21, 2001 10:18 AM
Subject: Re: [PIC]: ===== >B to C


{Quote hidden}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...