going out on a limb and praying the schematic is correct

MrDEB

Well-Known Member
my Christmas 2025 project I had to redo (see posthttps://www.electro-tech-online.com/threads/using-a-rtc-in-sf-basic.166376/post-1460947
and have yet to get a 74hc595 to work properly but it should work as per schematic.
Am aware this is asking for more problems but hopefully not.
 

Attachments

  • Schematic_SNOW-COPY2-1_2025-05-23.pdf
    269.7 KB · Views: 99
Offered without comment in the futile hope that MrDEB will make a little effort to understand how to use the '595, because he ain't got a clue now.



Imagine the twinkling that could occur if you rapidly shifted out bytes of random numbers?


Code:
{
*****************************************************************************
*  Name    : UNTITLED.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2025 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 5/15/2025                                                      *
*  Version : 1.0                                                            *
*  Notes   :                                                                *
*          :                                                                *
*****************************************************************************
}
Device = 18F43K22
Clock = 8

// int osc and IO pin libraries
Include "intosc.bas"
#option DIGITALIO_INIT = true       // automatically call setalldigital
Include "setdigitalio.bas"
Include "SHIFT.BAS"

Dim LATCH As PORTB.4        // hc595 pin 12 LCHCLK
Dim DATA As PORTA.1         // hc595 pin 14 SDI
Dim CLK As PORTB.3          // hc595 pin 11 SFTCLK
Dim RST As PORTB.1          // hc595 pin 10 RSTn (no connection to pcb)
Dim SDO As PORTA.4          // hc595 pin 9 SDO QH' shift out

Dim Leds As Byte

// set pin modes
Shift.SetClock(CLK)
Shift.SetOutput(DATA)
Shift.SetInput(SDO)
High(RST)
Low(LATCH)
 

 // if there was a connection...
//Low(RST)
//DelayUS(100)
//High(RST)


// cycle leds
Leds = 0
While (true)

//remove {curly brackets} around each section to test

{//ORIGINAL CODE – What happens here?
    If (Leds = 0) Then
        Leds = 1
    EndIf
    Shift.Out(MSB_FIRST, Leds, 8)
    LATCH = 1
    LATCH = 0
    DelayMS(250)
    Leds = Leds << 1
// END OF ORIGINAL CODE
}

{//WHAT HAPPENS IF YOU TRY THIS?
Leds = %11111111
Shift.Out(MSB_FIRST, Leds, 8)
LATCH = 1
LATCH = 0
Delayms(500)
Leds = %10101010
Shift.Out(MSB_FIRST, Leds, 8)
LATCH = 1
LATCH = 0
Delayms(500)
//END OF EXAMPLE 1
}

{//WHAT HAPPENS IF YOU TRY THIS?
Leds = %10101010
Shift.Out(MSB_FIRST, Leds, 8)
LATCH = 1
LATCH = 0
Delayms(500)
Leds = %01010101
Shift.Out(MSB_FIRST, Leds, 8)
LATCH = 1
LATCH = 0
Delayms(500)
//END OF EXAMPLE 2
}

End While
 
Last edited:
If I was doing it I'd connect up the 595s in a daisy chain similar to post 1 with one clk and data pin using the SPI mssp peripheral instead of bit banging using SHIFT.

Rig up a timer and clock out all 80 bits at once... probably take <20usec without much wrangling.
 
pOST#43 DOES NOTHING. I would like to be able to use the 8 bits that Jon posted ($11111111)
Going to look at it better as well as the SPI mssp that Tumbleweed suggested.
 
pOST#43 DOES NOTHING.
Geez oh grief. Did you even LOOK at the code? The code was written so you could try three different options so you make get a clue, but it would take some effort.... perhaps 30 seconds total. If you had even looked at it you would have noticed:





Did you even look at the code? Did you not notice that virtually all of it was light blue like a comment.

Remove the curly brackets { } around one section. Try it out. Put them back and repeat for the next section. Try it out. Engage brain. LOOK AT CODE AND TRY TO UNDERSTAND THE DIFFERENCE.

I saw how lost you are with this and that you don't understand that you can control each and every LED individually by changing its associated bit and shifting the ENTIRE SERIES OF BYTES OUT, so reluctantly I made an absolutely worthless attempt to help you once more. F**k me. I am so stupid for trying.

You'll say "I didn't understand the curly brackets." Bull excrement. You've been butchering Swordfish Basic for a dozen years or more. Not my fault if you don't understand the simplest features.
 
For those playing along at home, here is the code shown in the Swordfish editor.

For those with normal visual acuity and several interconnected brain cells, you can see:

> Code is black, non-italic font

> Comments are light blue, italic font

In the attached PDF, you'll see MrDEB is right - between the WHILE and WEND of the main program loop, there are only comments, with the instructions to test each section by removing the curly brackets. This would be OBVIOUS to anybody attempting to understand the code.



 

Attachments

  • SWORDFISH EDITOR.pdf
    36.8 KB · Views: 20
Even St. Jude would give up.

Saint Jude, also known as Saint Jude Thaddeus, is widely recognized as the Patron Saint of Hopeless Causes and Patron Saint of Lost Causes. He is also known as the Patron Saint of the Impossible.

 
I missed some cuely backets that are kind of hidden (see line 50 and 62)
The Curley cues should be IMO not buried like {//.
Should be
{
next line of code.

I'll admit I was surprised that Jons code didn't work at first but after discovering the hidden Curlys and taking more time to read the code.
MY BAD
 
BOTH SUGGESTIONS WORK. exactly what I am looking for
I want to integrate different patterns using a FOR NEXT LOOP
Using binary %11111111 makes designing different patterns (used similar with led matrix scrolling letters etc)
THANKS Jon
 
going to experiment driving the TWILITE pins with similar code in a sub route.

You are still missing the point of using the shift registers. Your plan with separate data lines is an unholy mess that you'll never make work, and nobody will help you un-muck it because it's just not going to work. The shift module won't support what you're trying to do, and there's ZERO chance you can come up with an alternative. If people who know how to use shift registers tell you whar you're trying to do, you would be wise to heed their advice. I've been telling you that for 20 years – maybe you should consider it this time since the number of people willing to help you is just about ZERO.

● ONE and ONLY ONE data line with the '595s connected in series.

● ALL CLOCK pins connected together.

● ALL LATCH pins connected together.

● A huge array of bytes, which you can either shift out one byte at a time to move a pattern across the shift registers, or you shift out as many bytes at a time as there are shift registers.

Let's say you have 8 shift registers. Set up 8 bytes with some LEDs illuminated, some not. Shift out those 8 bytes. Call them LEDData(0) to LEDDate(7).

Copy those bytes to LEDDate(8) to LEDData(15). Change just a few bits, say one or two in each byte. Shift this group out 250mS after the first group.

Copy LEDData(0) – (7). Change a few different bits. Send it out 250mS after the last group.

The LEDs that had been off initially that you turned on in the second group and off again in the 3rd will have twinkle. Other LEDs you leave on or off for a number of groups for a different effect.

It will take some effort to set up the data array, but mostly you're just copy&pasting (which you are extremely experienced at) and changing a few bits at a time.

If the above doesn't make sense to you, you have two options:

--> Ask specific questions about what you don't understand.

--> Throw everything in the dumpster.

Getting "creative" and trying to make hardware you DO NOT UNDERSTAND work the way YOU WANT IT TO WORK is just not going to work for you. How many forum pages are there between you last thread and this one, and you've only just gotten the shift register to work????? Maybe it's time you followed thevl advice people give you.

MrDEB – you should be aware you are on my block list and I don't even see the threads you post unless I search them out. I will not to foolish enough to do that in the future. I'm done being a fool.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…