Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5369

MicroPython • Re: multithreading with Raspberry Pi Pico for model railroad

$
0
0
More information seems called for, so here it is.
On one side of the layout we have Cogload Junction, which is where the lines to/from Taunton divide to Bristol or Westbury. There is a single track bridge. On the other side we have the recombination, 4 lines to 2. The cross-over makes life complicated, which is why the Victorians built the bridge pretty soon after opening the line. Anyone who has waited on the London Underground in the vicinity of Aldgate will know this.
On the Pico I'm using all the GPIOs except the SPI to the MCP3008.
I probably can get away with a single thread because the pulses from the Hall-effect devices are probably longer than 32ms and can be stretched if necessary with a capacitor on the open collector/resistor pull-up. So a quick bit of logic in between times could work.
My ambition is to have 4 trains operating without smashing into each other.
This is spot on:
15 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3
--:--:--.--.--.--.--.--.--.--.--.--.--.--.--.--.--:--:--.--.--
Stop __:__:____________________________________________:__:________
: : : :
Slow __:__||||_________________________________________:__||||_____
: : : :
Half __:__||||||||||||||||||||||_______________________:__|||||||||
: : : :
Fast |||__||||||||||||||||||||||||||||||||||||||||||||||__|||||||||

but 4 of these sequences will run simultaneously, phased by 4 time slots. One of the time slots will read all 4 track back-emf at once.
Thank you all for your interest and suggestions.
TTFN
Richard.

Statistics: Posted by rickticktock — Wed Aug 07, 2024 6:18 pm



Viewing all articles
Browse latest Browse all 5369

Trending Articles