Electrical Subsytem

& Firmware Integration

Circuit Diagram

Connecting the Arduino to the Ultrasonic Distance sensor and Motor Shield in order to control the VRCar.

Key Components

The parts that make up the Electrical and Firmware Subsystems

Motor Control code

The robot's motors are controlled by an Arduino and a shield. This follows what data the PC connected to the controller is sending it

more
Ultrasonic Sensors

Make sure that the VRCar doesn't bump into anything! When it gets near a wall or object, the VRCar will back up accordingly.

more
Remote control

Xbox ONE Control inputs are taken in and sent out as motor speed data over serial to the Arduino, using Python scripts. 

more
ELECTRICAL SUBSYSTEM

Ultrasonic Sensors

Making sure that the VRCar doesn't bump into any walls or objects.

We wanted to be sure that while the driver has full control over the car, the driver won't be able to ram it into a wall and break all the parts. To avoid this, we added distance sensors and code to move the car away from obstacles automatically if the car is within 5 cm. The main concern was the front and back distances as they would impact the car the most. The left and right sides are less likely to get stuck in the first place and would be easier for the driver to move, but are equally dangerous to get stuck in. We decided to use ultrasonic sensors as our distance sensor because IR sensors do not give accurate enough readings under changing light conditions or small distances. 


The serial communication we opted for made the car very tethered, which goes against our design goal of being able to drive the car around. We decided to add in batteries and a telemetry unit so that the car can be wire free. We added batteries to power the Arduino and the motor shield. We were worried the battery for the motor shield might overload the shield so we added a variable resistor to the circuit.

FIRMWARE SUBSYSTEM

Remote Motor Control

For the code, please refer to this GitHub Link.

For the firmware, we were able to code the Pro Xbox ONE controller by using the inputs library. We defined a set list of inputs we wanted to use from the Xbox controller, and prepared them as inputs to be translated into motor speed data. The list of possible inputs were then used to be translated into data to be turned into motor speeds. 

Xbox Controller Inputs:

SOURCE: Diagram of Xbox ONE Controller to Refer to for Inputs

Forewards and Backwards

One of the big issues regarding the original controller code was that we can not move backwards. We adjusted the inputs on the Arduino code for negative values and we were able to remember the last direction the car went using lastDirection and currentDirection variables. It was important because the car would jitter if we setDirection too frequently, so it is crucial to set the direction as few times as possible to make sure the code runs smoothly. 

Codeblock for Arduino Motor Control

Implementation with Ultrasonic Sensors and millis()

The sensor code was also interesting to set up. Usually, most ultrasonic sensor codes use delay in their code. While they usually only last for milliseconds, it is still enough to stop the code from running and experience serious stuttering. We used a milis() based sensor code where the delay is 10 microseconds, which should be negligible. 

Codeblock for Integrating Distance Data with Speed 

Telemetry for the PC to Arduino Serial

To eliminate the restrictions of cables from our VR car, we also approached wireless communications from the Arduino Uno that was embedded on the VR Car to the computer. To set up our telemetry parts, we initially used the 915 MHz radio modules that are widely believed to be powerful and stable. However, as the 915 MHz radio modules usually work for Ardupilots such as Pixhawk, we found out that it was not quite compatible with our chosen microcontroller Arduino Uno R3. Therefore, we switched to a pair of two nRF24L01+PA+LNA radio modules that are more adaptable with our microcontroller.

Given that this was an extended goal, we did not complete this part. This portion was not integral to our systems, although it would've been super nice to have. If you would like to see what was attempted through code, follow this GitHub Link.

Diagram of Arduino Wiring to Telemetry Radio Reciever