StampWorks Experiment 23 - on the SX ?
T&E Engineer
Posts: 1,396
I tried to recreate the BS2 version of the Stampworks 23 (74HC595 usage - pattern shifting) and I need some help in what is wrong. I don't see anything wrong after compiling it. At first I thought the pause was too short but I increased it to 10000 (from 100) and saw no output on the LEDs. The SHIFTOUT.SXB example works so I know my chip is good. Let me know...
(Also Attached)
As you can see I modified the SHIFTOUT.SXB for pattern shifting as seen in Stampworks 23 for the BS2.
' =========================================================================
'
'·· File...... SHIFTOUT.SXB
'·· Purpose... Expanding the SX outputs with a 74HC595
'·· Author.... (c) Parallax, Inc. -- All Rights Reserved
'·· E-mail.... support@parallax.com
'·· Started...
'·· Updated... 06 APR 2005
'
' =========================================================================
'
' Program Description
'
'
' Transfers a counter value to eight LEDs using a 74HC595 shift register.
'
' Device Settings
'
DEVICE········· SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ··········· 4_000_000
'
' IO Pins
'
Dpin··VAR·RA.0···' shift data
Cpin··VAR·RA.1···' shift clock
Latch··VAR·RA.2···' latch outputs
'
' Variables
'
temp1·········· VAR···· Byte
pattern··VAR·Byte
DelayTime·CON·100
' =========================================================================
· PROGRAM Start
' =========================================================================
Initialize:
·· LOW Latch
·· pattern = %00000001
'
' Subroutine Declarations
'
Out_595··SUB·1···' pass value to write
'
' Program Code
'
Start:
GoForward:
· Out_595 pattern
· Pause DelayTime
· pattern = pattern << 1
· If pattern = %10000000 goto GoReverse
· Goto GoForward
GoReverse:
· Out_595 pattern
· Pause DelayTime
· pattern = pattern >> 1
· If pattern = %00000001 goto GoForward
· Goto GoReverse
'
' Subroutine Code
'
' Use: PUT595 value
' -- moves 'value' to 74HC595
Out_595:
· temp1 = __PARAM1····' capture value
· SHIFTOUT Dpin, Cpin, MSBFIRST, temp1······· ·' send the bits
· PULSOUT Latch, 1····························· ' transfer to outputs
· RETURN
(Also Attached)
As you can see I modified the SHIFTOUT.SXB for pattern shifting as seen in Stampworks 23 for the BS2.
' =========================================================================
'
'·· File...... SHIFTOUT.SXB
'·· Purpose... Expanding the SX outputs with a 74HC595
'·· Author.... (c) Parallax, Inc. -- All Rights Reserved
'·· E-mail.... support@parallax.com
'·· Started...
'·· Updated... 06 APR 2005
'
' =========================================================================
'
' Program Description
'
'
' Transfers a counter value to eight LEDs using a 74HC595 shift register.
'
' Device Settings
'
DEVICE········· SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ··········· 4_000_000
'
' IO Pins
'
Dpin··VAR·RA.0···' shift data
Cpin··VAR·RA.1···' shift clock
Latch··VAR·RA.2···' latch outputs
'
' Variables
'
temp1·········· VAR···· Byte
pattern··VAR·Byte
DelayTime·CON·100
' =========================================================================
· PROGRAM Start
' =========================================================================
Initialize:
·· LOW Latch
·· pattern = %00000001
'
' Subroutine Declarations
'
Out_595··SUB·1···' pass value to write
'
' Program Code
'
Start:
GoForward:
· Out_595 pattern
· Pause DelayTime
· pattern = pattern << 1
· If pattern = %10000000 goto GoReverse
· Goto GoForward
GoReverse:
· Out_595 pattern
· Pause DelayTime
· pattern = pattern >> 1
· If pattern = %00000001 goto GoForward
· Goto GoReverse
'
' Subroutine Code
'
' Use: PUT595 value
' -- moves 'value' to 74HC595
Out_595:
· temp1 = __PARAM1····' capture value
· SHIFTOUT Dpin, Cpin, MSBFIRST, temp1······· ·' send the bits
· PULSOUT Latch, 1····························· ' transfer to outputs
· RETURN
Comments
You need to initialize the pattern.
After "Start:" put "pattern = %00000001" and you should be good.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
Those that would give up freedom for security will have neither.
·
An SX/B program jumps to the label "Start" after the internalization sequence so you "Initialize" section is being skipped.· I've attached a version of the program that is based on the code from StampWorks 2.0.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 11/26/2005 3:51:48 PM GMT
I tried that too but get LED's on for a second and then go out (cycle down the line).
I tried using a LOW Latch as I don't see this in the SEROUT.SXB example program.
How is this supposed to work on an SX/B ?
Don't I have to create a direction (outputs for RA too)?
A bit confused...
Thanks for the program.
However, what I see is that all the LED's turn on but stay on with·NO shifting back and forth.
Tim
Are you using SX/B version 1.42.01 ?
Make sure you don't have a wiring error.
Please post the program your using again and I'll check the generated assembly to see if there is something wrong there.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
Those that would give up freedom for security will have neither.
·
I just tried Jon's program (see his attachment) and it doesn't shift. Also I just downloaded the latest SX-Key 3.10 program from the Parallax website which says it is 1.42 (I don't know about 1.42.01).
SX/B 1.42.01 thread: http://forums.parallax.com/showthread.php?p=517621
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 11/26/2005 3:53:04 PM GMT
I copied over the 1.42.01 files and verified I NOW had 1.42.01 from 1.42. Thanks.
However, after runing your program I see all the LEDs turn on and then each one turns off in sequence from the first to the last.
E.G.
·1·· 2·· 3··· 4·· 5·· 6·· 7·· 8·· 9·· 10 11· 12 13· 14· 15
ON ON ON ON ON ON ON ON ON ON ON ON·ON·ON ON
then
OFF ON ON ON ON ON ON ON ON ON ON ON ON ON ON
then
ON OFF ON ON ON ON ON ON ON ON ON ON ON ON ON
ON ON OFF ON ON ON ON ON ON ON ON ON ON ON ON
:
ON ON ON ON ON ON ON ON ON ON ON ON ON ON OFF
ON ON ON ON ON ON ON ON ON ON ON ON ON ON ON
No shifting either.
SEE ATTACHMENT - Should be the same as Jon's original last posted program.
If that's the case then you'll want to add a separate value to send to the '595.· Define another variable called val595 and then do this:
Main:
· DO
··· val595 = ~pattern··················'·invert pattern
··· OUT_595 val595···················· ' put inverted pattern on 74x595
··· WAIT_MS DelayTime················· ' hold
··· pattern = pattern << 1············ ' shift pattern left
· LOOP UNTIL pattern = %10000000
· DO
··· val595 = ~pattern
··· OUT_595·val595
··· WAIT_MS DelayTime
··· pattern = pattern >> 1············ ' shift pattern right
· LOOP UNTIL pattern = %00000001
· GOTO Main
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 11/26/2005 4:19:14 PM GMT
·· OUT_595 ~pattern
... the compiler doesn't complain, but the compiled output ignores the ~ so the program doesn't work as expected.· I have sent a note to our compiler engineer.· If you're pressed for variable space, you can insert a bit of assembly to create send the inverted value to the subroutine:
Main:
· DO
··· \ MOV W, /pattern
··· \ MOV __PARAM1, W
··· \ CALL @__OUT_595
··· WAIT_MS DelayTime
··· pattern = pattern << 1
· LOOP UNTIL pattern = %10000000
· DO
··· \ MOV W, /pattern
··· \ MOV __PARAM1, W
··· \ CALL @__OUT_595
··· WAIT_MS DelayTime
··· pattern = pattern >> 1
· LOOP UNTIL pattern = %00000001
· GOTO Main
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 11/26/2005 4:35:57 PM GMT
I am using the PDB LEDs 10 of the 16 which are active high which is the same as the StampWorks experiment 23 (using the 74HC595).
I will try your modification and see if it makes a difference.
Thanks for your good efforts.
Timothy Gilmore
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I reloaded in your SHIFTOUT.SXB program that you posted originally in this thread. I still get the same results as I posted before (e.g. OFF ON ON ....). I have since changed out the SX28 and the 74HC595 and still get the same incorrect results.
PS: I have also reloaded in Stampworks experiment 23 into my BS2 and connected the Clock, DataOut and Latch as stated (pins 0, 1, 2) and it works fine (shifting 1 LED on at a time back and forth) with the same 74HC595 and same LEDs on the PDB.
This makes me believe that their is something not right with the SX/B firmware·(as I have also changed out the SX28 and got the same incorrect results) in the SX/B possibly the SHIFTOUT command.
Comments? Thoughts?
Jon,
Have you wired this up yourself and tested your code you submitted?
The only thing I changed from the SX/B to the BS2 was moving the 3 wires (Clock, DataOut and Latch) from RA.0, RA.1 and RA.2 to BS2 pins 0, 1 and 2.
I did load and running 1.42.01 too.
??
I can't explain what's happening on your end, and since I can't see what you're doing I have to trust that you're running the code without changes.· I have in fact loaded and am running the code (it's been running all day, I haven't done anything else).· Just to be sure, I've re-opened and downloaded the program to my SX28 on the PDB.· It's running fine.
I don't know why this would make any difference, but have you tried a different set of pins?·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Here are the facts as I see them.
I am using a PDB with 4 Mhz resonator.
I have replaced different 3 SX28s and 3 74HC595 (2 different mfg).
The 3 wires (DataOut, Clock and Latch) are brought to pins 0, 1, 2 on a BS2 and EVERYTHING WORKS PERFECTLY RUNNING THE STAMPWORKS EXPERIMENT·23·WITH·A BS2·(595·SHIFTOUT example). When brought back to the SX28 on RA, RB or RC (modified below):· it sequences through all LEDs and leaves them all on. (INCORRECT)
Dpin··VAR·RA.0···' shift data
Cpin··VAR·RA.1···' shift clock
Latch··VAR·RA.2···' latch outputs
(only change in firmware is to modify to RB or RC statements and move 3 wires respectively to RA, RB and RC) - All has incorrect response· - NO OTHER CHANGES MADE.
I also took the SX28 out and hardwired it and the 4 MHz resonator (pin 26 & 27), /MCLR (to 10K resistor to +5Vdc), Vss (pin 4 to GND), Vdd (pin 2 to +5vdc). DataOut to RA.0 (pin 6), Clock to RA.1 (pin 7) and Latch to RA.2 (pin 8). (As seen on page 6 of the "Programming the SX MicroController" Book - came with the SX Tech Tool Kit PRO)
I used your last attached code and got the same results everytime.
I downloaded 1.42.01 and the About window verifies that (was running 1.42).
I believe it is the SX coding as I have proved everything else works correctly. (74HC595 works with the BS2 as stated above)(different SX28 and different Resonator moved off the board and run independently - incorrect response)
All hardware (except SX28 works) with the BS2.
Ideas??? Thoughts ????
This is really stumping me to no end.
If you live within an hour of Dallas, TX I will pack-up my PDB and bring it to you, then figure out what's going on at you're end.· Do you live in Texas -- near the Metroplex?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
· RA = %0000
· TRIS_A = %1000
This initializes all of the '595 pins to outputs and low.· Maybe something funky is happening on your system with the clock line, and it's being ignored in the original program.··SHIFTOUT takes the clock line and simply inverts it to clock bits, maybe it's out of sync on your system.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
You are an incredible individual!!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It's Only A Stupid Question If You Have Not Googled It First!!
Tim:·I've attached·another version of the program ( that still works ) -- it has the initialization of all pins connected to the '595 and includes a manual replacement for SHIFTOUT and PULSOUT.· Give it a try.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I deeply appologize for this embarassing moment. I found out the problem as operator error for the most part.
The BS2 stamp (Experiment 23) shows the following:
Clock·········· CON···· 0······················ ' shift clock (74HC595.11)
DataOut········ CON···· 1······················ ' serial data out (74HC595.14)
Latch·········· CON···· 2······················ ' output latch (74HC595.12)
and the SX SHIFTOUT program shows the following:
Dpin··VAR·RA.0···' shift data
Cpin··VAR·RA.1···' shift clock
Latch··VAR·RA.2···' latch outputs
No one noticed this difference including myself.
After concentrating on wires for 595 pins 11, 14 and 12 for pins 0, 1 and 2 - I failed to see that the Dpin and Cpin are reversed as compared to the BS2 program. I should have caught something so simple.
When I changed the SX code to read:
Dpin··VAR·RA.1···' shift data
Cpin··VAR·RA.0···' shift clock
Latch··VAR·RA.2···' latch outputs
It worked fine as it should.
Jon,
You were right about the clock line as this is when I focused on the clock and saw the problem.
Once again - I appologize for all inconviences.
Thanks to all
Timothy Gilmore
PS: I hope I did not kill too much of your Holiday weekend as it did mine.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
James Newton, Host of SXList.com
james at sxlist,com 1-619-652-0593 fax:1-208-279-8767
SX FAQ / Code / Tutorials / Documentation:
http://www.sxlist.com Pick faster!