Button/Led matrix & multiplexers

Support for Arduino in combination with Air Manager and Air Player

Moderators: russ, Ralph

Message
Author
User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Button/Led matrix & multiplexers

#1 Post by Keith Baxter »

Hi,

I started this thread for discussion on the above. @Ralph It might be an idea to open a separate channel where different topics can be discussed. This one is both for RPi and Arduino.

Lets start by discussing the best method to drive 70 led's for back-lighting the 737 FMC. I am using a RPi 3b for this project. But I will need similar for all the other panels where arduino is used.

We want to use these Tactile momentary buttons and control the brightness from the sim dataref (value 0.0 -> 1.0)

https://www.aliexpress.com/item/3276259 ... st=ae803_5

What LED driver to use?
I assume PWM output will be used.



Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
jph
Posts: 2857
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Button/Led matrix & multiplexers

#2 Post by jph »

You were talking about button matrix issue before so I will repost this for you. It is an example to show you how to use a matrix of 16 x 16 which you originally wanted as the AM implementation is 8 x 8 limited (which is fine) - so for a custom 16 x 16 matrix using only normal AM functions no message port and only using 20 I/O pins instead of 36 you can use the following.

From the previous thread where you wanted a 16 x 16 matrix and you were not willing to use message port.

My plans for my 'pit' - whenever I get properly around to it (it is Antenna / high power RF Linear amplifier building season at the moment) ;) is to use message-port for absolutely everything !!! and not the basic hardware built in AM functions. That way I have proper control over everything and am never wondering how to implement something specific and absolutely 100% not tied to specific hardware. The ONLY limitation is that the base micro must support the MP sketch. You could run 1000 buttons from a single Arduino if you wanted to. Your comment about people who can use message port not needing AM is absolutely 100% NOT the case. AM is amazing in that it offers that very complex interface between the hardware and the sim. Am is also the only tool to make non hardware instruments.
As for your specific case I do not see the issue for a 16 x 16 matrix if you really must have one. You CAN do it with AM hardware offerings without message port. How fast it would be I don't know, but probably perfectly ok.
I am sure you have also considered that you MUST use a diode for each and every switch in whatever matrix you use - even the basic 8 x 8- even the built in 8x8 as otherwise ghosting would occur and you could not use latching buttons / switches. Hence buttons / switches and 64 diodes.
As said, if you really wanted to you could easily make a 16 x 16 unit WITHOUT MP. a bit of 'appliance of science' 8-)
You need 4 ROW OUTPUTS (not inputs!) and 16 COLUMN INPUTS - with WPU enabled or external pullups.
On the 4 ROW output pins which you set in AM simple digital outputs and the 16 other pins set as digital INPUTS (these are COLUMNS for the matrix 0-15)
Now you simply put a 74154 4:16 exclusive MUX / Decoder - preferably the 74HC154 or 74HCT154. They cost all of 76 cents. This then becomes the ROW Driver (ROW 0-15)
To scan the 16x16 matrix you simply set the row address with the 4 ROW outputs to the 74HCT154 and the corresponding bit (ROW 0-15) will be pulled LOW.
You then read the state of the 16 COLUMN inputs.
Start at ROW 0, Read the COLUMN 16 pins. then ROW1, Read the COLUMN 16 pins, and loop around. Rinse and repeat.
As said, whatever method you use you WILL need a diode on EVERY button or switch.
So get your soldering iron out you old goat :D
Joe. CISSP, MSc.

User avatar
jph
Posts: 2857
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Button/Led matrix & multiplexers

#3 Post by jph »

Who are the 'we' you refer to Keith ? :shock: ;) :D - is it the Royal 'we'

For the leds use 3 x Pi Pico straight from AM as they have 26 fully addressable PWM pins.

Job sorted.
Leave money in tin at the door.

As for number of USB cables ? - you seem to have a phobia about USB cables. Just use some hubs, not an issue at all. Also, this is far far easier without a custom PCB. To me the PCB is pointless but each to their own of course. You can buy project boards for ALL arduinos and pi units. Far far easier. Again, up to you though.

As for doing it via MUX for the LEDs with brightness control - or even their own mux with no brightness from AM ? . Simple answer - FORGET IT . :D
Joe.
Joe. CISSP, MSc.

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Button/Led matrix & multiplexers

#4 Post by Keith Baxter »

@jph ,

This PCB has to be done for all the switches and LED's

The RPi will piggy back onto that board.

The instrument is like a tablet and can be portable so many cables connecting it, is not an option. There needs to be one connector that the instrument connects to.
It would be awesome if WiFi or Bluetooth would work with AM. I did ask @Corjan about 3 years ago. :mrgreen:

This board does not use a RPI so I will redo it.

Well it uses a RPi pico and not for AM.
g34164.png

The screen is ZJ050NA-08C LCD Screen 5 inch 640x480 display panel
And the control board is a PCB800099/VS-TY2662-V1 which is based on the Realtek RTD2662 controller.
Reason is that it is HDMI and easy to use with a RPi licence.



Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
jph
Posts: 2857
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Button/Led matrix & multiplexers

#5 Post by jph »

@Keith Baxter Ah, ok. I see what you are doing with that board. Nice one.
Do you mean a pi Zero 2W ? or a 'normal' pi ?

As for using one connector, again, a hub ONLY if multiple boards as If you are simply dimming ALL the leds then you only need a single PWM to LPF to control a power Mosfet to dim them all together.
You could use the same a single Pico for the button mux with the 4 to 16 line decoder and also for PWM with the Power mosfet for illumination. You will need a a heatsink on the power mosfet as it will be in the non linear region if leds are dimmed.

Looking good !
Let us know how you get on and have fun.
Joe
Last edited by jph on Tue Feb 15, 2022 2:32 pm, edited 2 times in total.
Joe. CISSP, MSc.

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Button/Led matrix & multiplexers

#6 Post by Keith Baxter »

Hi,

This is just the beginning. Next comes the EFB (TABLET) I want to use the Waveshare 10.1" lcd touchscreen. With or without a RPi.


Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Button/Led matrix & multiplexers

#7 Post by Keith Baxter »

jph wrote: Tue Feb 15, 2022 2:21 pm Ah, ok. I see what you are doing with that board. Nice one.
Do you mean a pi Zero 2W ? or a 'normal' pi ?

As for using one connector, again, a hub. If you are simply dimming ALL the leds then you only need a single PWM to LPF to control a power Mosfet to dim them all together.


Let us know how you get on and have fun.
Joe
Hi,

Joe yes, dimming all the led on those tactile switches. They do not light when the button is pressed. Only as back-Lighting for the buttons,so controlled by one dataref for all switch LED's

RPi is a RPi 3b


Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
jph
Posts: 2857
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Button/Led matrix & multiplexers

#8 Post by jph »

In that case Keith then you could (on the pi) use the scheme I listed for the DIY 16x16 Matrix Mux with the 4:16 line decoder, it will be straight forward. It is definitely better to use the 4-16 line decoder for the 'ROW' section of the matrix as it will only use 20 pins on the Pi 3. (and 1 for the output enable of the 4:16) Of course, you can make the Matrix any size you like within reason. You could test the code for response time in AM with only a couple of buttons. Just write the routine to scan, for example, 8x8 but where you control the mux from AM which is then a mini version of what you would be doing for the larger matrix. The only concern I have - and it is probably unfounded, is the update and response of AM as instead of AM waiting for an event, you have to manually instigate the row scan 16 times - one for each row - and note the 16 bit (16 input pin) COLUMN results. That is a single full matrix scan. This needs to occur at regular timed interval - for example, 3 or 4 times a second or you will miss key pushes. I can give you a bit of a flow description of the logic path for the pin read and writes if it would help ? It should be absolutely minimal computing though - it is just the data flow back and forth that will occupy the time and make or break it.
Another Pi 3 pin can also drive the LED illumination.
After a nice cup of tea I kicked myself and thought of a fairly simple solution for the illumination based on direct PWM of a logic level power mosfet as then there will be no need at all for a heatsink as it will be completely out of it's linear region. It is a far better option. I will ponder the best way to implement it and offer some options.
What power supplies do you have going to the board ? (voltages) - it will influence the options for the Mosfet control design. Also, are all the leds the same colour / type ? - I think you said they were all the same switch which would be good.
Joe
Joe. CISSP, MSc.

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Button/Led matrix & multiplexers

#9 Post by Keith Baxter »

Joe,

My exact point. Now I have to be a :ugeek: and resort to sourcing code, library's and a MUX/decoder. Doing experiments etc. When "IF" AM was able to do a 16x16 button array (in this case I only need 9x8) which (as you say a RPi and arduino are capable of) I would not have to go to all that trouble. SUCKS
Surely the SI guys have a better solution. @Ralph as a hardware electronics engineer should have the answers and suggest a practical solution ;)

OK. For completeness, we will continue this discussion should others have a similar application.

In this particular case, I think I can handle all the buttons, led's and ADC input with a RPi and a UNO. I just need to plug the the UNO into the One of the RPi USB so no need for a USB hub.
Now on to driving all those led's with a simple PWM output. What power level mosfet should I be looking at?

Would I need resistors for each LED or set or LED's?
The Voltage and Current for LED: 2.0-3.0V/20mA;

Currently the PSU is 5V 5A
I think I might have to revisit the amperage of the PSU and go for a 20A.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
jph
Posts: 2857
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Button/Led matrix & multiplexers

#10 Post by jph »

Just to clarify Keith
Are you using, or intending to use the PI with an AM hardware image flashed ?
I am think perhaps not from but may not be fully understanding. I seem to think you are using proper Air Manager on the Pi yes ?

I have never used the real PI with AM. Is it actually possible to put Air Manager on the PI AND actually use the I/O of the PI at the same time from within the PI Air Manager program ? - maybe it is ? that would be neat.

Depending on the answer to the above - What I am suggesting with the DIY mux would normally be accomplished by using a standard AM HARDWARE FLASHED image and standard AM commands. - nothing actually 'custom' in the way of programming apart from a few lines of code in AM that control the whole MUX and the MOSFET -absolutely no coding at all needs doing on the Arduino or Pi or whatever - if flashed with the AM hardware image. (but as said, the abilities of FULL AM on the pi I am not sure. If that is still an issue then I have quite a few other options up my sleeve though that don't involve any complex programming etc.

Off out now, but will be around tomorrow.
Have a great evening. You are like a mad professor :D

Oh, try adding this to your PCB design ;) - https://www.ebay.com/itm/114844008567?_ ... BMjNDj7N9f I just bought one from this guy for the latest project. Only 7500 Volts up to 60A . - but I digress.
Joe
Joe. CISSP, MSc.

Post Reply