EFX-TEK

TEK Talk => Programming Techniques => Topic started by: Natalie P on June 07, 2014, 09:56:10 PM

Title: Condensing Codes on Prop-1
Post by: Natalie P on June 07, 2014, 09:56:10 PM
I apologize in advance as this is a likely a remedial question: I have used this code:
SEROUT Sio, Baud,("!DC16", %00, "S", %00000100, %00000000)
...to turn several outs on and off at once on the DC-16 board instead of having to reference each individual out.  Using this same condensed format, how do i write it out when I want to use this directly for the Prop-1?
Title: Re: Condensing Codes on Prop-1
Post by: JackMan on June 08, 2014, 01:37:03 PM
Pretty simple. Here's some examples.
PINS = %00000000 (all off)
PINS = %11111111 (all on)
PINS = %10000001 (OUT0 and OUT7 on)
Title: Re: Condensing Codes on Prop-1
Post by: JonnyMac on June 09, 2014, 09:58:21 AM
As Jack points out, PINS it is. That said, make sure you set the DIRS register to setup your pins as outputs first. For example, I pre-configure most of my programs to have P7 as serial control of external devices (setup as input -- SEROUT/SERIN will reconfigure), P6 as my trigger input, and P5..P0 as my outputs. The reset section in my standard template looks like this:

Reset:
  PINS = %00000000
  DIRS = %00111111


The first line clears any outputs (I can jump back to this at the end of a cycle), the second line sets P5..P0 as outputs so that I can write directly to PINS later.
Title: Re: Condensing Codes on Prop-1
Post by: Natalie P on June 16, 2014, 01:34:43 PM
Cool, thanks!  So then this code option is only applicable for the PINS.  Is there code for using the OUTS in this format?
Title: Re: Condensing Codes on Prop-1
Post by: JackMan on June 16, 2014, 04:21:46 PM
 The TTL pins and the OUT's are both active at the same time. You can't turn on just a PIN or just an OUT.
In other words, if PIN0 is active, OUT0 will be active as well.
Title: Re: Condensing Codes on Prop-1
Post by: Natalie P on June 16, 2014, 09:19:15 PM
Ahh okay...thank you for clarifying, JackMan!  :D
Title: Re: Condensing Codes on Prop-1
Post by: JonnyMac on June 17, 2014, 09:42:28 AM
And now for the scary (yet important) details....

The W pins on the TTL headers are what we call "active high," that is, when you make the pin HIGH it will be at 5v. When you make the pin LOW it will be a 0v -- both referenced from the B (ground) pins.

The OUTx connectors are called "open collector." What this means is that these outputs act like an open switch until you make the associated pin go HIGH. When you do, the "switch" closes and connects to the ground side of the circuit. This is why connections on the OUTx terminal are always between the V+ terminal (positive voltage) and OUTx (switched ground).
Title: Re: Condensing Codes on Prop-1
Post by: Natalie P on June 19, 2014, 01:28:16 PM
Excellent, thank you!, JonnyMac!  I understood how the OUTs function but appreaciate the explaination of it all!  :D