Relay module 74HC595 Q0 sometimes on

Go To Last Post
29 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello everyone,

 

I soldered a few modules for interfacing with some switches, LEDs and relays.

My problem now is a relay module with 8 relays controlled by one 74HC595 which should be used as a looper for guitar pedals.

When I switch on my box (atmega8, switch module, relay module) there is a loud click like all the relays are active at once but none of the attached status LEDs are active.

The code is not loaded at the time the click is noticable at the same second the power is attached.

Using the code to activate the relays seems to be ok, I can here the clicks, I can see the LEDs light up as desired. This seems to be no coding issue.

 

When I remove the board and connect only VCC and GND there is most of the time no click. Sometimes Q0 is high which means the first relay is active but not the attached status LED.

When Q0 is not high after VCC is attached I can put 5V to Q0 and the relay is active. Q1-Q7 same thing also the LEDs. Everything as desired.

 

I checked everything with the continuity tester and it seems to be fine.

At first I thought that maybe the trace for Q0 from the IC to the relay is somewhere touching the VCC trace but it's not.

Can someone give me a hint about whats wrong here?

 

There was no ULN around so I used BC337 and because I had no high power shift register I chose low power LEDs with the M74HC595B1.

I soldered on perf board and it may not be the cleanest build around.

 

Relay: FRT5 DC 5V single side stable

https://www.schukat.com/schukat%...$file/FRT5.pdf

 

Attachment(s): 

This topic has a solution.
Last Edited: Sat. May 16, 2020 - 08:18 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Pin 10 is the CLEAR pin that should be connected to a slow rising circuit or driven by a pin to keep the chip reset during power up. (100ms??)

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yep, clears/resets and such should in general either be managed by an external signal (i.e. program code) or, as John says, an on board delay. It depends if you have to have things work 'stand-alone'. Very few simple logic chips have power-on resets.

 

Neil

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Interesting solder art. Nice to see you put a bypass cap across the hc595. You probably want a 100uF electrolytic to keep the power rail good when all the relays turn on.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
Interesting solder art.
Youtube's "GreatScott!" (  https://www.youtube.com/channel/... ) uses this all the time. Maybe the OP is a devotee.

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you guys, I will try the capacitor/resistor/diode to reset suggestion. Like the pic in the attachment?

The art of perf was inspired by this guys https://www.diystompboxes.com/smfforum/index.php?topic=96544.0
Then I realized that I wanted to use my old wiring pencil that I have never used. I failed and switched to the expensive time consuming soldering technique. And boy this board is heavy.
I could have etched a few boards during this time.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lucky you didn't etch a pcb - your pcb design is far from optimal. Understand that a pcb track has a finite resistance - your power tracks are too thin and the voltage drops will cause problems. Consider where the current will flow and size the tracks and layout appropriately.

 

Your schematics are less than optimal. That translates to near unreadable. Draw your transistors with the emitter pointing down. There's a number of conventions to follow when drawing schematics - these make the difference between a schematic that connects stuff together or whether the schematic makes sense to most readers.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


With only VCC and GND attached it works. The relays are quiet during power up. Let's put it back in the box on monday.

Kartman: thanks for the info regarding the trace width and the schematic. I'm a hobbyist trying to learn. I was happy to get a layout I can easily solder by my own with my own hands. But that's not an excuse for poor design.

The 100nf across the IC was meant to be a decoupling capacitor not as juice repository :-)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

   I recommend that you go back to the very beginning of the design.   Because the signal is low-level audio, there is no need to have all the relays-and-transistors for this application.   Relays are for high-current/high-voltage designs. 

   For a guitar FX multiplexer/switcher like this, it would be better to do all the switching with 74HCT4053 analog-signal switchers.   Each 74HCT4053 has three electronic switches configured as 1-in_1-of-2-out, which is precisely what the relays are doing.  Your guitar signal is about 1-2 volts peak-to-peak AC.  Use a resistor pair and capacitor to bias this input AC signal at roughly 1/2 Vcc and feed it into the 74HCT4053s.   The 4053s can be switched directly from the AVR ports, so you don't need all the transistors and relays.   And 4053s are cheap: less than a dollar per IC.

   If you're using an 8 or 14 pin AVR, then I would suggest using an Arduino Nano clone instead because you now have 12 I/O pins to use and the 595 isn't needed.   If that's not an option, then check the 595 datasheet to see if the G input can be used to hold the 595 outputs in tri-state on power-up.  All the relays are coming on at power-up because the 595 outputs are sourcing current to the transistors when the G pin is grounded, which activates the 595 outputs.

   Also, see if you can switch off all the labels of the parts that are displayed on the schematic.  They are making the schematic impossible to read.  I did a crude overdraw on the schematic just to see what was going on.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


You are missing a main power supply cap (like 330uF)) for all of your relays!

 

The schematic would be GREATLY cleaned up by using the VCC  (up arrow) & GND (down arrow) symbols.   Then your actual signal connections will stand out with more prominence .

The transistor section is upside down:

  transistor

  relay

  pos/gnd supply

 

Since the transistor is switching to gnd, it should be at the bottom of the stack up (the HC595 does not need to be at the top of the drawing, it can be at same level as transistors)

like this:

 positive supply

 relay

 transistor 

 gnd 

....you want to flow down towards gnd

 

what are these traces going nowhere...are they dumping into a poured plane the you don't show (show it)

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. May 16, 2020 - 05:44 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wow so much input. Thank you guys.

avrcandies: the red trace is supposed to be just a jumper wire (bridge? or whatever is the right term).
Still learning how to use Eagle.

The beauty about this 595 is the cascading of mutliple relay boards or in my case multiple switch boards, led boards and relay boards and one single atmega.
That was my plan. That’s the reason for the second pin header. But I don‘t have a second example of every board. To hook up two of these looper boxes to get a looper for 16 devices instead of 8.

Last Edited: Sat. May 16, 2020 - 08:18 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


 

 

avrcandies: the red trace is supposed to be just a jumper wire (bridge? or whatever is the right term).

Yo --only one end of the red trace seems to be going anywhere, shouldn't each end have a via? Why do you have it go to a dead end?   That is rude to the electrons.   The only alternative is maybe it dumps into a not-shown plane pour.

There are several of these---so you intend it?

 

You should thicken of your gnd and V+ traces---they are arteries, not capillaries

 

 

    component pins go to wires...not other component pins or wiring junction connection dots   

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. May 16, 2020 - 11:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta wrote:

Because the signal is low-level audio, there is no need to have all the relays-and-transistors for this application.   Relays are for high-current/high-voltage designs. 

   For a guitar FX multiplexer/switcher like this, it would be better to do all the switching with 74HCT4053 analog-signal switchers.   Each 74HCT4053 has three electronic switches configured as 1-in_1-of-2-out, which is precisely what the relays are doing.

 

Yes, and no.

 

I do a lot of repairs on guitar amps and FX pedals and the like for a local reseller, and relays are still used in many FX pedals today.  Besides, the 4053 SUCKS for audio( I know this first hand).  YES, you can use solid state switches, but before doing so read the datasheets on them first.  they aren't the end all solution for everything.

 

Kartman wrote:
Lucky you didn't etch a pcb - your pcb design is far from optimal. Understand that a pcb track has a finite resistance - your power tracks are too thin and the voltage drops will cause problems. Consider where the current will flow and size the tracks and layout appropriately.

Agreed, but Unless those relays are sucking hundreds of milliamps the OP probably could get away with it.

 

Kartman wrote:
Your schematics are less than optimal. That translates to near unreadable.

REALLY!?

Considering the CRAP we normally get around here the OP's schematic is quite clear.  Then again, I am not picky.

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


The other "minor" thing about relays that carry audio or very small current is to use gold contacts.

 

I use the Axiom W11 type relay on a board that is designed for control of air conditioner, blinds etc. that carry only a few mA.

 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You want more than eight fuzz boxes on your guitar?  Talk about wall of sound!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

very small current is to use gold contacts.

An excellent point !!  You can see the same thing happen with press (non-wiping) panel switches.  A way around that is to add a resistor to give a heavier load to the switch, or possibly a cap to create a little surge.   These keep the oxide/tarnish from building (enough of a zap to burn off initial buildups).  Of course that won't do for the audio sys. Gold is more immune to deterioration & should be used.

 

Some quality panel switch catalogs actually spec minimum currents for their switches! 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

tuckito wrote:

   

 

Aha, I think I know what you're doing: using Eagle to layout on strip board, or on perfboard with regular tracks on the bottom (thinks back to earlier photos...)

 

In this case, you have RED front copper - a wire link, because you don't *have* any front copper - connecting to the blue back copper where it terminates, right?

 

Eagle doesn't really offer a way to terminate a line at a new signal with a via, which is what you want (you still have an air wire going to the terminating node to the right). I have found the best way to do this is to:

 

- start with the air wire from the last via (so here, you'd unroute that vertical red link) and drop it to the place where it currently ends

- change layer so you get the via and you're tracking the back layer

- end the line at any point on the blue trace - that will leave a via where you want it and Eagle will eat the air wire for you.

 

That said - I used Eagle for many years (including professionally; one of our products was laid out using Eagle 4(!) and I'm the only person there that knows how to change it!) but I would not recommend its use these days. That's largely because of the new licencing fees - at least my version 6 licence-for-life still seems to be valid, and version 6 code is available from Autodesk, if you look hard - but I don't like the prices for later versions; I don't like renting software; and I don't like software that phones home.

 

I'm now using Kicad and while the learning curve is just as steep as for any other schematic capture/layout program, it's no worse - and it's an FOSS program so there it's likely to remain at it's current low low (i.e. free) price.

 

Neil

Last Edited: Sun. May 17, 2020 - 06:51 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You want more than eight fuzz boxes on your guitar?

That's an air conditioner remote control for a highish rise building.wink The air conditioners are a bit old and don't have Ethernet or other remote control so this was a retrofit for the building manager, he can use an iPad or other wi-fi device to connect  to a box that will eventually send RS232 strings to the relay controller.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Aha, I think I know what you're doing: using Eagle to layout on strip board, or on perfboard with regular tracks on the bottom (thinks back to earlier photos...)

ahhh...Perhaps that is it...so this is not to create a PCB version of the hand-made proto?  That makes sense, if no quantity is being built.   

However, this is not clearly mentioned anywhere, even when we asked questions about PCB layout, such as increasing trace width. 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sun. May 17, 2020 - 07:39 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes it is like that exactly for the perf board.
I thougth that is obvious by looking at the pictures :-)

And you an never have too many drive pedals or fuzz pedals or....

I use eagle 7 free.

Last Edited: Sun. May 17, 2020 - 08:25 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I thougth that is obvious by looking at the pictures :-)

No, since a prototype is often built & worked on to finalize & check the design before the PCB is laid out.  Nowadays, especially with SMT & fast turn low cost boards, the proto stage is done using PCBs.

That soldering is def an interesting maker method!

you may enjoy these pictures

   http://elm-chan.org/docs/wire/rc/wcs.jpeg

 

http://elm-chan.org/docs/wire/wiring_e.html

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

With everything boxed up it's still switching on...

Only VCC and GND -> no switching on.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm getting closer:

 

According to my config.h and the functions in main.c it should be active high like it works for my LED module with a 595.

 

// 74hc595 RELAY
#define SER_REL_DDR         DDRC
#define SER_REL_PORT        PORTC
#define SER_REL_PIN         3
#define RCLK_REL_DDR        DDRC
#define RCLK_REL_PORT       PORTC
#define RCLK_REL_PIN        5
#define SRCLK_REL_DDR       DDRC
#define SRCLK_REL_PORT      PORTC
#define SRCLK_REL_PIN       4
#define SER_REL_low()       SER_REL_PORT    &= ~(1<<SER_REL_PIN)
#define SER_REL_high()      SER_REL_PORT    |= (1<<SER_REL_PIN)
#define RCLK_REL_low()      RCLK_REL_PORT   &= ~(1<<RCLK_REL_PIN)
#define RCLK_REL_high()     RCLK_REL_PORT   |= (1<<RCLK_REL_PIN)
#define SRCLK_REL_low()     SRCLK_REL_PORT  &= ~(1<<SRCLK_REL_PIN)
#define SRCLK_REL_high()    SRCLK_REL_PORT  |= (1<<SRCLK_REL_PIN)

Initialization of "relay" with every relay set to 0

uint16_t relay = 0b0000000000000000;

I use these two functions to set the bits in "relay" (uint16_T to be able to use two relay boards somtime in the future)

void relayOn(uint16_t value){
    relay |= (1<<value);
}

void relayOff(uint16_t value){
    relay &= ~(1<<value);
}

And shift them in

void setRelay(uint16_t value){
    SRCLK_REL_low();                                			// set the serial clock pin low
    RCLK_REL_low();                                 			// set the register clock pin low
    int8_t i;

    for (i=15;i>=0;i--){                       				// start with 15 to shift the msb from value into the register first
        if((_BV(i) & value) == _BV(i)){     				// check bit on position i in value; (bit_set() only for 8 bit register)
            SER_REL_low();                          			// set bit equal to bit in position i either low
        }else{                                  			// or
            SER_REL_high();                         			// high
        }
        SRCLK_REL_high();
        SRCLK_REL_low();
   }
   RCLK_REL_high();
}

 

When I set relay to all active on startup the relays are all inactive on startup, no clicking.

When I rename relayOn() to relayOff() and vice versa the relays turn on, when I want them to... So it's active low. But why?

I got confused with the LEDs because as smart as I am I connected all the GND legs of the LEDs to GND.

What also confuses me is that when I put a wire with VCC to Q the relays turn on so the layout is active high isn't it?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

it should be active high like it works for my LED module with a 595.

What is it?  

LED module?---what are you talking about?  this board?

 

I connected all the GND legs of the LEDs to GND.

Why?  Didn't you follow your schematic?  If not, what else didn't you follow?  Where is your large cap for the relay power? 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Mon. May 18, 2020 - 07:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes lots of whining no input.
The LED module is a 595 with 8 LED simple setup not as messed up as my relay module.
Same code, shift in a few bits and light up the LEDs.
What got me confused is the fact that I have to shift in all 1s into the 595 of the relay module to not activate the relays on startup but then I need 5v on Q to activate the relays.

avrcandies wrote:
Why?  Didn't you follow your schematic?  If not, what else didn't you follow?
That sentence was a monolog. I know that was stupid but yes you are right about this, how should anyone know if I did some other smart stunts.
avrcandies wrote:
Where is your large cap for the relay power?

I did not update the layout after the suggestions in this thread.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I hope you didn't use 4.7K to drive your relay transistors...that is extremely weak...you need more like 1k, or maybe even 750 ohms.  Make sure thing are on solidly, not barely by a thread.  If the relay coils are picopower, that might be ok.

 

What got me confused is the fact that I have to shift in all 1s into the 595 of the relay module to not activate the relays on startup but then I need 5v on Q to activate the relays.

What are you talking about?  Your driver turns on a relay when the 595 output is high, correct? Why not load them with zeros?....the output must be set to something, they must not be allowed to power up randomly with some hi & some low.

 

is the fact that I have to shift in all 1s into the 595 of the relay module to not activate the relays

I doubt that is a fact, unless you miswired everything.   Schematic shows the output must be HI to turn on a relay.

 

Fix your schematic to make it easier to follow & less confusion

 

in this order top to bottom:

V+      ...use the v+ symbol

RELAY

TRANSISTOR

GND   ...Use the gnd symbol!

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Mon. May 18, 2020 - 08:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's fixed. A symbol was missing. value should be ~value...

 

void setRelay(uint16_t value){
    SRCLK_REL_low();                                			// set the serial clock pin low
    RCLK_REL_low();                                 			// set the register clock pin low
    int8_t i;

    for (i=15;i>=0;i--){                       				// start with 15 to shift the msb from value into the register first
        if((_BV(i) & value) == _BV(i)){     				// check bit on position i in value; (bit_set() only for 8 bit register)
            SER_REL_low();                          			// set bit equal to bit in position i either low
        }else{                                  			// or
            SER_REL_high();                         			// high
        }
        SRCLK_REL_high();
        SRCLK_REL_low();
   }
   RCLK_REL_high();
}

I don't know how this happened, maybe yesterday when I "tried" to fix it while babysitting...

indecision

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
 if((_BV(i) & value) == _BV(i)){  

When you AND a value with only one bit, the result is either 0 or non-zero. Why ==  _BV(i)?

Also note that doing _BV(i) is a fairly expensive operation on an AVR. Less expensive is

if (value & 0x8000)

{

// '1' bit

}

else

{

// '0' bit

}

value <<1;

 

Also, why are you inverting the bits? You want a logic '1' to turn on the transistor.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, I see. I wrote this years ago when I first got in touch with bit operations. Back then the _BV etc made sense to me. I forgot everything.

void setRelay(uint16_t value){
    SRCLK_REL_low();
    RCLK_REL_low();
    int8_t i;
    for (i=0;i<=15;i++){
        if (value & 0x8000){
            SER_REL_high();
        }else{
            SER_REL_low();
        }
        value<<=1;
        SRCLK_REL_high();
        SRCLK_REL_low();
    }
    RCLK_REL_high();
}

Works.

Last Edited: Tue. May 19, 2020 - 03:04 PM