This is the automation system for specific chemical industry, where the temperature and rotational speed of stirring is very important for some chemical reactions. The aim of this project is to show, that FPGA can be used in connection with microcontroller. On the picture we see the container with stirrer. To control the temperature is needed to know what is the rotational speed of stirrer and know what is the fluid temperature in container. Heater and stirrer are used to control the internal parameters. This is my first serious project in FPGA so the project is not advanced and I needed a lot of time (more time than professional FPGA developer)) to do. Now I'm working to improve functionality of the project and I'm doing a MODEL.
To make this project you need:
- Digilent Zybo board (or other board with Zynq SoC),
- Some electronic elements like transistor,
- Digital temperature sensor,
- Vivado Design Suite with Xilinx SDK,
- NI LabVIEW or Visual C++ (to make an operator panel).
This project has three levels:
1) Programmable logic level
2) Embedded level
3) Operator level.
All processes are driven by operator which controls system by computer program. Because I don't have a lot of knowledge about computer programming I made program in LabVIEW, which communicate with device by serial port.
I would like to show you how to build this system. I made three parts of this instructable.
-> Programmable logic part,
-> C/LabVIEW part,
-> Hardware part (I will update this part as soon as possible if I do more)
Now I invite you to go to next step and learn something new about automation.
Step 1: Processing System
Open Vivado. Create new project. In IP Integrator choose Create Block Design and follow the instructions in creator. If you do this add to your block design the processing_system7_0 block and choose automate connections
Step 2: Configuration of Processing_system
Double-click on processing_system7_0 block. You will see the Zynq block internal structure.Choose Peripheral I/O Pins. You see a lot of pheripherals of microprocessor. In this step you can decide which peripheral is useful for you. Choose your peripherals on the left. Also you can modify your design in other windows, f.g. you can change the baud rates, frequencies... If you do this, click OK
Step 3: Verilog/VHDL User Modules
You can write your own modules and add this to your design. It is very easy to do, you should only in IP settings add your repository. If you add the repository you should right-click and choose add IP. Find your IP and add it to your design. In my design I have created a lot of modules. The most important are:
- temp_meas module which gets data from digital temperature sensor - DS18B20, now I have to
- Measurement module, which analyses pulses from optocoupler and send measurement data from FPGA to ARM,
- Automation module - this is output of microprocessor - we can set the values of pulse width, hysteresis and temperature for hysteresis block from ARM,
-Hysteresis block(only simulated!) - which control the heater.
- Motor_control - which generates PWM signal to the output according to value on it's input - the value from automation block.
Step 4: AXI IP's
If you added to your design AXI IP's (in brief: blocks which can communicate with processor) you should address it! The address is very important, because to write, read from AXI IP you will use a function, which needs the address. If you address your AXI IP's you should constrain your design - assign physical I/O to output/inputs of your module. If you do this step you have to synthetize, implementate, generate bitstream and export design to SDK.
Step 5: SDK - Software Development Kit
In this part we will discuss about microprocessor part of design. Open the SDK. Create new project.
Step 6: Using Your Peripherals
In programmable logic part you added some peripherals in processing_system. Now open the system.mss file. You can see the peripherals with links to documentation and examples. To make design you should follow the documentation and read examples. This is the best way to learn new things.
Step 7: Reading Data From Measurement
In this design you can read data from AXI IP! It is very easy, you should only use the special function from Xilinx library - Xil_In32(). On the picture I shown the structure of this function. In my example - offset 0 is the data from speed sensor, 1 and 2 - data from temperature sensor.
Step 8: Writing to Automation
Also you can write to your AXI IP's. It is similar to reading, you should only precise the address, offset and value which you would like to write. In my example I write the pulse width value (8 bit value) to AUTOMATION IP.
Step 9: Implementing PI/PID Algorithm
If you get data from sensors it is a good idea to make feedback and add the regulator. Now I'm working to improve the operation of the regulator (coefficients).
It is important to add saturation conditions! Regulator can produce very high values. The better way is use the PI regulator. Also remember about sampling time, good sampling time can help you a lot.
Step 10: UART Read/write
To send/receive data from computer you can use the serial port or ethernet. Because is very hard to implement an ethernet driver I choosen the easiest way - UART interface.
Step 11: Make a Bootable Image of Your Design and Program the Board.
In ZYBO board we can write out project to memory or to SD cart. You can program the board from SDK, remember: first program the FPGA!
Step 12: Make an Operator Panel
Nowadays to control the processes we use HMI/SCADA systems. Because it is a simple project I used LabVIEW to communicate with device. You should only have basic knowledge about LabVIEW (it isn't hard to learn this). Now I'm working about improving this application.
Step 13: Hardware - Connect H-Bridge to DC Motor
To drive DC motor you should connect it to the board via H-Bridge. Remember: never connect DC motor directly to FPGA/microcontroller board - current from inductance can damage the board. H-bridge is something like buffer.
Put H - Bridge to pmod connector. Get 12V supply (respectively efficient) and connect it to the bridge. Connect DC motor to the bridge.
Step 14: Connect Temperature Sensor
Use the digital thermometer and connect it to the pmod. Logic analyser will help you in improving your design.
In my design U have used analog temperature sensor. I connected it to XADC pmod connector and I configured XADC to measure voltage from sensor.
Step 15: Make Speed Sensor
It is a lot of speed sensors. I choosen the optical method - by optocoupler. In optocoupler energy is transferred by light. If the signal from optocoupler is to weak you should build an amplifier. Remember about voltage levels!
Connect the output of the transistor to pmod (according to constraints).
You can use hall sensors or use the feedback from current - this is your choice which sensor you use in design.
Step 16: Add Heater to Your Design
To create working model you should add the heater. Use the relay and transistor. Remember - relay is an induction element, so you should protect the transistor from current spikes. Now I'm preparing the heater to work so I will add photos If the heater will be done.
Step 17: Build Mechanical Construction
In this step you should build a mechanical construction. Add the container, make the stirrer, make the stand for DC motor. Immobilize speed sensor in good position.
Now I'm building the mechanical construction, If I end this stage of project I will update this step.
Step 18: Add More Sensors to Your Design
You can improve design by adding more sensors.
Step 19: Run the System
If you do all steps in this instructable you can test your design.
How much is done?
- 90% of programmable logic part,
- 70% of software part,
- 30% of model - only mechanical part
In video I didn't used a temperature sensor because unfortunately it damaged in tests, so I shown only the part of the system.
Link to video: https://youtu.be/-Q5xJpDqk20