Rotary encoders and other with Raspberry Pi and Arduino Mega

Are you building a cockpit, planning to build one or just dreaming, this is your cockpit builder meeting point

Moderators: russ, Ralph

Message
Author
Detlef
Posts: 303
Joined: Mon Nov 16, 2020 9:43 am
Location: Bavaria

Rotary encoders and other with Raspberry Pi and Arduino Mega

#1 Post by Detlef »

Hi all,

attached is a sketch of what I want to add to my cockpit. It's three panels with dual rotary encoder,s single rotary encoders, LEDs, switches and buttons.
I need 24 inputs for rotary encoders, assuming I need 2 inputs for a single one, and 4 inputs per dual rotary encoder.
And the rest adds up to 71 digital IOs.

So in total that is 95 which by chance is also the total number of free IO pins when using one Raspberry Pico and one Arduino Mega :)
I figure the Rpi has 26 free IO pins, and the Arduino Mega has 69 free IO pins. Right?

Since the Rpi is a lot faster I thought, I flash it with standard software available with Airmanager and connect all rotaries and in addition two buttons.
I also flash the Arduino Mega with the standard SW and connect 69 buttons/switches/LEDs total.

Will that work or have I overlooked something?

(For explanation: the dark blue circular buttons on the last panel shall move the camera left, right, top, down, in, out.)

Thank you for your help
Detlef

I
Slot-3-4-5.pdf
(55.87 KiB) Downloaded 227 times

Tetrachromat
Posts: 236
Joined: Sun Feb 14, 2021 6:55 pm

Re: Rotary encoders and other with Raspberry Pi and Arduino Mega

#2 Post by Tetrachromat »

Detlef wrote: Sun Jul 18, 2021 5:43 pm ... and the Arduino Mega has 69 free IO pins. Right?
As far as I know from the 69 pins on a MEGA only 67 are usable. D0 and D1 are used internally for serial communication. See here.

Anyway for your setup I would rather go with 3 devices of the same type. One per panel.

Paul

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

Re: Rotary encoders and other with Raspberry Pi and Arduino Mega

#3 Post by jph »

Hi Guys,
Try not to confuse Raspberry Pi with a Raspberry Pi PICO, two completely different animals - for this stay away from the Pi ! - but not the PICO.
The PICO offers 26 usable - although AM Docs show 29 :? - see below, So, in this case, then the raspberry PI PICO handles the encoders and the Mega can handle 54 + ADC used as I/O - (the first two D0 D1 for serial comms) for standard button switches leds etc
You can add another Mega to handle more and have spare capacity.
Or, you could use 4 PICO units offering 104 options.
I would definitely go for a PICO for a batch of encoders. The rest is down to cost and convenience I suppose.
1 Pico and 2 megas may be a great option for future expansion ? or indeed, 4 PICO units as they are only about 4.5 Euro each in the EU and incredible units.
Joe

@Corjan, can you please clarify the usable pins in AM on the PICO ? the official docs from Raspberry show 26 I/Os - but also the 3 SWD pins - 2 + GND - (and the LED on GPIO 25), ?. I am not seeing a way - on first inspection to get more than 26 usable ? - - apart from the LED pin ?

https://datasheets.raspberrypi.org/pico ... asheet.pdf
Joe. CISSP, MSc.

Detlef
Posts: 303
Joined: Mon Nov 16, 2020 9:43 am
Location: Bavaria

Re: Rotary encoders and other with Raspberry Pi and Arduino Mega

#4 Post by Detlef »

Tetrachromat wrote: Sun Jul 18, 2021 8:42 pm As far as I know from the 69 pins on a MEGA only 67 are usable. D0 and D1 are used internally for serial communication. See here.

Anyway for your setup I would rather go with 3 devices of the same type. One per panel.

Paul
Paul,
thank you. Yes you are right. I already have one Arduino Mega in use. Of course D0 and D1 are for USB communication. From my previous panel I also see I have not used pin 13 which is the built-in LED, which on some Arduino designs has some unwanted effects when using it as input or output. For simplification I will just not use it.

But I made a mistake, the autopilot disconnect does not need an LED. And in addition I think I can eliminate the LED for the parkbrake because I use a lever that is in or out, easy to see, and a parkbrake light is present somewhere else in most planes anyway.

So I am down to 24 rotary inputs plus 2 general IOs for the Pico and 68 IOs for the Mega. I see your point, using one device per panel is better, but the Pico is too small for that and I still guess I am on the safe side letting a Raspberry Pico handle the rotary encoders. So I probably go with one Pico, one Mega.

Thank you
Detlef

Detlef
Posts: 303
Joined: Mon Nov 16, 2020 9:43 am
Location: Bavaria

Re: Rotary encoders and other with Raspberry Pi and Arduino Mega

#5 Post by Detlef »

jph wrote: Mon Jul 19, 2021 8:39 am Hi Guys,
Try not to confuse Raspberry Pi with a Raspberry Pi PICO, two completely different animals - for this stay away from the Pi ! - but not the PICO.
The PICO offers 26 usable - although AM Docs show 29 :? - see below, So, in this case, then the raspberry PI PICO handles the encoders and the Mega can handle 54 + ADC used as I/O - (the first two D0 D1 for serial comms) for standard button switches leds etc
You can add another Mega to handle more and have spare capacity.
Or, you could use 4 PICO units offering 104 options.
I would definitely go for a PICO for a batch of encoders. The rest is down to cost and convenience I suppose.
1 Pico and 2 megas may be a great option for future expansion ? or indeed, 4 PICO units as they are only about 4.5 Euro each in the EU and incredible units.
Joe

@Corjan, can you please clarify the usable pins in AM on the PICO ? the official docs from Raspberry show 26 I/Os - but also the 3 SWD pins - 2 + GND - (and the LED on GPIO 25), ?. I am not seeing a way - on first inspection to get more than 26 usable ? - - apart from the LED pin ?

https://datasheets.raspberrypi.org/pico ... asheet.pdf
Joe,
Thank you for pointing out Raspberry Pi versus Pico. I am not familiar with Raspberry til now.
As to what device how often, I will give that some more thinking.

Detlef

Detlef
Posts: 303
Joined: Mon Nov 16, 2020 9:43 am
Location: Bavaria

Re: Rotary encoders and other with Raspberry Pi and Arduino Mega

#6 Post by Detlef »

Hi,

sorry for having many questions now, maybe somebody can reply.

I did some more thinking (and I forgot the push functions of the rotaries). I have 99 wires (say IO ports) in total now, that I want to use in Airmanager instruments.
Included are 2 single rotary encoders and 5 dual rotary encoders.

So there are two solutions I would go:

- Use two Arduino Mega boards
- Use four Raspberry Pi Pico boards

I have some questions now where I really would love some help:

Generally:
1) Will both solutions work fine for the rotary encoders and all?
2) I get a lot of USB cables. Can I use a powered USB hub inside my panel assembly and then just connect one cable to the PC? Especially, I want to be sure I get all rotary clicks and button clicks reported to the AM instrument.


When using four Picos:
3) I read the Pico uses an operating system that makes it harder when there is a need to read or write signals in real time. Is this relevant here when I program it with the standard Sim Innovations software? I don't want to miss pilot actions on the rotaries and so on.

4) Will it be needed at some point in time to re-program the Picos, e.g. for a new Airmanager version? And would that mean, press the BOOT_SEL button while plugging in the USB cable? That would be difficult when my cockpit is assembled. I saw that it is easy to connect a button to the reset input, but the BOOT function is just put on a testpad TP6. I am not sure I can solder a wire there.

Thank you
Detlef

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Rotary encoders and other with Raspberry Pi and Arduino Mega

#7 Post by Sling »

Hi Detlef,

Generally I would say things will be fine whichever way you go but the proof is in the pudding as the saying goes.

My initial thoughts.

The Pico boards are cheap so pick one up and trial it if you have concerns to see how it performs.

Some USB hubs can cause problems so unless someone can recommend a specific one that you can buy right now you will have to take a bit of a chance with this. I think I remember someone having some issues with a USB3 hub so probably best to stay away from that.

Tony

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

Re: Rotary encoders and other with Raspberry Pi and Arduino Mega

#8 Post by jph »

Detlef wrote: Wed Jul 21, 2021 5:07 pm Hi,

sorry for having many questions now, maybe somebody can reply.

I did some more thinking (and I forgot the push functions of the rotaries). I have 99 wires (say IO ports) in total now, that I want to use in Airmanager instruments.
Included are 2 single rotary encoders and 5 dual rotary encoders.

So there are two solutions I would go:

- Use two Arduino Mega boards
- Use four Raspberry Pi Pico boards

I have some questions now where I really would love some help:

Generally:
1) Will both solutions work fine for the rotary encoders and all?
2) I get a lot of USB cables. Can I use a powered USB hub inside my panel assembly and then just connect one cable to the PC? Especially, I want to be sure I get all rotary clicks and button clicks reported to the AM instrument.


When using four Picos:
3) I read the Pico uses an operating system that makes it harder when there is a need to read or write signals in real time. Is this relevant here when I program it with the standard Sim Innovations software? I don't want to miss pilot actions on the rotaries and so on.

4) Will it be needed at some point in time to re-program the Picos, e.g. for a new Airmanager version? And would that mean, press the BOOT_SEL button while plugging in the USB cable? That would be difficult when my cockpit is assembled. I saw that it is easy to connect a button to the reset input, but the BOOT function is just put on a testpad TP6. I am not sure I can solder a wire there.

Thank you
Detlef
HI Detlef,
If I can try to answer these -

1. Basically, yes they should both work ok. However, the PICO is light years ahead in terms of storage space and speed (about 8 times greater than the 'mega'). There is simply no comparison. It is future proof. However, there is a definite case of - if a solution works for you, and you don't really intend to change it then use whatever you want. The PICO can cope with anything that AM wants to throw at it in the future. I would definitely agree with Tony and get a PICO and experiment. I really believe it is the future for AM due to its HUGE storage space, incredible speed and fully programmable I/O. The lessons learnt in using it for this project will be a huge bonus for the future as you see the power of the device and what it can offer. I must say though, that at the moment the pic is not proven in AM so it may well be worth experimenting, but not relying on it as as solution - yet. It is still in early development and needs a lot more testing. The future though is absolutely the best.

2.In theory, certainly. All USB Hubs are not made the same though. There are reputable known makes and some really unknown ones. They do however, all use one of about a dozen (or less) internal processors so shouldn't be much difference. and, the later ones do tend to be better than ones from even a few years back - in terms of throughput. The issue that some have reported in AM are, I believe, not really fully identified. Certainly there are power saving features that can cause issues but this is a part of the O/S and design requirements, however, the power saving options can be switched off. My favourite units that I can recommend are from Inateck. Absolute quality. You can see current models on their site https://www.inateck.com/collections/pcie-card This is the rolls royce - the internal unit. However, the external multiport hubs are also superb.
Don't use a powered hub. Power each board from a suitable supply. In the case of the PICO, it is a 2 to 5.5V supply. In the case of a mega it is higher due to the on board buck converter. Also, the PICO is a 3.3V unit whereas the mega is a 5V unit (as far as I/O goes) External good quality 5V supplies are easy to get and can power the whole cockpit if needed. As for cable, up to 5 Mtrs is fine for any use really. Please note the 3.3V I/O versus the 5V I/O on the mega - very important. 3.3V is the standard now although many peripherals have on board converters. For your use it doesn't matter really. IF you really ever needed a converter for a stubbon perhiferal then they are pennies each for an 8 way unit.

3. This is not a concern in any way.

4. It is simple to add both a reset AND a BootSel remote to the PICO. see schematic attached later - but basically, to add a remote bootsel, the look at the rear of the board and you will see a pad marked TP6 - near the usb connector. solder a wire to this and bring it to a remote button, then the return from the button goes to GND, that is it. For the reset - if needed - then you can connect 'run' pin to gnd via a button.

Attached is the schematic for the PICO - (purely for info). It can be clearly seen that TP6 to GND will cause a BOOTSEL, length of wires is not critical. Twist them if you like. On the schematic in the mid left the BOOTSEL section can clearly be seen.
Hope that helps ?
Joe
.
Pico Schematic.jpg
Joe. CISSP, MSc.

Detlef
Posts: 303
Joined: Mon Nov 16, 2020 9:43 am
Location: Bavaria

Re: Rotary encoders and other with Raspberry Pi and Arduino Mega

#9 Post by Detlef »

Sling wrote: Thu Jul 22, 2021 2:52 am Generally I would say things will be fine whichever way you go but the proof is in the pudding as the saying goes.
Hi Tony,
nicely put! :D

I see in Joes comments, he also suggests to try with a Pico first. The thing is, I am very lazy and not so good with the crafting work involved when it comes to hardware work. Assemble, disassemble, wire, re-wire and so on is not my thing. So if I go with Picos I will probably just be crazy enough, to order four Picos at once, and in addition the break-out screwshields. If something goes wrong with that, I can sell the screwshields :)

This may be a dumb question:
All I need to do to prepare a Raspberry Pi Pico for Airmanager is, start Airmanager and use it to transfer the needed standard program image into the Pico. And for that I have to press the Boot Select button on the Pico while connecting the USB cable of the Pico. Right?

Thank you
Detlef

Detlef
Posts: 303
Joined: Mon Nov 16, 2020 9:43 am
Location: Bavaria

Re: Rotary encoders and other with Raspberry Pi and Arduino Mega

#10 Post by Detlef »

jph wrote: Thu Jul 22, 2021 8:04 am HI Detlef,
If I can try to answer these -

1. Basically, yes they should both work ok. However, the PICO is light years ahead in terms of storage space and speed (about 8 times greater than the 'mega'). There is simply no comparison. It is future proof. However, there is a definite case of - if a solution works for you, and you don't really intend to change it then use whatever you want. The PICO can cope with anything that AM wants to throw at it in the future. I would definitely agree with Tony and get a PICO and experiment. I really believe it is the future for AM due to its HUGE storage space, incredible speed and fully programmable I/O. The lessons learnt in using it for this project will be a huge bonus for the future as you see the power of the device and what it can offer. I must say though, that at the moment the pic is not proven in AM so it may well be worth experimenting, but not relying on it as as solution - yet. It is still in early development and needs a lot more testing. The future though is absolutely the best.

2.In theory, certainly. All USB Hubs are not made the same though. There are reputable known makes and some really unknown ones. They do however, all use one of about a dozen (or less) internal processors so shouldn't be much difference. and, the later ones do tend to be better than ones from even a few years back - in terms of throughput. The issue that some have reported in AM are, I believe, not really fully identified. Certainly there are power saving features that can cause issues but this is a part of the O/S and design requirements, however, the power saving options can be switched off. My favourite units that I can recommend are from Inateck. Absolute quality. You can see current models on their site https://www.inateck.com/collections/pcie-card This is the rolls royce - the internal unit. However, the external multiport hubs are also superb.
Don't use a powered hub. Power each board from a suitable supply. In the case of the PICO, it is a 2 to 5.5V supply. In the case of a mega it is higher due to the on board buck converter. Also, the PICO is a 3.3V unit whereas the mega is a 5V unit (as far as I/O goes) External good quality 5V supplies are easy to get and can power the whole cockpit if needed. As for cable, up to 5 Mtrs is fine for any use really. Please note the 3.3V I/O versus the 5V I/O on the mega - very important. 3.3V is the standard now although many peripherals have on board converters. For your use it doesn't matter really. IF you really ever needed a converter for a stubbon perhiferal then they are pennies each for an 8 way unit.

3. This is not a concern in any way.

4. It is simple to add both a reset AND a BootSel remote to the PICO. see schematic attached later - but basically, to add a remote bootsel, the look at the rear of the board and you will see a pad marked TP6 - near the usb connector. solder a wire to this and bring it to a remote button, then the return from the button goes to GND, that is it. For the reset - if needed - then you can connect 'run' pin to gnd via a button.

Attached is the schematic for the PICO - (purely for info). It can be clearly seen that TP6 to GND will cause a BOOTSEL, length of wires is not critical. Twist them if you like. On the schematic in the mid left the BOOTSEL section can clearly be seen.
Hope that helps ?
Joe
.
Pico Schematic.jpg
Joe,

that helps a lot, thank you! I see you are a fan of the Pico already!

Regarding the USB hub: I don't mean one inside a PC, but inside my overhead panel, so that I have just one USB cable going to the PC.

Regarding a BOOTSEL button. As you say that, it does sound easy enough. I am thinking about the CZH-Labs Electronics Salon screwshields, because I like the one I have for the Mega.
https://www.czh-labs.com/products/screw ... ry-pi-pico
I hope it is still possible to solder a wire to the TP6 pad.

Thank you for the schematics also.

Thank you
Detlef

Post Reply