Go Down

Topic: Use Arduino Uno as multiplexer latched output (Read 1 time) previous topic - next topic

Andy2778

Hi all, I am new to Arduino.
And I wish to use Arduino to carry out 4 to 16 MUX with latched function.
My objective is to ON/OFF some valve with relay which all the control need to ON/OFF independently. 
May I know can this be done?
Sorry I am totally new to Arduino and my condition is not allow to use mux and latched IC.
I need a finished product for my applicaiton
Or is there any suggestion? 

Grumpy_Mike

Quote
and my condition is not allow to use mux and latched IC.
What! You have some medical problem that prevents you from using certain components?

Quote
My objective is to ON/OFF some valve with relay which all the control need to ON/OFF independently.
So what has multiplexing got to do with this?

Just connect an output to each of the pins you want to control and turn them on and off. Then use a FET to turn on your valves for the output pin signal.

Andy2778

What! You have some medical problem that prevents you from using certain components?
So what has multiplexing got to do with this?

Just connect an output to each of the pins you want to control and turn them on and off. Then use a FET to turn on your valves for the output pin signal.
Nope, just that my boss don't want us to design any PCB. He prefer using finished products like Arduino and I can't find any module for 8 bit latched in my area.

My output is controlling relay. My main microcontroller has limited output. So, plan to add Arduino to serve as a 4 to 15 multiplexer with latched function.

In terms of coding, do you think switch case is good for my application?

Wawa


Andy2778

http://xyproblem.info/
What you want me to attempt?

Can't you see that I am asking is there any other suggestion?!
I am still considering other solution for my problem. I have considered of using 8 bit latched IC but my condition is not allowed to do so. That is why i need advice whether Arduino is suitable for my application or not.

Wawa

I seems you want to control some valves ? (type, voltage, current) ?
With a microcontroller with limited outputs ? (is it already used for other things) ?
You have already decided you need relays for that ?

Why do you think a multiplexer is the answer.
Time division muxing is ok for LEDs (persistence of vision), but not for relays.
A shift register could be a better solution (depending on the rest of the hardware).
Post links to the valves.
Leo..






PaulRB

#6
Nov 08, 2017, 07:53 am Last Edit: Nov 08, 2017, 08:08 am by PaulRB
Quote
carry out 4 to 16 MUX
I think the OP meant to say demultiplexer.

Yes, is possible with an Uno. No, I don't think a switch case would be suitable.

I would suggest holding the 16 output pin numbers in an array. Also hold the 4 input pin numbers in a second array. Read the 4 input pins and turn those readings into a number between 0 and 15 using bitWrite(). This number can then be used to look up the output pin number from the array.

Grumpy_Mike

Nope, just that my boss don't want us to design any PCB. He prefer using finished products like Arduino
Who said anything about designing a PCB?

Without real information we can only offer you so much advice. Stupid artificial constraints don't go down well here.

Quote
and I can't find any module for 8 bit latched in my area.
You don't have any post where you live?

Andy2778

I seems you want to control some valves ? (type, voltage, current) ?
With a microcontroller with limited outputs ? (is it already used for other things) ?
You have already decided you need relays for that ?

Why do you think a multiplexer is the answer.
Time division muxing is ok for LEDs (persistence of vision), but not for relays.
A shift register could be a better solution (depending on the rest of the hardware).
Post links to the valves.
Leo..

Yes. limit output.
I am just saying that multiplexer is one of the solution that I am considering. It should be demultiplexer according to PaulRB which I made a mistake here.
If I am not wrong, shift register is shift the output state across the output pin which I don't think suitable for my case because I need to switch on the relay individually. Correct me if I am wrong.



I think the OP meant to say demultiplexer.

Yes, is possible with an Uno. No, I don't think a switch case would be suitable.

I would suggest holding the 16 output pin numbers in an array. Also hold the 4 input pin numbers in a second array. Read the 4 input pins and turn those readings into a number between 0 and 15 using bitWrite(). This number can then be used to look up the output pin number from the array.
I see. Alright, thank you very much for your advice.
If i using the bitWrite function, the output will hold until i set it to OFF?
or i need delay and interrupt timer functiona also?

Who said anything about designing a PCB?

Without real information we can only offer you so much advice. Stupid artificial constraints don't go down well here.
You don't have any post where you live?
Because my boss dont want to spend much time on PCB design problems, like deal will supplier, trial and error.
Sorry that i cant provide much detail because now is still in design concept stage. If we know that Arduino isn't a good choice then we might change to other solution. That is why I am asking in this forum here because I don't know much about Arduino.
Basically we just need a device that can control multiple output individually with latch function, it must be low cost and finished products, like Arduino which we can buy and use it immediately.
Nope, just that i cant found any 8 bit latched module in the market of my country.

Wawa

If I am not wrong, shift register is shift the output state across the output pin which I don't think suitable for my case because I need to switch on the relay individually. Correct me if I am wrong.
You're wrong.
This is basically how a shift register works:

1) micro shifts a byte in a shift register, or a string of bytes into a string of shift resisters.
Every bit of the byte(s) represents a shift register output.

2) micro generates a latch pulse, and the data/byte is moved to the outputs of the shift registers (and stays there).

3) micro is not needed anymore, until a different relay pattern is needed.

Basically we just need a device that can control multiple output individually with latch function, it must be low cost and finished products, like Arduino which we can buy and use it immediately.
A common Arduino (Uno, Nano) has enough I/O to control two common/cheap 8-channel relay boards.
An Arduino output pin does not change it's state until you tell it to.
Leo..

PaulRB

#10
Nov 10, 2017, 07:49 am Last Edit: Nov 10, 2017, 07:50 am by PaulRB
Quote
If i using the bitWrite function, the output will hold until i set it to OFF?
or i need delay and interrupt timer functiona also?
You would not be using bitWrite function to change an output, you would be using it to turn the 4 inputs into a number between 0 and 15. The next part of the code would then switch on or off an output based on that number. Yes, as mentioned above, outputs do not change until the code changes them again, or the Arduino is reset or power is disconnected. You will not need timer or interrupt functions, unless there is some requirement you have not told us about yet. But the coding details are not important now. You should focus on the circuit design.

Do you have enough pins on the Uno? 16 outputs, 4 address inputs, plus, I assume, a data input and a latch/enable input. That's 22 in total. Does an Uno have enough?

Grumpy_Mike

#11
Nov 10, 2017, 10:57 am Last Edit: Nov 10, 2017, 10:59 am by Grumpy_Mike
Quote
just that i cant found any 8 bit latched module in the market of my country
Then you are stuffed as you don't seem to want to make anything with components. For this simple problem no other system is better than the Arduino.

If you can't find a relay board how on Earth are you going to find something much more scares with a built in relay. I still don't understand what is wrong with buying one from another country and having it delivered to you.

By latched do you mean a relay that retains its state when the power is removed?

dougp

Hi all, I am new to Arduino.
And I wish to use Arduino to carry out 4 to 16 MUX with latched function.
My objective is to ON/OFF some valve with relay which all the control need to ON/OFF independently.  
Sounds to me like an addressable latch.

Andy2778

You're wrong.
This is basically how a shift register works:

1) micro shifts a byte in a shift register, or a string of bytes into a string of shift resisters.
Every bit of the byte(s) represents a shift register output.

2) micro generates a latch pulse, and the data/byte is moved to the outputs of the shift registers (and stays there).

3) micro is not needed anymore, until a different relay pattern is needed.
A common Arduino (Uno, Nano) has enough I/O to control two common/cheap 8-channel relay boards.
An Arduino output pin does not change it's state until you tell it to.
Leo..
Ok. But my system is trigger relay independantly.
So, if everytime i switch the output condition, is it I need to set for other output as well?
For example now I only trigger GPIO1, then i need to set the GPIO = 0000 0001 (binary).


You would not be using bitWrite function to change an output, you would be using it to turn the 4 inputs into a number between 0 and 15. The next part of the code would then switch on or off an output based on that number. Yes, as mentioned above, outputs do not change until the code changes them again, or the Arduino is reset or power is disconnected. You will not need timer or interrupt functions, unless there is some requirement you have not told us about yet. But the coding details are not important now. You should focus on the circuit design.

Do you have enough pins on the Uno? 16 outputs, 4 address inputs, plus, I assume, a data input and a latch/enable input. That's 22 in total. Does an Uno have enough?
Actually my microcontroller have around 20 outputs, for our design actually we just want to expand it.
So, in this case as long as Arduino can provie around 12 to 15 is consider ok.
I did check Arduino IO Pin before, total have 19pin including analog.
Thanks for reminding.
And can you explain the data input and latch/enable input funtion in this case?
Sorry that i am still trying to get the concept of the code.

Then you are stuffed as you don't seem to want to make anything with components. For this simple problem no other system is better than the Arduino.

If you can't find a relay board how on Earth are you going to find something much more scares with a built in relay. I still don't understand what is wrong with buying one from another country and having it delivered to you.

By latched do you mean a relay that retains its state when the power is removed?
Hi, no, what I mean is that we do not prefer customize a board because we do not want to spend much time on trial and error.
And cost is what we are concerning as well.
Actually my latch means like, when first start, everything is off, then I trigger output, it becomes ON, trigger second time then it set to OFF, something like this.

Andy2778

Sounds to me like an addressable latch.
yes. that's the function that I want.
But now my situation is that we do not want to custom make any PCB. ( I can't found any addressable latch module in the market.
So we are planning to use Arduino to carry out addressable latch function.
But I am unfamiliar with Arduino so I need advice here or there is other better option.

Go Up