November 22, 2024, 04:58:42 AM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


SHIFTOUT on a prop-1 ?

Started by crpalmer, October 14, 2008, 12:54:44 PM

Previous topic - Next topic

crpalmer

I just saw this in an older thread:
   
QuoteRe: Is this possible with a Prop 1?
« Reply #5 on: March 17, 2008, 08:28:26 AM »

You could use a Prop-2 for more outputs. Or... if you're good at building electronics you could build up a circuit using a 74HC595 shift register (see the SHIFTOUT example in the PBASIC help file).  The BS1 doesn't have the SHIFTOUT command, but I can synthesize it in BS1 code.  If you wanted just a single LED lit you could do more with a BS1, but it requires a tricky wiring scheme called Charlieplexing (do a search on that phrase in our forums -- I've posted on it before).

If you went with the Prop-2 the program would be structurally similar.  The POT command would change to RCTIME and you would be working with Words instead of bytes, but nothing amazingly difficult.

Do you have code that does the equivalent of a SHIFTOUT on a BS1 chip?

JonnyMac

Here you go.

' =========================================================================
'
'   File...... SHIFTOUT.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Latch           = PIN2
SYMBOL  DOut            = PIN1
SYMBOL  Clock           = 0


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  shByte          = B0                    ' shifted byte
SYMBOL   lsb            =  BIT0
SYMBOL   msb            =  BIT7

SYMBOL  idx             = B2


' -----[ Initialization ]--------------------------------------------------

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000111                              ' set outputs


' -----[ Program Code ]----------------------------------------------------

Main:

  GOTO Main


' -----[ Subroutines ]-----------------------------------------------------

SHIFTOUT_595:
  FOR idx = 1 TO 8                              ' shift eight bits
    DOut = msb                                  ' shift MSB first
    PULSOUT Clock, 1                            ' clock the bit
    shByte = shByte * 2                         ' shift left
  NEXT
  PULSOUT Latch, 1                              ' latch bits to outputs
  RETURN

' -------------------------------------------------------------------------


' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office