From 4021 to 4094? - Solved
OK so I dealt with the changing pinstate based on individual bits in a variable by bitwise shifting by (1*whatever bit# I wanted to know about in the variable), then seeing if the result was >=128 and making my decision based on that.
Thanks,
Rick
I've made progress with the 4094 output function, I found this PBASIC code for the 4094 and it helped me understand the order in which the clock/strobe/data etc gets pulsed:
And so now I have some code that sends info to the 4094 accurately, I'm just not sure how to make the pin High or Low via a variable:
outa[noparse][[/noparse]DATA]~~ = High on DATA pin
outa[noparse][[/noparse]DATA]~ = Low on DATA pin
But where is the DataPinState := LSB[noparse][[/noparse]MyVar]??
Do I have to use IF statements?
I appreciate peoples help,
Thanks,
Rick
Hello,
I'm working on a project that needs more inputs/outputs than the prop has.
I'm using 4021s for inputs and 4094s for outputs..well almost.
I modified the NES object in the obex since it made use of 4021s, its working great.
I'm not sure how to flip this around for a 4094 for my outputs, any help would be appreciated.
Thanks,
Rick
Post Edited (CassLan) : 3/24/2009 11:04:07 PM GMT
Thanks,
Rick
I've made progress with the 4094 output function, I found this PBASIC code for the 4094 and it helped me understand the order in which the clock/strobe/data etc gets pulsed:
SYMBOL Strobe = 0
SYMBOL Data = Pin1
SYMBOL Clock = 2
SYMBOL outByte = B0
SYMBOL outbit = Bit7 ' high bit of outByte
SYMBOL shift = B2
' other code here...
Out_8:
FOR shift = 1 TO 8
Data = outBit ' make bit available
PULSOUT Clock, 1 ' clock the bit
OutByte = outByte * 2 ' shift bits left
NEXT shift
PULSOUT Strobe, 1 ' data -> outputs
RETURN
And so now I have some code that sends info to the 4094 accurately, I'm just not sure how to make the pin High or Low via a variable:
outa[noparse][[/noparse]DATA]~~ = High on DATA pin
outa[noparse][[/noparse]DATA]~ = Low on DATA pin
But where is the DataPinState := LSB[noparse][[/noparse]MyVar]??
Do I have to use IF statements?
I appreciate peoples help,
Thanks,
Rick
Hello,
I'm working on a project that needs more inputs/outputs than the prop has.
I'm using 4021s for inputs and 4094s for outputs..well almost.
I modified the NES object in the obex since it made use of 4021s, its working great.
I'm not sure how to flip this around for a 4094 for my outputs, any help would be appreciated.
OBJ
VAR
long latch, data, clk, type, bits
PUB Init(l, d, c) | tmp
{{ Initializes pin assignments and sets intial directions and pin values
Arguments:
l -- latch pin, orange wire
d -- data pin, red wire
c -- clock pin, yellow wire
}}
latch := l
data := d
clk := c
bits := 16 ' get all bits for init
dira[noparse][[/noparse]LATCH]~~ ' LATCH to output
dira[noparse][[/noparse]CLK]~~ ' CLK to output
dira[noparse][[/noparse]DATA]~ ' Data to input
outa[noparse][[/noparse]LATCH]~~ ' high LATCH
tmp := inputs
PUB inputs : btns | InBit
outa[noparse][[/noparse]LATCH]~ ' low LATCH
outa[noparse][[/noparse]CLK]~ ' Set clock low
btns:=0
REPEAT bits ' for number of bits
InBit:= ina[noparse][[/noparse]DATA] ' get bit value
btns := (btns >> 1) + (InBit << (bits-1)) ' Add to value shifted by position
!outa[noparse][[/noparse]CLK] ' cycle clock
!outa[noparse][[/noparse]CLK]
waitcnt(500 + cnt) ' time delay
outa[noparse][[/noparse]LATCH]~~ ' high LATCH
Thanks,
Rick
Post Edited (CassLan) : 3/24/2009 11:04:07 PM GMT
