Group assignment: compare as many tool options as possible.

Individual assignment: write an application that interfaces a user with an input &/or output device that you made.

1. Group assignment

Go to the Sedicupct website

2. Individual Assignment

2.1 Final project interface with Unity

This week I have made an interface in Unity for my final Project. I have created a virtual scene where the movement of the platform (pitch) is simulated, depending on the angle of inclination, the linear actuator will be activated until reaching the real angle of the platform obtained with an MPU6050 inclination sensor. When the virtual angle and real angle are equal, the desired angle will be reached and the actuator will stop.

I have used my boardATtiny3216 that I built in week 13 "Networking and communications".

To control the motor use the pololu shield (VNH5019) from week 12 "Output Devices".

The actuator I'm going to use is the RS Electric Linear Actuator from week 12 "Output Devices".

To measure the real angle of inclination use the MPU6050 sensor from week 10 "Input Devices" .

Communication between Unity and the board is done through the USB port. I use the Arduino IDE to program the ATtiny3216 board and to test communication with the computer's serial port.

I create an Arduino program to send the motor speed data from the ATtiny3216 board to Unity only to display the speed value on the interface.

I have tried MPU6050 libraries but they only work with Arduino ATmega microcontrollers and for ATtiny microcontrollers I found the following MPU6050_light library.

Open Arduino IDE - Library Manager and put MPU6050 in the browser. Download the MPU_light Library.

I open the example to test that the MPU6050 works with the ATtiny3216.

I link the GetAngle example with the motor control program I have, I will only need the angle in Y.

I compile the program and open the serial port to see the two angle data of the MPU6050 and the speed of the motor.

I create a scene in Unity to control the movement of the platform. With an Up button I go up one degree each time I click, and with the Button_Down I go down one degree. In addition, the real angle of the MPU6050, the virtual angle of the platform in Unity and the motor speed are displayed. Each time you click on the buttons, the platform will move, modifying the angle of inclination in the Y axis. In addition, the motor will be activated by moving the rod until the angle value of the mpu6050 reaches the virtual value of the Unity platform.

In week 2 Computer-Aided Design I designed the models of the platform and the electric scooter. Also create a project in Unity to make the animations the movement of the two objects. I'll use this project to get started with the interface. (Unity Files / ElectricScooer (Unity Project).

First I create a basic interface in Unity where the actuator drive speed value is displayed.

Now I am going to create the interface with buttons and the MPU6050 Real Angle, Virtual Angle and Velocity variables.

I made a script to program the communication between Unity and Arduino and get the Angles and speed values. In addition, the variables and their operation are programmed within the logic of the program.

First I am going to perform the movement of the platform manually. I change the values ​​of gameobject in its transform (rotation Y). By varying these values, the platform model goes up and down. In addition, the tilt value is sent to the ATtiny3216 board to drive the motor.

Now the actuation is carried out by means of the "UP" and "Down" buttons. When any of these buttons is pressed, the platform model in its "rotation Y" transform is increased or decreased by 1 degree.

To create the .exe file (executable). Click on File / Build Settings ...

Create a folder where the .exe file will be saved.

Open the .exe and the application will start.

4. Conclusions of the week

How was the week?

This week I have started with the interface of my final project, a first step is a basic interface where I can control the inclination of the platform by controlling the electrical actuation. I have used the Unity software to create the interface since I have experience in developing virtual reality applications with this game engine.

What went wrong ?

In week 10 input devices I had already used the MPU6050 sensor with my ATmega328 board and it worked perfectly with the MPU6050 library, but with my ATtiny3216 board it does not work and does not compile, I have tried with another MPU6050_light library and it works very well, also the example of that library obtains the initial value of mpu6050 and calibrates it as the 0 of the axis.

What went well?

First I tried in the interface to send a data from the board to Unity, then I made a bidirectional communication between the board and Unity to provide feedback at all times the real vs real inclination values..

What will you do different next time

I would like to interface with Unreal Engine, which is another video game engine like Unity, so I could compare and analyze the advantages and disadvantages of each program.

2.6 My files

Arduino programming and Unity interface

ControlMotorVNH5019_Without Library_BoardArduinoATtiny3216