Schlagwort: tech articles

  • Pico W retro gaming special in The MagPi magazine issue #122

    Pico W retro gaming special in The MagPi magazine issue #122

    Reading Time: 2 minutes

    Retro Gaming with Raspberry Pi Pico and Pico W

    Retro Gaming with Raspberry Pi Pico & Pico W 

    Our resident retro games expert KG Orphanides has crafted a superb feature for this month’s edition of The MagPi magazine. Discover how to emulate classic computers, hack 1980s hardware, and play retro games on a $6 microcontroller.

    Build a Mini Magic Mirror

    Build a Mini Magic Mirror

    A magic mirror is one of the timeless Raspberry Pi projects that we’ve given a new spin this month. Using a smaller screen and Raspberry Pi Zero W we’ve created a range of magic mirror projects that you can deploy around the home.

    LEGO Submarine 4.0

    LEGO Submarine 4.0 

    Get underwater with this incredible build. Using LEGO, a syringe, a pressure sensor and a wireless communication board this build can head into (and underneath) the water.

    Raspberry Pi Radio: Add a DJ and jingles

    Add a DJ & Jingles to your Raspberry Pi Radio

    Sean McManus has built an incredible Raspberry Pi Radio that doesn’t just play songs, it uses Raspberry Pi smarts to create a virtual DJ. The disc jockey uses voice technology to interject and announce tracks, and even plays jingles and stings.

    Build a Poltergust G-00

    Build your own Poltergust G-00

    The MagPi’s very own Rob Zwetsloot has created this incredible 3D-printed ghostbusting vacuum from Luigi’s Mansion 3. This month Rob walks us through the build process.

    The Centre for Computing History interview

    The Centre for Computing History interview

    We talk to the incredible museum located in Cambridge about its wonderful range of classic computers, retro games, and a giant processor that plays Tetris.

  • Win! 1 of 5 EPD Pico Kits

    Win! 1 of 5 EPD Pico Kits

    Reading Time: < 1 minute

    Subscribe

  • LEGO Reaction Wheel Inverted Pendulum

    LEGO Reaction Wheel Inverted Pendulum

    Reading Time: 3 minutes

    Well, that’s the theory, but in practice it’s not quite so easy and, as shown in his YouTube video, Juha had to alter his Python code repeatedly and make hardware adjustments to get the system to work to his satisfaction.

    Precision control

    A gyroscope and accelerometer on a mini IMU (inertia measurement unit) board are used to measure the pendulum angle, while Raspberry Pi runs a control loop for filtering data and calculating PID (proportional–integral–derivative) controller outputs for adjusting the motor’s speed and direction. Automatically calculating corrections based on feedback, PID is one of the most common control methods used in industrial and mechanical applications, such as in a car’s cruise control system. It’s also fairly easy to implement.

    “Others have used LQR [linear–quadratic regulator] control for inverted pendulums,” notes Juha, “but it looks too mathematical and difficult for me. As for tuning the PID parameters, I didn’t have any approach other than ‘try and see.’ It got good laughs in the YouTube comment section as it looks so unprofessional.”

    While Juha opted to use a Raspberry Pi Zero 2 W for its fast bootup speed, “CPU load was only 5% running the control loop with a 1 ms interval, so it would work with a much less capable board.” He even tried using a Pico, which “worked OK in terms of processing power, but then I realised I need to store tens of megabytes of log data for drawing nice graphs for the video.”

    Amazingly, before this project, Juha had never used a Raspberry Pi before and had minimal experience with electronics. “I had to figure out how GPIO works, what are pull-down and pull-up resistors, how I2C works, etc.”

    Keeping it up

    The next major challenge was getting the pendulum to stay upright for more than two seconds. “The problem was with the reaction wheel top speed limitation,” says Juha. “There is a short time window for acceleration before the limit is reached, so you need to get past the top equilibrium point before that. A plain PID controller would just minimise angle error and keep the wheel rotating too fast. I read many studies of different inverted pendulums, until I found one paper that mentioned continuously changing the target angle for the PID controller. That solved it finally.”

    So, in the finished system, is it impossible to push the pendulum off balance so that it falls over? “No, not at all,” replies Juha. “It will easily fall over if you push it. The controller will immediately try to compensate for the push by accelerating the wheel, but it can correct only for small errors. With a more powerful motor, higher top speed, and higher rotational inertia for the wheel, it would resist stronger pushes.”

  • LEGO Reaction Wheel Inverted Pendulum

    LEGO Reaction Wheel Inverted Pendulum

    Reading Time: 3 minutes

    Well, that’s the theory, but in practice it’s not quite so easy and, as shown in his YouTube video, Juha had to alter his Python code repeatedly and make hardware adjustments to get the system to work to his satisfaction.

    Precision control

    A gyroscope and accelerometer on a mini IMU (inertia measurement unit) board are used to measure the pendulum angle, while Raspberry Pi runs a control loop for filtering data and calculating PID (proportional–integral–derivative) controller outputs for adjusting the motor’s speed and direction. Automatically calculating corrections based on feedback, PID is one of the most common control methods used in industrial and mechanical applications, such as in a car’s cruise control system. It’s also fairly easy to implement.

    “Others have used LQR [linear–quadratic regulator] control for inverted pendulums,” notes Juha, “but it looks too mathematical and difficult for me. As for tuning the PID parameters, I didn’t have any approach other than ‘try and see.’ It got good laughs in the YouTube comment section as it looks so unprofessional.”

    While Juha opted to use a Raspberry Pi Zero 2 W for its fast bootup speed, “CPU load was only 5% running the control loop with a 1 ms interval, so it would work with a much less capable board.” He even tried using a Pico, which “worked OK in terms of processing power, but then I realised I need to store tens of megabytes of log data for drawing nice graphs for the video.”

    Amazingly, before this project, Juha had never used a Raspberry Pi before and had minimal experience with electronics. “I had to figure out how GPIO works, what are pull-down and pull-up resistors, how I2C works, etc.”

    Keeping it up

    The next major challenge was getting the pendulum to stay upright for more than two seconds. “The problem was with the reaction wheel top speed limitation,” says Juha. “There is a short time window for acceleration before the limit is reached, so you need to get past the top equilibrium point before that. A plain PID controller would just minimise angle error and keep the wheel rotating too fast. I read many studies of different inverted pendulums, until I found one paper that mentioned continuously changing the target angle for the PID controller. That solved it finally.”

    So, in the finished system, is it impossible to push the pendulum off balance so that it falls over? “No, not at all,” replies Juha. “It will easily fall over if you push it. The controller will immediately try to compensate for the push by accelerating the wheel, but it can correct only for small errors. With a more powerful motor, higher top speed, and higher rotational inertia for the wheel, it would resist stronger pushes.”

  • LED sphere

    LED sphere

    Reading Time: 3 minutes

    The idea for the project followed a friendly chat. “I was having a lunchtime discussion at work with my friend, Jens, a 3D printing wizard, about doing things with LEDs that hasn’t really been done before,” Tom recalls. After ordering a 3D printer – “and wanting to use it for something more than printing out an Iron Man helmet or a vase” – he put a plan into action. “One of my biggest requirements from the start was a lot of LEDs.”

    Bouncing ideas

    By the time he got started, other makers were creating something similar. Jiří Praus unveiled his Freeform LED Sphere (“but it’s constructed out of differently sized rings around a central axis, which I didn’t want”) and Whity created the Geodesic(k) RGB LED Spheres (“but 180 LEDs, and the LED density was too low because he used premade WS2812B PCBs”).

    With research, he learned that it’s mathematically impossible to distribute points uniformly across a sphere, but there were techniques which came close. “I loosened the requirement of uniform LED distribution somewhat and chose an icosahedron as the core internal structure,” he says. “Its 20 axes of symmetry is sufficiently high.

    “I also came to the conclusion that through-hole LEDs were the way to go if you want the surface of the sphere to be truly curved. You can adjust the length from the LED core to the PCB for each LED individually.” He then spent more than a month using FreeCAD to come up with potential design ideas, starting with a central lattice made out of hollow triangles on which 20 PCBs and 20 triangular sphere elements were mounted separately.

    On a roll

    Printing and assembly issues caused a rethink. “The breakthrough came when I dropped the central frame, inserted LEDs from the outside into the shell, and mounted the PCBs firmly against the inside shell triangle,” Tom explains. “I used magnets on each triangle side to form a self-supported structure. The more sphere elements snap together, the sturdier it becomes.”

    Eventually, he switched from FreeCAD’s GUI to its embedded Python engine. He also settled on 21 LEDs for each of the 20 sphere elements, designing a custom controller PCB on which to mount them. A Raspberry Pi Pico formed the project’s heart and Tom initially coded the project using MicroPython, later transitioning to regular C.

    “I needed something that was small, didn’t require a lot of power, had a lot of performance, was close to the metal, had the ability to drive WS2812 LEDs, and had very good documentation and examples,” Tom notes. “The Raspberry Pico scored high on all those points.”

    The result is impressive. “The LEDs are not just a part of a sphere element, but part of the whole sphere, with a unique (x,y,z) coordinate assigned to it,” Tom says. It’s also battery-operated, making it entirely mobile.

    Tom has enjoyed the process so much, he’s on a roll, continuing to make improvements. “Right now, I’m dealing with a fair bit of instability due to loose wires,” he says. “If I were to do this again, I’d probably use JST connectors instead of plain vanilla pin headers and connectors, because they make a very reliable link.”