Project VROOM Electrical Documentation v2
Project VROOM Electrical Documentation v2
Terminology
Below is a collection of relevant terminology, descriptions and tips concerning the electrical and software
design of the Virtual Reality Bike:
Microcontroller – Small electronic device that can control various devices (like our actuator and fans)
by varying voltages on the device. For this project, we used two microcontrollers. These controllers are
Arduino UNOs.
Motor Controller – Although a microcontroller can control the “logic” of a circuit (e.g. turning off and
on something), some circuits require larger amounts of power to be able to turn devices on and off. A
motor controller is a specific type of controller that can harness high power sources (such as our external
battery used to power the actuator) and be able to channel that power into devices.
• In our actuator circuit, we use a motor controller to interface between an Arduino UNO, external
power supply and our actuator. While the Arduino takes care of our “logic” in this circuit, the
motor controller acts as an intermediate device which can accommodate the actuator’s need for a
larger power intake.
Duty Cycle – Since the actuator works via an electric motor, when it’s in use, it produces heat as a
byproduct. The longer the actuator runs, the more heat it produces, increasing its chances of overheating.
A duty cycle is a percentage that informs an end-user about how long a piece of equipment should be
powered relative to the amount of time that the equipment needs to be powered off to ensure proper
behavior.
• The actuator used for the bike has a 25% duty cycle, which means that for every 25% of the time
it is running, it needs to be powered off for 75% of the time: a ratio of 1:3
• The two original games produced for the bike have a duration of 2 minutes (our ride cycle). It
was assumed that the actuator would be powered for this entire 2 minutes, so therefore, the
actuator was required to be powered off for 6 minutes after each ride cycle.
1
• During the spring of 2019, a conversation was had with an engineer from ServoCity (the
manufacturer of the electric actuator we used for this project) to discuss whether the load
of our rider would affect the rated duty cycle. The engineer was confident that the
actuator could handle the load we presented and suggested that the duty cycle could even
be exceeded without our current use case.
Transducer - a device that converts variations in a physical quantity, such as pressure or brightness,
into an electrical signal, or vice versa.
• In this project, the electric throttle, buttons, and fans can be considered transducers:
o The electric throttle converts rotational motion into an electrical signal.
o The buttons convert achieving a certain pressure threshold into an electrical signal.
o The fans use an electrical power supply to stimulate the rotational of blades which
produce wind.
Relay – a collection of switches that can open and close electromechanically or electrically. If a certain
component needs a higher power supply than a microcontroller can provide, but you would like to still
control the time at which this component is powered, a relay is commonly used.
• In this project, the fans were originally controlled using a relay. The relay design was abandoned
when the VR Bike traveled to SIGGRAPH 2019 because the relays were damaged. The fan
circuit omits the implementation of relays.
Interrupt – an input signal to a processor indicating that a certain event that needs immediate attention.
An interrupt signal stops the currently executing code and executes the event in a timely manner.
Serial (UART) Communication – the process of sending data one bit at a time, sequentially, over a
communication channel. Serial communication is the most common form of communication used by
microcontroller beginners. SparkFun has an article that explores serial communication more closely.
Inter-Integrated Circuit Protocol (𝑰𝟐 𝑪) – a serial protocol for two-wire interface to connect low-
speed devices in communication systems. Because an Arduino UNO is only able to establish one UART
connection at a time, 𝐼 2 𝐶 was investigated and ultimately used in the project in the event a single Arduino
UNO needed to communicate to two controllers at the same time. This functionally was ultimately not
needed, but the 𝐼 2 𝐶 was still used as the serial protocol between the Arduino UNO and motor controller
in the actuator circuit.
Arduino UNO – An open-source microcontroller board developed by Arduino.cc. The board has 14
digital I/O pins, 6 analog I/O pins, and is programmable with the Arduino IDE (Integrated Development
Environment).
2
8" Stroke 560 lb Thrust Super Duty Linear Actuator
Bill of Materials
Item Price Quantity Link Total Price
Arduino UNO 22.00 2 Link 44.00
Pololu High-Power
Simple Motor Controller
G2 18v25
KMISS Electric Throttle Link
3.5MM Terminal Block 2.50 2 Link 5.00
Ablenet Spec Switch 65.00 2 Link 130.00
Uphere 3 Pack of 12.99 1 Link 12.99
Computer Fans
2.4 A Wall Charger 6.99 1 Link 6.99
400 W Switching Power 79.99 1 Link 79.99
Supply
3
Wiring Diagrams
4
Figure 2. Fan Circuit
5
Figure 3. Actuator Circuit
6
immediately call a function that stops the actuator when the emergency button is pressed, it is necessary
to implement an “interrupt” within the software of these programs. Interrupt designs for Arduino UNOs
are well documented at: https://www.arduino.cc/reference/en/language/functions/external-
interrupts/attachinterrupt/
The 1st step in implementing an interrupt in software is to create a function known as an Interrupt
Service Routine (ISR) which has the sole purpose of stopping the actuator. Below is the ISR function in
both original actuator scripts:
7
back to zero when triggered, so the emergency stop button is purely used to stop future haptic feedback
responses from the actuator.
8
Figure 7. HiveJive script with “breaker” variable highlighted
As was mentioned at the beginning of this section, a hardware accommodation is needed to make use of
interrupts on the Arduino UNO. In order to use interrupts and cater to instantaneous requests, it is
necessary to utilize one of two “interrupt” digital pins on the Arduino UNO when creating the emergency
button circuit. Digital pins 2 and 3 are declared as usable for interrupts according to the Arduino.cc
reference material.
9
It’s important to mention that the fundamental goal at hand is to use a linear actuator to enhance the
sensation of pitch created within a virtual environment by physically moving a patron. The critical
component at play is syncing the pitch created by the actuator with the environment in the digital world.
It’s imperative to approach design with the linear actuator from this angle because the actuator can be
used to mimic a limitless number of vertical sensations depending on the speed and timing constraints
provided to the actuator controllers. Therefore, it is crucial to understand that although the methods I’m
about to describe to program the linear actuator are the ones the original SIGGRAPH group settled on,
there are a myriad of other ways to exploit the sensation of pitch in the virtual world.
As was mentioned when discussing the actuator circuit design, a motor controller is needed to handle the
25 amp, 30-volt power supply necessary to power the actuator. Since it was imperative to our design to
incorporate an emergency stop button, it was decided that an Arduino UNO would be implemented
alongside the motor controller to handle the logic associated with the emergency stop button. Therefore, it
was a necessity for both the Arduino UNO and Pololu motor controller to communicate with each other.
A common serial protocol used to communicate between multiple controllers is serial communication.
Although serial communication is
10
Neutral Actuator Function
11
12
Explanation of Button and Throttle Scripts
On the VR Bike, there exist six devices which can be separated into two categories:
1. Game Input Devices
2. Haptic Feedback Devices
The “game input devices” allow the patron to directly effect the game enviornment by interacting with
them. On the VR Bike, the “game input devices” include the electric throttle and the two large buttons.
The “haptic feedback devices” are non-user controlled, and are used to provide the patron with both
immersion and spatial awarness. The “haptic feedback devices” include the three computer fans mounted
on the front of the bike.
As was described earlier, there exists three “game input devices” on the VR Bike that can be utilized to
give a patron the ability to change the game enviornment: the electric throttle and the two large buttons on
the handlebar. Since the goal of these devices is to allow the user to alter something within the VR game,
it was necessary to establish a connection between a microcontroller and the Unity game project.
To do this, a C++ script was created and loaded onto an Arduino UNO which categorized the electrical
signals from these devices and stored them into variables. Once stored, these variables can then be
shipped off to a C# Unity script via serial communication for the game developer’s use. Below is a
summary of both the C++ and C# scripts:
13
transmission rate. If you wish for a game element to respond more instantanouesly to a button press or a
change of the throttle, increase the baud rate. If the baud rate is increased too high, however, transmission
errors will result. Below is a figure of the initial setup:
Figure 11.
The remainder of the C++ script is comprised of three functions which are responsible for sending the two
button and throttle values to the C# Unity script. Figure 12 below features the first two functions:
“SendLeftButtonData()” and “SendRightButtonData().” Both these functions read the value of the
respective digital pins each button is attached to, saves that value as a variable, and then prints the value
on the serial monitor which was initialized earlier.
14
Figure 12.
The “SendThrottleData()” function in Figure 13 is slightly more complex because the throttle is an analog
device. In this function, the analog pin that the throttle data wire is attached to is read and saved as a
variable. Once saved, this variable is checked against the maximum and minimum most values the throttle
is capable of outputting. Note that these maximum and minimum values were determined through testing.
Once it’s determined that the analog value falls within our expected range, that value is then mapped to a
more Unity friendly range of -360 to 360. Note that is “mapping” function can be altered to fit the needs
of user, but -360 to 360 tended to work for the original project. Finally, simiarly to the button functions,
the mapped throttle value is printed on the serial monitor. If the mapped throttle falls outside of range of -
360 to 360, the last valid mapped throttle value is printed on the serial monitor.
Figure 13.
The last section of the C++ script involves calling the above functions in the “loop()” function featured in
Figure 14. There are two important pieces of information to note within the “loop()” function: Firstly, the
15
order in which these functions are being called is important. Looking back at the top of Figure 11 and
within the “SendLeftButtonData()” function of Figure 12, there exists a constant titled “OUR_VAR”
which is assigned the character ‘R’. Each time the C++ script completes all three functions, a single string
of values is printed on the serial port, starting with this ‘R’ character. This character is used to help the C#
script identify when a new set of button and throttle values arrive. An example of the output of the serial
port after a single “loop()” execution is as follows:
R0:35:1
The second important piece of the “loop()” function is the intentional delay. A delay of 16.6 milliseconds
is needed to ensure that the only 60 unique strings will be printed on the serial monitor per second. The
Unity project for the original VR Bike ran at 60 frames per second, so therefore, if more than 60 strings
were printed, certain lines would be omitted when read by the C# Unity script. I don’t believe it’s the end
of world if more than 60 strings are printed per second, but there’s no use in pursuing faster computation
than necessary.
Figure 14.
16
Regardless of the method used to program the linear actuator, it is important to understand the 1st line of
C++ program includes the syntax “#include <Wire.h>.” This line configures the Arduino UNO to
communicate with 𝐼 2 𝐶 devices. For more information on the Arduino Wire library, please see
https://www.arduino.cc/en/reference/wire.
The next section of the program declares and initializes constants and variables. The 2nd constant,
“smcDeviceNumber,” is a mandatory constant needed to communicate with the motor controller. The
volatile variables pertain to the emergency stop button; the “Emergency Stop Button Design” section
gives further explanation concerning these variables.
Fans:
• Come with a 4-pin and a 3-pin interface
• “Okay” to snip off 4-pin interface
• Only utilize the right two pins on the 3-pin interface
Reference Materials
1. For more information on the Arduino “Wire” library:
17