After the recent Mini but Mighty build-along that showed how the Avnet MiniZed with it's onboard Zynq processor can control motors, I started wondering just how "mighty" could we go.
The project that we followed along with stepped up the Zynq's 3.3V low power IO to being able to drive a 12V motor at up to 2A. Quite impressive, but let's go a bit bigger!
The hardwareI've been lucky enough to be playing with (sorry, working hard controlling) a fairly large industrial robot arm recently. This is not a small hobby servo-driven robot. It's a full-on 6-axis robot arm with a reach of about a metre and it's quite capable of swinging a 5kg payload around at frightening speed! Do we think the little MiniZed is up to the job of controlling this? Well, let's find out!
Well, first of all you're going to need a robot arm. I'm using the Universal Robots UR5e, but any robot that has standard 24V inputs will do.
How do we control it?Whilst in the microcontroller / FPGA world we're used to small 3.3V signals, the industrial world likes to work on 24V. There's an IEC 61131-2 standard for this, so the things we're doing here should work with a lot of large equipment. Unfortunately the H-bridge we used for the build-along only works up to 12V so we'll have to create something ourselves. Don't worry though, it won't be very difficult.
Building our custom PMODOur MiniZed has 3.3V outputs. Our robot works with 24V. We'll need something to translate the signals. Luckily, this isn't as difficult as it sounds. As it's a fairly modern robot, it has type 3 inputs from the IEC 61131-2 standard, which means it sinks only a few mA of current at 24V. We're only sending a signal one way from the MiniZed to the robot, so our custom PMOD only requires a resistor (suitable for use with an LED) and an optoisolator for each channel. Here is our circuit diagram. On the right hand side there is an approximation of what we might find in the robot. You can see why a single transistor is all we need to drive it.
It really didn't take very longer to solder this circuit up on a bit of stripboard. The only thing which might have improved it would have been some 90 degree header pins so it sat flat in line with the MiniZed. Sometimes it's best to just work with what's on hand.
Modifying the Mini but Mighty codeAdam Taylor's original Mini but Mighty example used one GPIO and one PWM output. Here's we're using 4 GPIOs. There are some small modifications we need to make in both Vivado (for the hardware design) and Vitis (for the software).
In order to keep this guide concise, I won't repeat everything that was in the original. Once you have that working, I'll just explain the differences.
Vivado changesNot a lot changes in Vivado. Where the original project used one GPIO, we just need to select 4. We no longer need the TTC (Triple Timer Counter) but it does no harm to leave it in. Don't forget to make these new GPIOs external just as you did with the single one. I've ringed the changes required below:
In order to connect these to the outside world, we need to map them to the first 4 pins on PMOD 1. Rather than just telling you which pins to use, I'm going to explain how to find them. This is in case you want to do something slightly different. You need the schematic for the MiniZed with is available at http://zedboard.org/support/documentation/18891
Here you can see that they are L15 (as with the original), M15, L14 and M14.
This leads us on to updating our constrains file to enable these. Once you've made these changes just export the hardware and fire up Vitis as with the original guide.
# MiniZed PMOD 1 pins 1-4 as GPIO output
set_property PACKAGE_PIN L15 [get_ports GPIO_O_0[0]]
set_property PACKAGE_PIN M15 [get_ports GPIO_O_0[1]]
set_property PACKAGE_PIN L14 [get_ports GPIO_O_0[2]]
set_property PACKAGE_PIN M14 [get_ports GPIO_O_0[3]]
set_property IOSTANDARD LVCMOS33 [get_ports GPIO_O_0[0]]
set_property IOSTANDARD LVCMOS33 [get_ports GPIO_O_0[1]]
set_property IOSTANDARD LVCMOS33 [get_ports GPIO_O_0[2]]
set_property IOSTANDARD LVCMOS33 [get_ports GPIO_O_0[3]]
Vitis changesThe changes we need in Vitis are to use all four of our GPIOs. We can also ditch the timer-related code for processing the PWM. I deliberately checked in the original code under source control before changing it, so you can see exactly what's been added and removed.
One thing I wasn't sure about was why we were accessing the first GPIO pin as pin 54 in code. I'm guessing that pins 0-53 are for MIO pins and 54 upwards are for EMIO-mapped pins, although I have yet to find where this is documented. Regardless of why, the 3 extra GPIOs are pins 55-57.
You will find all the source code for both Vivado and Vitis at https://github.com/FredMurphy/MiniZed_MightyRobot
Wiring it up to the robotThe first thing we need to do is to check that the GPIO is getting through to the robot and being seen as changing inputs. A bit of 8-core CAT5E Ethernet cable proved useful and I wired up our 4 outputs (plus the 24V) to 4 digital inputs on the robot.
Here you can see that my first GPIO is being detected as a high input on digital input 1. It's only a little checkbox on screen, but it means big things!
Compared to the Zynq, programming the robot is a breeze. The basics mostly involve setting a few waypoints and telling it how fast to get there. There's a bit more to it than that if you want it to do more advanced stuff, but it's really not that hard. Here's our robot program shown on the teaching pendant. You can see it all in the source code repository.
I've gone with a very simple program which maps each GPIO to a single sequence. Obviously it would be possible to do much more. Our 4 inputs give us 16 combinations to work with - although combining them as a 4-bit parallel bus is not built-in. The robot doesn't support PWM directly but it does have a 0-12V analog input so I could have kept the original PWM output, smoothed it and used it to control the robot's speed.
If you want to find out more about programming an industrial robot, you can do it all using a simulation here. You'll have to create an account, but other than that it's all free.https://academy.universal-robots.com/online-training/e-series-online-training/
DemoWell, it'd be no fun if we didn't see the MiniZed and the robot in action, would it? I hope you've enjoying seeing that the MiniZed can interface with some bigger stuff and you're inspired to try something big yourself!
Comments