serial to parallel IC
shmow
Posts: 109
I've a BS2 that uses a 74HC595 IC for serial to parallel discrete signals.
Here's the watered down version of what I had written for the stamp:
I've edited as far as I can for the prop but I'm not sure how to use the Pin0_clock & MSBFIRST features of
the stamp for the prop.
How do I handle these parts?
Here's the Spin that I've done so far:
Here's the watered down version of what I had written for the stamp:
' {$STAMP BS2} ' {$PBASIC 2.5} 'serial output for serial/parallex IC: - when button (pin 3 - momentary) is pressed ' propeller sends out serially binary value of 1111 ' - when BUTTON (PIN 3 - momentary) is released ' propeller sends out serially binary value of 0000 Btn PIN 3 'push button - momentary btnWrk VAR Byte Binary_Pattern VAR Byte 'variable for binary value Pin0_Clock CON 0 Pin1_DataOut CON 1 Pin2_Latch CON 2 Main: BUTTON Btn, 0, 255, 0, btnWrk, 1, Did_Press Did_Press: IF btn = 0 THEN 'when button pressed value of 1111 is sent out on pin 1 Binary_Pattern = %00001111 'binary value GOSUB Out_74HC595 'sub routine call ENDIF IF btn = 1 THEN 'when button released value of 0000 is sent out on pin 1 Binary_Pattern = %00000000 'binary value GOSUB Out_74HC595 'sub routine call ENDIF GOTO Main Out_74HC595: 'sub routine SHIFTOUT Pin1_DataOut, Pin0_Clock, MSBFIRST, [noparse][[/noparse]Binary_Pattern] PULSOUT Pin2_Latch, 5 RETURN
I've edited as far as I can for the prop but I'm not sure how to use the Pin0_clock & MSBFIRST features of
the stamp for the prop.
How do I handle these parts?
Here's the Spin that I've done so far:
'' -- input P23 turns on LED on pin P4 '' -- if LED is on then P 0, 1 & 2 send signal to 74HC595 (serial-parallel IC) '' {{LED Pushbutton 74HC595 ────────────────── ────────────────── ────────────────── 3.3V 100 Ω LED  PROP 74HC595 P 4 ───────┐ │ P 1 ─── P 14 Data In  ┤Pushbutton P 0 ─── P 11 Clock ??? GND │ P 2 ─┳─ P 12 Latch │ │ P 23 ─┫  10 kΩ │   10 kΩ GND  GND }} CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ BS2 : "BS2_Functions" ' Create BS2 Object PUB Btn_LED dira[noparse][[/noparse]4] := 1 ' make the pin an output repeat outa[noparse][[/noparse]4] := ina[noparse][[/noparse]23] ' output state equals input state if outa[noparse][[/noparse]4] BS2.start (31,30) BS2.SEROUT_dec(1,00001111,9600,1,8) BS2.PULSOUT(2,5) else BS2.SEROUT_dec(1,00000000,9600,1,8) BS2.PULSOUT(2,5)
Comments
Why not just use BS2.SHIFTOUT?? - if you have to...
However it would be considerably better you take some time and learn how the Propeller works... Start with the code of SHIFTOUT in BS2 e.g.!
BTW. don't repeat BS2.start in the loop all the time! This should be done once only...
And yes as deSilva mentions, you should be using SHIFTOUT and not SEROUT.
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
SelmaWare Solutions - StampPlot GUI for controllers, XBee and Propeller Application Boards
Southern Illinois University Carbondale, Electronic Systems Technologies
American Technical Educator's Assoc. Conference·- April, Biloxi, MS. -- PROPELLER WORKSHOP!
I used the shiftout command.
Here's the watered-down version of the program: