Stacking 2 blue pills

Post here first, or if you can't find a relevant section!
Post Reply
Gazz292
Posts: 7
Joined: Sat Apr 23, 2022 9:02 pm

Stacking 2 blue pills

Post by Gazz292 »

i am building a set of desktop controls for my hobby of playing on train driving simulators,

i play on 2 different simulators which take different input methods, one simulator, via an external program can accept any USB joystick input, so for that one i flashed a bluepill with FreeJoy... which is a GUI programmable USB-HID joystick.

The other simulator can not accept usb joystick input, but someone has figured out a way to trick the simulator into accepting a serial string with the potentiometers positions,
so i run a simple arduino serial string type sketch on a seperate blue pill, that blue pill is programed as an arduino, using the stm32duino library (shows up as a maple mini... can you tell programming isn't my strong point)

So atm i have to swap boards over when i change simulators, physically unplugging the potentiometers and switches and plugging them into the other blue pill, even tho i have just 2 bits of strip board to unplug from one board, and plug into the other...then swap usb leads over, it's getting old fast, and i will break wires or wear the header sockets out i imagine.



So.... I thought i could be clever and stack 2 blue pills, so all pins are connected 1 for 1 between the 2 boards, the potentiometers and buttons will send the signals to both boards at once, and i will just swap the usb lead over to power up which ever board i want.


Only that didn't work, neither board will boot up when i do that.

So i'm wondering if there are some pins that i should disconnect between the 2 boards that might be causing them to not boot,

i'm thinking that maybe the reset pin (pin 7, NRST) shouldn't be shared between boards, but are there others i shouldn't have connected between both boards.
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 26
Location: Prudnik, Poland

Re: Stacking 2 blue pills

Post by GonzoG »

You cannot do it like this at all.
Both boards connected like this will be powered up, both boards will be trying to communicate over USB in 2 different protocols.

You can connect buttons and pots to 2 boards but those boards cannot share any pins other than used signal pins and GND.
This also excludes PA11 and PA12 (USB pins).
But it isn't a good solution as both boards may interfere with each other.

I'm building steering wheel for ETS2/ATS that will use 2 boards - 1 as USB joystick (ATMegaU4 board like Arduino Micro, Leonard, Pro Micro, as those can be programmed using Arduino IDE to be seen as joystick) and 1 STM32F4 board that will get data from game to display some information and for buttons control, that sends data to ATMegaU4 over UART.
Gazz292
Posts: 7
Joined: Sat Apr 23, 2022 9:02 pm

Re: Stacking 2 blue pills

Post by Gazz292 »

will it make a difference that only one board would be plugged into usb at a time, so the other one will be reading the signals and sending them to usb, but nothing will be reading them???

so the PA11 and 12 pins will need isolating as well, as they will be trying to do that thing where 2 different protocols are fighting each other.

i could put a switch in on the main 3.3 volt pins, isolate the 5 volt pins and the vbus pin, so it 'should' be just the grounds and signal input pins working then?

........

I also have a bus simulator (for Omsi) where i've connected a dashboard from a German NG272 bus to the computer using an arduino mega and a simple transistor pcb i made to switch the 24 volt signals to the lights and gauges, i also have the ticket machine and destination display and controller hooked up and working with the sim,

Plus of course the bus steering wheel and column, for which i am building a custom force feedback system for it, using EMC FFB, this should allow me to have the full 6 turns lock to lock on the wheel, and enough torque to break thumbs if i don't turn the current to the 150 watt motor down 8-)
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Stacking 2 blue pills

Post by fpiSTM »

I agree with @GonzoG .
Even if you plug only one USB. Other boards will be power up and receive also signal on same pins.
Gazz292
Posts: 7
Joined: Sat Apr 23, 2022 9:02 pm

Re: Stacking 2 blue pills

Post by Gazz292 »

She lives... it works... woooo :twisted: 8-)

The extra long pin headers arrived in the post today (female pin headers, with long male pins)

So i soldered a set of 20 each side of a spare blue pill i had, so the female headers are on the top of the board, and sticking out the bottom of the board are male headers that are long enough to plug into another set of female headers... i.e. the other stm board.

i removed the pins for reset, vbus/vbat, the 5 volt pin, and pins PA11 and PA12... usb data. all the other pins will be shared between the 2 boards.

flashed the stmduino loader onto it using STMlink, so it became seen as a maple mini,
and then loaded on the simple arduino sketch that reads the pots positions and sends them out in a string over serial,

Plugged this blue pill into the other one that runs FreeJoy, then the strip connector with the potentiometers on it was plugged into the top board (the stmduino one)

Plugged in the USB cable to the top blue pill, and it booted up and began sending out the serial string/stream.

Of course the lower board also booted up, but it's just sat there, presumably reading the potentiometers positions but with no where to send the data.

i swapped the usb cable over to the bottom board, and the USB HID joystick showed up in device manager, and i had the joystick working.



I had to just try it... so i got a 2nd usb lead and plugged both boards into the same laptop, and they played nicely together, i was getting both the FreeJoy joystick data on com3, and the serial string stream on com6.


So i can possibly put a small USB hub in the train driving lever box, so theres a single usb cable to the computer, and whichever simulator i play will read the relevant input board.
Post Reply

Return to “General discussion”