church that dispenses mini liquor bottles

My sister in law is Irish and German.

She’s a generous soul and we wanted to do something for her. She likes to drink as well.

Someone suggested the façade of a church that dispenses the mini (50ml) liquor bottles. The dispensing part is essentially proven out. I’ve made it twice with materials that are more than in the final build.

Essentially there are 28 little doors that open and the booze slides down to a door where she can get it. I need to trigger solenoids to open the doors.

On the breadboard I’ve build 4 or 5 versions of the (4) 74HC595 circuit. I have had varied success. When working with just one IC and 8 LEDs, things are fine. After that it gets interesting for me. Anyway, I don’t think I’ll need help building the circuit.

The circuit is, of course where my problem lies. I just need to ensure lots of 0s sit on those pins until it’s time to drop a bottle. This happens once a day at 5:00PM EST, as it stands now. I’ve ordered one of those little clocks to keep the system close to actual time. We think she will get a kick out of it because so like to be precise. The ordering couldn’t be easier. I’ll be just working from solenoid number one forward until is reached. Well, I think it’s 26 days this year.

The leads from the 595s will trigger a 5V relay, which will allow the higher voltage to for a moment while the solenoid is active.

We may have to unlock the front door be we can add that in the future perhaps. There was talk of a recording of bells.

I also want to learn so as you move through the process please as notes in the code that can help me better understand.

What are your thoughts?

Tony Perry
tperry724@gmail.com

I’m thinking you probably want a heftier driver than a 74HC595 to sink current from relays.
(and not drive a High into relays to energize them)
I’d suggest TPIC6B595, which can sink 150mA from up to 50V.
Don’t forget a diode rated for the coil’s voltage and current back across each coil as well (anode to coil ‘+’, anode to the coil ‘-’/TPIC output).
Shift in a 1, the corresponding output goes low to energize the coil until a 0 is shifted in turn off the output and de-energize the coil.

The church of booze? I know the the church of the spagetti monster, but ...

The draw of the little solenoids are approx. 8 volts to trigger with 1.1 to 1.2 amps needed. I need only trip one at time, once a day. I had already purchased some logic level relay banks (QTY 4, of 8 banks eack) and I'd be dropping in 12 volts on the other side to ensure a snappy operation from the door "locks."

CrossRoads - I am but a neophite. A pleeb. You obviously have a tremedous amount of experience, and intellect, and I'm happy to receive what you'd be happy to share but ya gotta slow down for me a bit.

What do you think is fair for first helping me get the code in order to trip the solenoids? Again, I think a for loop could be used but I struggle how to send out the data required to have them trip one at a time. I don't have to work on the "once a day" think yet. I can wait until the part comes in and take a stab at it myself. I like to learn but it does take a while with some subjects.

Thank you for the consideration.

Best,

Tony



zwieblum:
The church of booze? I know the the church of the spagetti monster, but …

But that is not The One True Church of His Noodliness, The Flying Spaghetti Monster

I’ve been caught up in the grip of the pasta night a few times. My great aunt and grandma would always try to feed us before hand.

Folks,

Not looking for something for nothing.

I don't think this is a difficult project.

Let me know asap. please.

Best,

Tony

Those relay modules usually need Power, Gnd, and a Low level is needed on the IO pin to energize the relay.

I don't know that the 74HC595 can sink enough current to turn on the LED in the optocoupler. TPIC6C595 definitely can.

If you go with a shift register, either kind of '595, than you could have a byte variable represent 8 relay outputs (4 shift registers for up to 32 relays).
When an output needs to change, you change a bit in a variable, and send the 4 bytes out, assuming the shift registers are daisychained.

digitalWrite (latchPin, LOW);
SPI.transfer (byte0);
SPI.transfer (byte1);
SPI.transfer (byte2);
SPI.transfer (byte3);
digitalWrite (latchPin, HIGH); // outputs update on this rising edge

Say bit 2 of byte 1 was on, and bit 3 now needs to change, and all others were off.
So byte0 = 0b11111111
byte1 = 0b11111101
byte2 = 0b11111111
and byte3 = 0b11111111

So change byte 1 to 0b11110111, and send them all out as above.

I'm getting the TPIC6C595.

I should have said I'm getting 8 of them. Just in case I trample one, or two.

The TPIC6C595s should be here tomorrow. Can't wait. I know I have a few miles to walk but I'm excited about the journey. Can someone direct me to some basic code to get them chatting with some LEDs (32 of them) For the 74HC595's there were a lot of sketches to get started with to learn, not as much with the TPICs. I was so excited, I even have the breadboard all laid out, waiting for the chips.

I'm even taking two Udemy online classes/courses right now. One for Arduino and some programming. The other is almost all programing with some coverage of C.

There will be parts of I will not be able to climb due to the steep learning curve and the lofty height I'd have to achieve.

I will need help. I would like to have someone to go to and a rate worked out just in case.

AArg, gave me some homework. An article to read about shift registers. It was helpful. I built the 2 shift reg, 16 LED circuit.

I think I have two states when I wire the data line from SER to SER. Or from SER to QH. If from SER to SER, the second chip just emulates the first it seems.

If SER to QH, I really get odd responses from the circuit. I’m truly struggling to get this SPI protocol (right word?) under control.

THE TPIC chips did not come yesterday. Hopefully today.

Best,

Tony

TPIC chips are in! Trying to get things up and running. The pinouts are different and harder to make sense of compares to the 74HCs.

A question about your code from above which I will paste below.

int latchPin = 11;
int clockPin = 9;
int dataPin = 12;


byte0 = 0B11111111  // i added because they are teaching the use of variables
byte1 = 0B11111101  //*
byte2 = 0B11111111  //*
byte3 = 0B11111111  //*

digitalWrite (latchPin, LOW);
SPI.transfer (byte0);
SPI.transfer (byte1);
SPI.transfer (byte2);
SPI.transfer (byte3);
digitalWrite (latchPin, HIGH); // outputs update on this rising edge

//Say bit 2 of byte 1 was on, and bit 3 now needs to change, and all others were off.
//So byte0 = 0b11111111
//byte1 = 0b11111101
//byte2 = 0b11111111
//and byte3 = 0b11111111
//So change byte 1 to 0b11110111, and send them all out as above.


void setup() {
  
  }

I've been trying to learn use of variables but byte0, is unwelcome by the IDE for some reason. Any guidance? The end game is still the same, use the TPIC6C595s to send one pin high each day to drop a bottle of mini liquor.

I'm taking another Udemy course on C++. That makes three. Just trying to get a good base under me.

tperry724:

byte0 = 0B11111111  // i added because they are teaching the use of variables

I've been trying to learn use of variables but byte0, is unwelcome by the IDE for some reason. Any guidance?

You're missing a type, eg. byte, or, if the variables have been declared before, you need to put those assignments (and the digitalWrite/SPI stuff as well) inside of a function, eg. setup().

You’re missing semicolons too.
Either use “0b” prefix, or “B”, but I’m not sure “0B” is valid.

I'm in over my head. Anyone interested? Please send me a PM with a $/Hr charge. And after I give you a quick run down, I'd like to get a rough estimate.

What's your code like so far?

With the TPIC6B595, or 6C595, you send out

0b0000000 = all off
0b0000001 = 1 on
0b0000010 = a different one on
0b0000100 = yet another one on

So what you can do is create an array of data to send to the shift registers.
Say you have 4 of them for up to 32 bottles, or 28 bottles and 4 other things, maybe a door, or a little push bar or something.
I would make an array of 33 unsigned longs, with all 0s = none one, and the rest just one.
I'll do it in hex to keep it shorter:

unsigned long bottlePickArray [] = {
0x00000000, // none on
0x00000001, // #1 on
0x00000002, // #2 on
0x00000004, // #3 on
0x00000008, // #4 on
0x00000010, // #5 on
0x00000020, // #6 on
0x00000040, // #7 on
0x00000080, // #8 on
//etc up to
0x400000000, // #31 on
0x800000000, // #32 on
};

Then you have a counter that keeps track of where you are
byte counter = 1; // first bottle

To turn off a relay:
digitalWrite (ssPin, LOW);
// break the unsigned long into bytes
byte0 = bottlePickArray[counter] & 0x000000FF; // should give 8 lower bits
byte1 = (bottlePickArray[counter>> 8) & 0x000000FF; // bits 9-16
byte2 =  (bottlePickArray[counter>> 16) & 0x000000FF; // bits 17-24
byte3 =  (bottlePickArray[counter>> 24) & 0x000000FF; // bits 25-32
SPI.transfer (byte0);
SPI.transfer (byte1);
SPI.transfer (byte2);
SPI.transfer (byte3);
digitalWrite (ssPin, HIGH); // outputs update on this rising edge


So turn on one for some amount of time, then send out all 0s to turn it off.

Then all you need to do is keep track of where you are with counter.
Maybe store it in EEPROM in case you lose power.
Add an RTC to the system to keep track of the day as well.

(I'd also make the array bytes, and count by 4, so instead of all the shifting & masking, your index into the array would be counter, counter+1, counter+2, counter+3
Then counter = counter+4; // jump to the next group of 4
Start the array with
0x00, 0x00, 0x00, 0x00, // all clear
0x00, 0x00, 0x00, 0x01, // bottle 1
0x00, 0x00, 0x00, 0x02, // bottle 2
:
:
0x40, 0x00, 0x00, 0x00 // bottle 31
0x80, 0x00, 0x00, 0x00, // bottle 32

Or you could manipulate a 1 into the right location based on the counter you have stored in EEPROM.
I'd just go with the 128 bytes stored in memory, skip all the shifting and manipulating.

Attached is my new circuit with the TPIC6C595s. Can't get a thing out of it. I've nearly totally rebuilt it and still nothing. My Uno is working because I tried it on a different sketch. Does anyone see anything obvious?

tperry724:
Attached is my new circuit with the TPIC6C595s. Can't get a thing out of it. I've nearly totally rebuilt it and still nothing. My Uno is working because I tried it on a different sketch. Does anyone see anything obvious?

Well, since you asked for obvious, a casual look suggests that you might have connected the GND pin of the bottom right IC to the +ve voltage rail in the middle power rail channel. That would be bad.

And in the IC above that one, the CLR pin hasn't been connected.

I would recommend getting one IC working, then two, then 3, 4.

Breadboard with the TPIC6C595s. Not a peep of them. Not one lit led. Is there something obvious that I've done wrong?