Expanding the capabilities of standard robotic designers using LabView

  • Tutorial


Hello again, dear Habravites! Have you already collected all the possible models from your constructor? Are you tired of “driving along the line”, “controlling from the remote control” and “determining the distance to the object”? Have you already forgotten the last time you took your designer from the far shelf? It's time to brush off the dust and breathe new life into it! How to do it? We read under the cut!


1. Introduction


I was encouraged to write this post by applicants entering MSTU. N.E. Bauman on robotics, and claiming that "they are cool robots," but in reality they refuse to understand that robotics is much more complicated and interesting than assembling a standard machine from a designer and teaching her to ride along the line. Further there will be a bit of lyrics and reflection, and therefore those who want to immediately get acquainted with the technical part - I ask in section 3.

2. The lyrics, or why did I start all this


Recently, as part of our team (all graduates of the Bauman Moscow State Technical University from the departments of robotics specialties) I worked a lot with students of different ages - from 4th to 11th grade, and the level of the guys was completely different: from 5th graders - prize-winners of the LEGO and VEXiQ competitions, up to 11 graders, who first saw the live servo drive. And the situation in all cases is approximately the same - the student “lights up” with the idea, starts to work hard, achieves some results and “goes out”. And it goes out not in the sense of "tired of collecting robots," but in the fact that he cannot find (or does not want to search, or no one to direct in the right direction) ideas on how and in what direction to develop further. The most annoying thing happens when schoolchildren with whom we studied in the classroom from the 9th, realized several independent projects, and entered the MSTU in the robotics direction, suddenly, in the first year, loses interest in robotics and goes to "trade with vacuum cleaners." On the one hand, they can be understood - a strong overload and the complete absence of special items (which by the way do not always stir up interest). But on the other hand, most often they have an eternal question - when will they tell me how to assemble other cool cars from other cool designers? Why am I all this? The main problem in the development of robotics as a direction is the lack of creative thinking among students (and students) aimed at the formulation and solution of non-trivial tasks in the design and layout of various robotic systems. Educational programs
- Entry level (9-12 years)
- basic level (8-14 years)
- basic competitive level (12-15 years)
- professional level (14+)
- research and expert levels (14+).
But one way or another, despite the fact that within the last two levels (research and expert) we are trying to inculcate a creative approach to the prototyping of robotic systems, the projects carried out as part of the training are based on standard layouts, the assembly and programming of which are described in detail in the manuals . As a result, the majority of trainees have the following stereotypes: firstly, from each set you can collect a certain amount of a certain type of model, and secondly, robotics consists in assembling these same models. Despite our attempts to explain to the children the opposite in words, this is not always possible. Therefore, in this article I would like to offer some non-trivial ways to expand standard robotic designers, devices, initially not intended for this and describe the results obtained to date. So let's go.

3. Using Vernier sensors in conjunction with a VEX ARM Cortex-based microcontroller


3.1 VEX ARM Cortex-based microcontroller, or instructions for use

Designers of expert level are equipped on the basis of the VEX iron constructor, which includes the VEX ARM Cortex-based microcontroller. VEX microcontroller ARM Cortex-based is the latest microcontroller in the VEX microcontroller line. The main task of this microcontroller is to coordinate the data flow and provide power to the robot. A distinctive feature of this microcontroller is the ability to connect a wireless Wi-Fi adapter to it and the ability to organize data exchange through it using a control panel or personal computer.

VEX ARM Cortex-based Microcontroller

image

Microcontroller technical specifications:
• Power supply type: 6 AA batteries, or 7.2 V battery
• Current consumption: 150 mA
• I / O ports:
- 8 pcs. 3 wire leads for VEX drives
- 2 pcs 2 wire leads for VEX drives
- 1 pcs I2C “Smart Sensor”
- 2 pcs UART Serial Port
- 8 pcs 12-bit analog inputs
- 12 pcs digital lines
- 1 pc DAC Speaker
- 2 pcs Rx1 & Rx2
• Microcontroller:
- Type: STMicroelectronics ARM Cortex M3
- Speed: 90 MIPS
- RAM: 64Kb
- Flash : 384Kb
• Programming environment:
- easyC V4
- ROBOTC for VEX Robotics v4.x

Controller Port Layout
VEX microcontroller. View from above



VEX microcontroller. Front view.



VEX microcontroller. Back view.










3.2 What kind of beast are these Vernier sensors?

Vernier is a leader among manufacturers of sensors for measurements. Vernier is currently creating easy-to-use and accessible interfaces, sensors, and graphical analysis software. Today, Vernier produces about 60 different sensors for measuring various physical quantities. This number includes measurement sensors of both classical parameters - temperature, strength, humidity, voltage, and for very non-trivial measurements - ECG, heart rate, etc. In this example, interaction with a wide range temperature sensor (thermocouple) will be considered. The sensor is designed to measure the temperature of various objects in a very wide temperature range (- 200 to + 1400 ºС). It can be used for research in aggressive environments,

Vernier sensor for measuring temperature over a wide range



Sensor specifications:
• Measurement range: from - 200 to + 1400 ºС
• Accuracy:
- ± 5.0 ºС at a temperature from - 200 to + 1400 ºС
- ± 2.2 ºС at a temperature from 0 to + 900 ºС
- ± 15 , 0 ºС at temperatures from + 900 to + 1400 ºС
• Thermocouple type: K type
• Power supply parameters
- Current consumption: 11 mA
- Voltage: 5 V DC ± 25 mV
• Output voltage range: 0 - 4 V
• Resolution: 12 bits
• Weight: 0.12 kg
• Dimensions:
- matching device: 73 × 52 × 26 mm
- length of the sensor: 200 mm
- diameter of the sensor: 4 mm

3.3 working layout

The VEX microcontroller by default does not support the connection of Vernier sensors and so I had to come up with an adapter. It turned out to be very simple - a breadboard with a USB-UART adapter soldered on it and a connector for the Vernier analog sensor.

Board with soldered connector for Vernier sensor and adapter with USB - UART



Using this adapter, we connect our thermocouple to the microcontroller. As a result, the assembled layout is as follows:


3.4 Firmware development for microcontroller in easyC environment

Traditionally, RobotC environment is used to program VEX microcontrollers, and that is why I did not use a standard environment, but suggested developing an alternative environment for programming robotic controllers based on Intelitek's Cortex processors - EasyC.

EasyC development environment



EasyC, in fact, is a very simplified version of the C language. A distinctive feature of this environment is the ability to develop both in graphical and text mode, both of which are available in parallel. The main interface elements of this environment are the following windows:

Start Page - the start screen that appears when the environment starts. On this screen, the process of creating a new project, or the opening of the old one, takes place.
Function Block - this window contains the main function blocks for graphical programming of the microcontroller. To add a function to a block diagram, just drag it onto the block diagram and link it to other blocks.
Main- the main development window. By default, a panel with a block diagram opens. If necessary, you can switch to the C language panel by selecting the corresponding item in the Window menu .
Project Explorer - a window containing information about the current project.

When starting the easyC environment, a window appears in which we are invited to create a new project. To do this, click on the New Standalone Project , after which it is necessary to select the type of project in the window that appears - either to interact with the controller via Wi-Fi ( Joystick Project (WiFi) , or for offline operation of the controller ( Autonomous Only Project ). last type of project: by clicking OKThe Main window opens with a typical project structure.

EasyC open source development environment



Upon completion of the development to compile and download the firmware to the memory of the microcontroller it is necessary to connect the microcontroller to the PC using the included microcontroller USB-cable, wait for it to identify the system and in the menu Build and Download select Build and Download , or else press the keyboard F7 . Separately, I want to note that it is not recommended to connect the microcontroller to the USB 3.0 ports due to the possibility of errors when identifying the microcontroller with Windows. If the firmware download is completed successfully, you will see a message. After that, the controller can be disconnected from the PC. It will work autonomously with the firmware loaded in it.

Connecting a VEX microcontroller to a PC



Successful completion of firmware download



We will write the firmware for the VEX microcontroller so that later we can use it to collect data from the temperature sensor and transfer this data to the PC. The firmware works as follows: as soon as the code “110” is transmitted to the microcontroller via uart, the temperature value is read from the thermocouple. Then, through the uart, the microcontroller transmits the code “111”, which means the beginning of data transfer, and then the results are transmitted. After the transfer is completed, the microcontroller is again set to standby mode for a measurement command. I will not detail the firmware development process, as It is quite simple and does not cause problems. The result is the code shown in the figure.


The block diagram corresponding to this code is as follows:


3.5 Development of a data collection application in LabView

The task of the application is to send a command to start the measurement on the microcontroller, and then collect data received from the microcontroller. To write the application, follow these steps:
1. Create a new project in the LabVew environment.
2. Let's move on to the block diagram.
3. Place the Case Structure from the Programming - Structures palette on the block diagram .
4. Place the Visa Configure Serial Port VI element from the Instrument I / O - Serial palette on the block diagram .
5. By clicking on the VISA resource name input of the Visa Configure Serial Port VI element, right-click to create a control ( Create - Control) named COM port. Similarly to the inputs timeout , baud rate, we create constants with values: 10000 and 9200, respectively. Connect the output element Visa Configure Serial Port VI : error out to the input case Selector structure Case Structure , and VISA resource name out with boundary structure Case Structure . At this stage, we set the initialization parameters for the COM port. At this moment, the block diagram will look approximately like in the picture.



6. Add the While Loop structure from the palette inside the Case Structure to the “ No Error ” case.Programming - Structures . Inside the While Loop, place the Event Structure . Set the value 10 to the input timeout of the Event Structure .
7. Go to the Front Panel window . In this window, clicking the right mouse button, select the Blank Button (Silver) element from the Silver - Boolean - Buttons palette . Rename it to Dimension. 8. Let's go to the block diagram window. Right-click on the Event Structure and select Add Event Case . In the window that appears, select from the list of Event Sources our button - Measurement, and in the list
Events, select the value Change Value . Click OK. We transfer our measurement button inside of the case "Measure" structure of the Event Structure . Now the contents of the Event Sources structure will be executed when the Measure button is clicked . At the current stage, our block diagram looks as follows:


9. Place the Visa Write and Visa Read elements from the Instrument I / O - Serial palette inside the Event Structure . Connect the inputs of the Visa Write VISA resource name element and error inwith the terminals formed as a result of step 5. Connect the inputs of the Visa Read element with the outputs of Visa Write, respectively . To the write buffer input of the Visa Write element, let's submit an unsigned bite array with a single value of "110" converted using the Byte Array To String Function from the Programming - String - Conversion palette . To the byte count input of the Visa Read element, we give the constant “1”. The output of read buffer is connected to String To Byte Array Function from the Programming - String - Conversion palette. We will extract the first element from the resulting array using the Index Array (Programming - Array) function and check whether this element ( Programming - Comparison ) is set to "111".
10. Add the Case Structure structure from the Programming - Structures palette inside the Event Structure . Connect case Selector with the output of the equal? . At this stage, we implemented sending a command to the microcontroller and reading the response from the microcontroller, which means readiness for data transfer. At the moment, the block diagram is as follows: 11. Inside the “ True ” case of the new Case Structure


place the Visa Read element and in the same way as we did in step 9, we read 2x single-byte numbers from the buffer and convert the received data to the original value. Add a Visa Close element outside the While Loop loop and connect its inputs to the outputs of the Visa Read function by drawing wires through the boundaries of all structures.
12. Go to the Front Panel window . Similar to step 7, create a Stop button . We also add to the front panel WaveForm Chart with the name Temperature Graph from the Silver palette - Graph .
13. Let's go to the block diagram window. Connect the input of the added temperature graph to the output of the conversion result. We put the Stop button in the Timeout case of the Event Structure , and connect it to the output of the While Loop through the boundary of this structure . Make sure there are no breaks in the conductors in the block diagram.









At this block diagram is ready. The front panel of the resulting application should look something like the following figure:


3.6 Measurement process

Calibration must be performed before taking measurements. We will carry out calibration near zero degrees. We denote the calibration coefficient K. Then, K = 174.17-T0, where T0 is the value obtained from the thermocouple at 0 С.
Then the real temperature value will be calculated by the formula:
T = ((T '+ K) ∙ 159100-27710000) / 100000 ,
where T '- value obtained from the thermocouple.
Add this formula to the block diagram:


The program is fully operational. The results are presented below in the figures. Coefficient K = 50.17.

10 successive starts at room temperature



10 successive starts when the thermocouple is in hot tea and after removing the thermocouple from it



12 consecutive starts when the thermocouple is in water cooled in the freezer but not frozen yet.



3.7 Подведение итогов

Based on the materials presented here, laboratory work was developed for students of the Department of RK10 of the Faculty of Robotics and Integrated Automation as additional, optional classes. The very idea and laboratory work was positively received at the department by both teachers and students, primarily those who lacked standard sensors in working on their course and bachelor projects, but, in connection with the latest cathedral events, completed this work only several people - mainly 3rd and 4th year students. In the process of its implementation, students proposed ideas for its development and improvement, which to date, in connection with the dissolution of the Department of RK10, have not been implemented. At present, I plan to adapt this work for schoolchildren,

4. Using a mobile phone as the basis for technical vision.


Typically, robotic designers primarily include various sensors - rangefinders, photosensors, gyroscopes. But rarely, when a set includes systems for organizing technical vision, and in connection with this, I had the idea of ​​using each mobile phone available as the basis for a technical vision system. The idea is this: the phone is connected via Wi-Fi to a PC, where a program written in LabView uses the phone’s camera as a web camera.

4.1 How was this implemented?

As a camera, I used a phone with an apple on the logo, installing Senstic's PocketCam application on it. There are both free and paid versions of this application in the AppStore. They differ in that the free version broadcasts the picture in black and white, as well as the lack of sound transmission. Then on the PC, I installed the PocketControl application, which emulated a webcam connected to the PC.



Then, using LabView with NI Vision installed, it was possible to connect to this emulated camera without problems and start grabbing video.



As you can see, the picture is transmitted in a resolution of 640x480 with a frequency of 30 frames per second. Autofocus also works. But I want to note one interesting point - this permission can only be achieved if Windows 8.1 is used. An attempt to repeat the same thing on Win7 leads to the broadcasting of a picture in the resolution of 320x240 and strong “friezes”. What may be the matter, I still do not understand - if you have any suggestions or have encountered something like that, please write in the comments. As a result, we get a simple solution for organizing technical vision.



4.2 How to use it

At the last summer physics and mathematics school of innovative projects “Creation of the Future” Link, I invited one of my students, a tenth grader, to come up with a project where a similar approach could be applied. As a result, the project “Robot Researcher with Remote Control over ZigBee Channel” was born. The result of this project was a mock-up of a robot that was controlled in a semi-automatic mode - the operator sets the destination point from the computer and the robot transmits the video image during movement, as well as circling obstacles. Also, in the process of movement, the ZigBee robot transmits data about its state (direction of movement, presence of an obstacle). This was realized on the basis of a professional-level designer, namely a two-wheeled machine from Bioloid Stem.



The control program was developed on LabView based on examples that I described in detail in my first LabView post in robotics - creating a SCADA system for controlling a robot . The result was the following (the program was developed by the student practically without the intervention of a teacher):



I intentionally did not make any changes either to the interface or to the program code, in order to show how simple and quick (the project took 3 days) a student who did not have any programming experience can master the basic principles of development in LabView (after short two-hour courses). Part of the code is shown in the figure below.



It seems to me that for a student who did not have experience in programming, this is an excellent result.

5. Conclusion


The issue of expanding the robotic designer in the process of its development becomes more and more relevant over time. In this article, I suggested 2 options for a non-standard approach to expanding the capabilities of the designer by using LabView and third-party devices. I hope that this information is useful to someone in the implementation of their ideas and projects. Thanks for attention)

Also popular now: