Silicon ChipElectronic Building Blocks - July 2022 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions
  5. Publisher's Letter: The importance of repair
  6. Feature: Mixed menu by Mark Nelson
  7. Feature: The Fox Report by Barry Fox
  8. Project: Net Work by Alan Winstanley
  9. Project: Single-Chip Silicon Labs FM/AM/SW Digital Radio Receiver by Charles Kosina
  10. Project: Model Railway Level Crossing by LES KERR
  11. Project: Advanced GPS Computer by Tim Blythman
  12. Feature: Make it with Micromite by Phil Boyce
  13. Feature: Max’s Cool Beans by Max the Magnificent
  14. Feature: Flowcode Graphical Programming by Martin Whitlock
  15. Back Issues: Flowcode Graphical Programming by Martin Whitlock
  16. Feature: Circuit Surgery by Ian Bell
  17. Feature: AUDIO OUT by Jake Rothman
  18. Feature: Electronic Building Blocks by Julian Edgar
  19. PCB Order Form
  20. Advertising Index

This is only a preview of the July 2022 issue of Practical Electronics.

You can view 0 of the 72 pages in the full issue.

Articles in this series:
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
Electronic Building Blocks By Julian Edgar Quick and easy construction Great results on a low budget Introduction to linear actuators – Part 2 Controlling a linear actuator with positional accuracy using the programmable Pololu Jrk 21v3 module. I n Part 1, we looked at how linear actuators can be controlled by simple switches and relays. This approach is fine if you want the actuator to be fully open or fully closed, or you are controlling a progressive opening by physically watching the movement of the actuator (eg, shutting a gate). However, if you want more accurate control (for example, always opening the actuator by exactly 100mm) then a controller that uses position feedback is needed. So, this month, we turn to a fully programmable control module that provides excellent positional accuracy, even with varying voltage feeds and loads. In addition, the module can also control maximum speed and acceleration – and more. Note that to make use of the feedback function, you will need to select a linear actuator that uses an internal potentiometer to provide position information. These are less common than actuators without feedback. That said, companies like AliExpress do offer them from about £30. Fig.1. The Pololu Jrk 21v3 is a tiny board – just 34mm square. However, it can run brushed DC motors drawing up to a peak of 5A and can be controlled through multiple interfaces, including an analogue input, serial, PC USB link or model RC pulse train. Once programmed, it can be disconnected from the PC. 64 The controller The controller we will use is the Pololu Jrk 21v3 USB Motor Controller with Feedback. It is widely available for about £40. Now, before you blanch at that price, let’s take a step back. Why, you may be thinking, don’t you just use a cheap microcontroller like an Uno with a H-bridge motor drive shield? After all, you’re only controlling a DC motor! Well, the key difference is the software. Unless you want to spend a lot of time writing code – and I mean a lot – then the off-the-shelf software that is freely available for the Jrk 21V3 controller provides a huge advantage over a home-grown software solution. But before we look at the software, what does the module comprise? Measuring just 34mm square, the Jrk 21V3 is designed specifically for controlling small, brushed DC motors. Part of a family of motor controllers, the Jrk 21V3 has a maximum supply voltage of 24V and a maximum continuous current of 2.4A, with a 5A peak rating. (Higher currents are available in other controllers in the family.) The Jrk 21V3 has four interfaces: n USB for control via a PC n TTL-level serial interface for microcontroller control n Radio control (RC) PWM control for direct connection to an RC receiver or servo controller Fig.2. The connections for the Jrk 21v3 – a regulated 5V supply is available from multiple pins to power control and feedback pots. (Courtesy Pololu) Practical Electronics | July | 2022 Fig.3. The Input tab. Note here that the Analog voltage input has been selected and that the Target has been reduced from a full range of 0-4095 to 1400-2500, so limiting the stroke of the actuator to suit the application. Visible near the top are the Target and Scaled Feedback values – here they are identical, indicating that the actuator has stopped at exactly the requested extension. n 0-5V analogue control; eg, via a manual potentiometer. Here, we will be using the 0-5V analogue control. The all-important feedback can be via the following two means: n A 0-5V analogue signal n Tachometer (speed) up to 2MHz. Alternatively, the system can be set to have no feedback – that is, use openloop control. We will be using the 0-5V feedback signal derived from the pot inside the linear actuator. Above, I mentioned software. Using the USB connection to a PC (connection is via a USB Mini B connection – no cable provided), the following motor parameters can be altered: n PID tuning n Max current n Max duty cycle n Max acceleration n Error response n Input learning for analogue and RC control. These may all mean little at this stage, so let’s paint a word picture of what these settings can achieve. Say you were pretty excited by the picture in last month’s issue, showing the TV that can rise out of a cabinet at your command. Using just a toggle switch to operate the linear actuator and its internal limit switches to turn it off at each end of its travel, you will have the following outcome. When the switch is operated, the TV will start rising with a jerk as power is applied to the motor. It will then rise at a speed determined by the supply voltage and actuator speed specification, before it reaches full height and trips the internal switch, stopping abruptly and probably shaking the whole assembly. On the way down it will probably travel a bit faster, making an even bigger jerk as it stops at the limit of its travel. OK, it does the job but hardly an elegant solution. Now let’s add the Jrk 21V3 controller. This time, the actuator speed increases p r o g r e s s i v e l y, s t a r t i n g a l m o s t imperceptibly and then gradually rising in speed. The maximum speed of the actuator can be pre-set – for example, to minimise noise, you can run it at a maximum speed of only 30% full speed. The point at which the actuator stops rising can also be set (that is, the actuator doesn’t need to hit the limit switch) and as the actuator reaches that pre-set point, it can be programmed to progressively slow until it slides to a gentle halt. And that stopping point can be set and achieved with millimetre accuracy. On the way back down, all these parameters can again be set, but this time taking into account the weight of the TV that will be hastening the retraction process. (In other words, you can have different settings for ‘up’ and ‘down’.) Now you can start to get a feel for what this controller can do with a linear actuator. And start to see the non-trivial nature of the programming involved, but which is built into the Pololu software – in particular, building your own, unconditionally stable PID controller is not straight forward. Connections Fig.4. The Feedback tab – Analog voltage has been selected as the feedback type, and because the feedback signal was working in the opposite direction to the Input direction, Invert feedback direction has been ticked. Practical Electronics | July | 2022 As bought, the board will probably come with two loose 2-pin terminal blocks and a male header strip. These can be easily soldered to the board (this is not done at the factory in case you want to fit angled headers or different terminal blocks). The terminal blocks are for power supply and the two motor connections. In addition, we are going to require connections for the feedback signal from the actuator, and the analogue control signal to set the position we want the linear actuator to achieve. (In our case, we’ll use a simple pot to provide the control signal.) Therefore, we will need regulated 5V outputs and grounds for the extremities of the two pot connections – these are available on the board and are well 65 Fig.5. The PID tab – the P, I and D parameters can all be altered. Note the unusual way in which the data is input – either as a fraction with the denominator multiplied by the adjacent numeral (unless you put in zero, whereupon it defaults to 1), or direct-entered as the coefficient. Playing with these settings gives enormous control over the behaviour of the system. labelled. (Incidentally, a very good 55page manual is available for the Jrk 21V3 – it’s worth looking at before buying, as well as when building your board into your application.) The feedback signal from the actuator connects to the FB pin, while – not so obviously – the control input connects to the RX pin. The board is protected against reverse polarity, over-load and over-temperature – so it should be difficult to kill it when making these connections. However, always turn off power first and check the wiring before switching power back on. Software The software is available from Pololu and is best accessed by clicking on the link in the pdf manual. There is a large section in the manual on installing the software, but with Windows 10 Pro I just followed the on-screen prompts and had no difficulties. Testing Do your initial testing with the actuator sitting on the bench, not connected to the device that you wish to mechanically move. With the Jrk 21V3 plugged into the PC, click on the Connected to dropdown box and you should be able to select your device. Select the Input tab and then choose Analog voltage as the input mode. Ensure that as you turn the input pot, the Target number alters. You should also see a number associated with Scaled Feedback – but at this stage this won’t change since the actuator isn’t yet moving. So, if everything is connected, why isn’t the actuator moving when the input pot is turned? It’s because the PID settings are all still at zero. (PID – proportional, integral, derivative – is a control loop system that allows very effective control.) Move to the PID tab and start by setting P to 20 – leave the other figures at zero at this stage. (After any calibration change, press Apply settings to this device to upload to the module.) Now with P at 20, when you turn the input pot, the actuator should move, slowing abruptly when it gets to the position you’ve selected. Now Fig.6. The Motor tab – here maximum speed, maximum acceleration and brake durations can all be set. These allow the system to be set up so that the actuator smoothly gathers speed and operates at a maximum speed that suits the requirements of the mechanical system. Current can also be limited – the system then specifies a motor duty cycle that causes this current value to not be exceeded. 66 alter P to 5, and you should see that the actuator more progressively comes to a stop at the setpoint. To get the ‘last little bit’ of movement accurately to the setpoint, increase I (say to 0.125). You can now check how accurately the actuator is positioning itself at the setpoint – compare the difference between the Target and Scaled Feedback numbers. It’s not hard to program the PID settings to achieve identical numbers – that is, the actuator has moved to precisely the correct point. If the system seems to work nothing like the description in the above paragraph, you may have the Input and Feedback pots working in opposite directions. This is easily fixed by ticking the Invert box in either the Input or Feedback tabs (don’t invert both or you’ll be back to where you were before.) If the actuator is being used across its full stroke, the inbuilt limit switches will come into play. That is, rather than the actuator slowing progressively, it will hit the limit switch and so stop abruptly. To prevent this occurring, you can reduce the target range of the Input pot. For example, rather than the range being 0 to 4095, change the Target to a maximum of 2500 and the minimum to 1400. This will then cause the actuator to work over a smaller stroke range. So, now we have the actuator slowing progressively as it reaches the setpoint, but it still starts its movement with a jerk. Go to the Motor tab and place a small number (eg, 2) in the Max. acceleration box. Now when you turn the knob, the actuator will progressively gather speed. In the same tab we can change the maximum speed that the actuator reaches – this is specified by Max. duty cycle, where a count of 600 means 100%. One thing that is not obvious in this tab is the meaning of ‘Brake duration’. In this application, it refers to the delay time if you turn the pot from one direction immediately to the other. When setting up the PID parameters, it is worth opening the Plots tab. This window can then be dragged to one side and enlarged. The Plots tab allows you to graph a range of variables including error, motor duty cycle, target and feedback. The graph will quickly show if you have control overshoots or undershoots. It’s also fascinating to watch as the system progressively reduces the error, the motor duty cycle smoothly reducing as the actuator draws closer to the correct stopping point. Once the actuator is working correctly on the bench, install the actuator in the mechanical system it is going to control. Then, as the actuator is working under real world loads, some settings will probably need to be tweaked in the Jrk 21v3. Practical Electronics | July | 2022 Multi-switch position input Fig.7. The Error tab – a wide range of fault conditions can be monitored. They can each be Enabled or Enabled and latched, the latter stops the motor until a new command is received. Rather than using a pot, it’s easy to organise a rotary switch to give a variety of pre-set actuator positions. For example, in a racing car where an aerodynamic rear wing may need to be driver-adjusted in angle to take into account different track or fuel load conditions, a pot would be too fiddly to use. Instead, a 4-position rotary switch can be fitted – see Fig.10. In this approach, each pole of the switch is connected to the wiper of a 10kΩ, 10turn, trim-pot wired across regulated 5V and ground. The voltage available on the wiper of each trim-pot can be set by turning the trim-pot – and thus the position of the actuator at each switch position can be adjusted. With a linear actuator controlling wing angle, four wing angles can then easily be selected under racing conditions. A similar ‘pre-sets’ approach could be taken if controlling house curtain openings, how far down a blind is to extend – and so on. Conclusion In the two parts in this series we’ve covered operating a linear actuator with the simplest and cheapest of approaches – just a toggle switch – right through to using a sophisticated programmable controller. (How sophisticated? In fact, in this article we’ve not covered every available feature of the Jrk 21V3 – there’s simply not space to do so.) With the price of linear actuators having fallen so dramatically over the last few years, there’s no excuse not to automate a whole variety of systems that require movement. Have fun doing so – and we’d love to see some of your projects using these actuators. Fig.8. The Plots tab – this tab graphs in real time the selected parameters. Here Target, Scaled feedback and motor Duty cycle have been graphed. Note that what is shown above is not a good representation of what you normally see – here the input pot has been rapidly turned back and forth so that major changes could be seen over the maximum five-second window. Normally a step change in the input is followed by the feedback and target lines gradually coming together. Fig.9. The Jrk 21v3 connected to a pot for the input (foreground). The green, yellow and white connections are to the feedback pot on the actuator. The red and black wires are for power and ground and the actuator motor connections. Here the Jrk 21v3 is connected to a PC via the USB cable for programming. As can be seen, to operate a linear actuator requires minimal connections. Practical Electronics | July | 2022 JrK 21v3 input 10kΩ, 10-turn potentiometers 4-way user selection switch R egulated 5 V 0V (Gnd) Fig.10. Here a multi-position switch has been used with four trim-pots to give four pre-set positions for the linear actuator. The position of each pre-set can be adjusted by rotating the relevant trim-pot. 67