Help using shift register STP16DPS05.

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Help using shift register STP16DPS05.

Post by FFMan »

Someone helpfully pointed me in the direction of this shift register for an add-on to an existing project. Its exactly what I need.

I've spent an evening trying to make it work to no avail.

I'm not used to reading datasheets (attached), and maybe this one isn't very good, but I am assuming that the led output feeds the anode of the LED - is this correct ?

I am also assuming I can tie DM2 low if I'm not interested in the error detection mode ? I only have 3 io lines available to drive this so I hope this is the case.

I think I should used ShiftEx here, does anyone have any sample code that works with this device perhaps?

In the absence of knowing exactly how to setup shiftex I wrote some bitbang code and scoped the outputs to get what I thought was the same as in the timing diagram but I can't get the test led to turn on even though I am sending data to turn every output on.

Any comments/help appreciated.

Code below. Wait times are a guess but should operate device within spec.

Code: Select all

	
        for byLoop=0 to 15
		call putpin(SDI,zxoutputhigh)
		sleep (0.01)
		Call Putpin(CLK,zxoutputhigh)
		sleep (0.01)
		Call Putpin(CLK,zxoutputlow)
	next 
	sleep (0.01)
	
	'Latch data
	Call Putpin(SDI,zxoutputlow)
	Call Putpin(DM1,zxoutputhigh)
	Call Putpin(CLK,zxoutputhigh)
	Sleep (0.01)
	Call putpin(DM1,zxoutputlow)
	Call putpin(CLK,zxoutputlow)
Attachments
Trace of CLK and DM1 lines for same code
Trace of CLK and DM1 lines for same code
Capture-CLK-DM1.JPG (33.89 KiB) Viewed 3356 times
CaptureSDI-CLK.JPG
Trace of SDI & CLK lines
(53 KiB) Downloaded 163 times
rosariote
Posts: 39
Joined: 22 July 2007, 10:12 AM

serial out prolem

Post by rosariote »

Hi,
In your program your are using the sdi. Sdi = it is the data in to the micro. You need to use the sdo= output data. Any way I wrote a program so you can test it. Attached it is the program.
Attachments
serial_output.bas
(1.08 KiB) Downloaded 330 times
rosariote
Posts: 39
Joined: 22 July 2007, 10:12 AM

Post by rosariote »

Hi,
Please change the variable dat_out from integer to UnsignedInteger. I forgot that integer = 32,767 and UnsignedInteger = 65,535. You need a variable of 16 bits to be able to set all the bits in the serial chip.
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Help using shift register STP16DPS05.

Post by dkinzer »

FFMan wrote:I am assuming that the led output feeds the anode of the LED - is this correct ?
As I read the datasheet, the outputs sink current so you could connect the cathode of the led to the output and then connect the anode through a current limiting resistor to V+.
FFMan wrote:I am also assuming I can tie DM2 low ...
.Yes, you can tie OE/DM2 low so that the outputs are constantly enabled.
FFMan wrote:I think I should used ShiftEx here, does anyone have any sample code that works with this device perhaps?
From the timing diagram in the datasheet you can see that the data bit must be present on SDI before the rising edge of the clock. In the "Recommended operation conditions" section you can find the setup time is 10nS and the minimum clock high time is 8nS and the data hold time after the rising edge is 5nS. These timing constraints are easily met using ShiftOutEx().

You should initialize the clock output of the ZX to logic zero - this will result in a positive pulse for each data bit. It looks like the device is designed for MSB first. If you use MSB order the first of 16 bits sent (to SDI) will end up on OUT15.
- Don Kinzer
rosariote
Posts: 39
Joined: 22 July 2007, 10:12 AM

Post by rosariote »

Hi,
OOOOPPPSSS It is my fault. I misleading the SDI with the SDO. I modified the program to change the SDO with the SDI. Also I set permanently the OE MD2 low after the last bit send out.
Attachments
serial_output.bas
(1.13 KiB) Downloaded 340 times
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Post by FFMan »

I still can't get this to function at all.

I tweaked my bit bang code so it more accurately represented the timing diagram and the 2 traces are attached. All OUTs are switched high to eliminate msb/lsb issues at this stage,

My sleep between switches is still 0.01 which is very leisurely but means I can capture the trace readily.

I tried using shiftex also, but I can't get a sensible capture on my scope to verify what its doing. does it do the 17th clock pulse as shown in figure 7 or do I need to toggle this along with DM1 to latch the data ?
Attachments
CaptureSunCLK-DM1.jpg
CLK & DM1
(69.79 KiB) Downloaded 169 times
CaptureSunSDI-CLK.jpg
SDI & CLK traces
SDI always high to turn on all bits.
(73.02 KiB) Downloaded 173 times
rosariote
Posts: 39
Joined: 22 July 2007, 10:12 AM

Help using shift register STP16DPS05.

Post by rosariote »

Hi,
I think the problem is in at the end of the clocks. You need to send clock 16 with le/dmi low and oe/dm2 high. Then set le/dm1 high/ clock 17 /lower le/dmi. Then lower OE/dm2 to enable the output. I modified my program to do it as above described. The instructions sucks. See if my program run OKAY. It will set one led ON and next OFF all 16 lights.
Attachments
serial_output.bas
(1.24 KiB) Downloaded 322 times
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

FFMan wrote:[...] does it do the 17th clock pulse as shown in figure 7 or do I need to toggle this along with DM1 to latch the data ?
The maximum number of clock pulses generated by ShiftOutEx() is 16. If an additional clock pulse is needed it will have to be generated separately.
- Don Kinzer
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Post by FFMan »

I notice in the data sheet for this pesky device it doesn't appear to specify where the resistor R-EXT connects to other than the pin. R-EXT programs the led current and I have tried the resistor between R-EXT and the 5v line, and R-EXT and gnd but neither works.

I think I'm going to call it a day on this and go back to plan A (328n, serial link and darlington drivers), bigger but a known quantity.

If anyone in the UK wants a couple of shift registers to play with, do shout.
rosariote
Posts: 39
Joined: 22 July 2007, 10:12 AM

Post by rosariote »

Hi,
You should try the Texas Instrument TLC5926. They explained it better on how to use it with timing signals.
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Post by FFMan »

ok I see the TI one

Have you got any working code for that ?

Ideally I need through hole version - i'll see if they do one.
eserdahl
Posts: 6
Joined: 14 December 2005, 16:06 PM
Location: Sunnyvale, CA
Contact:

Help using shift register STP16DPS05.

Post by eserdahl »

The other end of R-EXT goes to GND. A trial value would be something like 1K to 2K, fine tune after you get it working. I think you still aren't getting the serial input correct. When you do and the R-EXT is to GND, the LED will light.
----- Original Message -----
From: ZBasic (zbasic.forum@zbasic.net)
To: zbasic.forum@zbasic.net (zbasic.forum@zbasic.net)
Sent: Tuesday, September 08, 2015 7:17 AM
Subject: RE: Help using shift register STP16DPS05.


I notice in the data sheet for this pesky device it doesn't appear to specify where the resistor R-EXT connects to other than the pin. R-EXT programs the led current and I have tried the resistor between R-EXT and the 5v line, and R-EXT and gnd but neither works.

I think I'm going to call it a day on this and go back to plan A (328n, serial link and darlington drivers), bigger but a known quantity.

If anyone in the UK wants a couple of shift registers to play with, do shout.




-------------------- m2f --------------------

Read this topic online here:
http://www.zbasic.net/forum/viewtopic.php?p=10565#10565

-------------------- m2f --------------------
rosariote
Posts: 39
Joined: 22 July 2007, 10:12 AM

Post by rosariote »

Hi,
Did you try my program? I modified it to handle 17 clocks and enable the output by zeroing the OE_DM2 after the 17 clock it is been issued. It is attached after the dkinzer messages.
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Post by FFMan »

rosariote - sorry no I've not tried your code as there seem to be at least one issue as it doesn't pulse the clock a 17th time as indicated by the data sheet when I read it.

I was hoping someone could had some proven working code, picking up someone elses unproven code rarely proves productive I find, and I have limited time to play with this due to family commitments.

thanks for all the comments. I might have a last play tomorrow before giving up.
rosariote
Posts: 39
Joined: 22 July 2007, 10:12 AM

Post by rosariote »

Hi,
Make sure you use the last one. The first one it is only 16 pulses. I corrected in the second one to send 17 pulses and turn the display by lower the OE_DM2 . You most setup the port pins follow yours setup. Good luck.
Post Reply