Tuesday, July 25, 2017

Spartan Superway 2017 Summer - Week 8

July 17 - July 21

This week was spent assembling the second bogie and connect the second DC motor and stepper motor to the relays and Arduino. I noticed some wires didn't have good connections on H-bridge circuit, and I had to fix them by checking how the connections were supposed to work through the Arduino. For example, 8 wires from 8 pins on the arduino didn't match up to the appropriate relay inputs. I had to shift the outputs from the ULN 2803A Darlington Transistor Array to match the inputs on the relay board.

Also during this week, I constructed a circuit to regulate voltage taken from the batter/wayside power into 5V for the Arduino (Figure 2). I used R1 = 470 Ohms and R2 = 1.5k Ohms.

This is my last week and my last day is Tuesday, July 25, 2017. Monday and Tuesday will be spent continuing debugging the assembled bogie with steering and propulsion/braking system.

Figure 1. SainSmart Relays H-bridge (From Google Images)

Figure 2. From LM317 Datasheet

Monday, July 17, 2017

Spartan Superway 2017 Summer - Week 7

July 10 - July 14

This week, I spent most of the time reviewing the code to make sure it works properly. I didn't start designing a 3D printed case because another intern was assigned to do it. On friday, we started to assemble the bogie and test the code on the already assembled bogie. However, we ran into a couple of problems during testing.

When we ran the code without turning on the AC/DC converter, the code ran as expected. When we plugged in the AC/DC converter, the hall effect sensor triggered the interrupt when there wasn't a magnet present. We suspect it was due to interference coming from the relay, converter, bad wires, or the motors. It created a lot of frustration, and took us all day to try and figure out what was wrong. At the end of the day, we cleaned up the shop and made it tidy for the Automotive Open on Monday.

Next week, we will finish assembling the bogies and try to test them on the track. Hopefully we can also fix the hall effect sensor problem as soon as possible.

Saturday, July 8, 2017

Spartan Superway 2017 Summer - Week 6

July 5 - July 7

This week, I finished soldering the hall effect sensor circuit to a small protoboard which will be easily attached to the body of the bogie using double sided tape. Then I started planning out how to get power from the LCD shield of the Arduino to power the low pass filters of the eight switches, the hall effect sensor, and the 9 degrees of freedom (DOF) accelerometer-gyrocsope. The accelerometer-gyrscope sensor will be used for correcting the tilt of the bogie on sloped tracks.

At first, just attaching two more wires from the 5V and GND pins to the LCD shield caused a cold joint and the shield didn't turn on. Then I decided to attach wires from the switch-protoboard to the hall effect sensor, and it worked better. Next, I'll attach wires from the 3.3V pin of the Arduino-LCD shield to power the accelerometer-gyroscope. 

Also, I learned how to use the accelerometer-gyroscope by using the analog pins to read the signals the accelerometer sends in the X, Y, and Z axis. From these signals, I found an equation online to convert the raw data into degrees of how far the sensor is tilting. Afterwards, I used the new values in conditional if statements to show the instructions to be executed at certain angles. At certain ranges of degrees, the Arduino will turn on specific LEDs to represent the instructions. What we expect the Arduino to do is that it will continuously read the sensor. Then, if the Arduino reads a change in degrees or if the degrees isn't nearly zero, it will turn on the DC motor of the tilting mechanism until the sensor says zero again. 

Next week, the team should be building a test rig to demonstrate the tilting system and debugging the code to make sure it works correctly. 

Friday, June 30, 2017

Spartan Superway 2017 Summer - Week 5

June 26 - June 30

This week, I fine tuned the code for running the bogie. I put the steering code into the magnet interrupt so that the bogie will switch/steer itself right away, once the magnet is detected. For the future, the timing of the bogie running forward/reverse has to be calibrated for the track. Such that the bogie has enough time to go up the slope, reach the magnet, switch, go across the top track, reach the other magnet, switch, and go down the slope. Ideally, we would want the bogie to do everything without having to hardcode the delays for going to its positions. For example, we have the bogie moving forward for 10 seconds, and we hope it encounters the magnet once it's at the junction. Then it will switch and move backwards on the top track for 20 seconds, and etc.

Also, I soldered the low pass filters to a protoboard so we don't have to use a large breadboard anymore. The smaller protoboard makes the electronics neater and we can easily position the protoboard anywhere that's convenient for us. Next week, I will solder the hall effect sensor circuit to a small protoboard.

Currently, the 1/2 scale team is waiting for parts to be machined before we can start assembling the two bogies and running tests on the track with it.
I will continue to do improvements on the electronics and hopefully design/print a 3D printed case for them.

Friday, June 23, 2017

Spartan Superway 2017 Summer - Week 4

June 19 - June 23

This week, I completed the code for using eight limit switches and the hall effect sensor. I uploaded the code to our team's github, and then Joey used the code in his test rig. The test rig consists of 2 small DC motors, a small stepper motor, eight limit switches, and a hall effect sensor. The test rig will help us debug the code to make sure it'll definitely work on the completed bogie. Joey continued to make necessary changes to the code, and I helped him adjust the code to achieve what we expect the bogie to do.

However, the new code is having trouble with the timing and conditions for steering/activating the stepper motor. The stepper motor moves when it's not supposed to when certain limit switches are pressed. We will continue working on the code next week, and hopefully fix all the problems. After the code is finished, we will test the code on the actual stepper and dc motor for the bogie. 

In the future, we are expecting to receive a rotary encoder which will be used to map the track. Hopefully it will help in initiating steering at very precise locations. 

Friday, June 16, 2017

Spartan Superway 2017 Summer - Week 3

June 12 - June 16

This week, I learned how to properly wire the limit switches such that they won't accidentally affect the Hall Effect sensor. What happened was that when a switch was pressed, the signal it generated bounced from 5V to 0V in a couple milliseconds. The I/O pins on the arduino are sensitive to that change, and the bouncing signal can trigger the interrupt pin connected to the Hall Effect Sensor. 

In order to debounce the signal, I had to attach an RC circuit to the COM pin of the limit switches. With a resistor of 100k Ohms and a capacitor of .1uF, it would stabilize the signal for 10ms. This was enough time for the signal to be stable and not trigger the interrupt. 
From there, I continued testing the limit switches to make sure they worked correctly and then soldered jumper cables to the pins for easier and consistent placement on the arduino and breadboard. 

With the team, we discussed about the braking system and failsafe system. These systems are important for the safety of the passengers in case of emergencies. Next week, we will continue looking into different ways we can implement braking and preventing the bogie from falling off during switching.

Friday, June 9, 2017

Spartan Superway 2017 Summer - Week 2

June 5 - June 9

This week, I started testing the hall effect sensor in the main code for running the bogie. The interrupt created by the sensor worked half of the time. This was due to the fact that there were too many delay functions in the code. The delay function in the arduino IDE is a blocking function, which means that as long as the delay is running in milliseconds, everything else on the processor is waiting. Although interrupts are supposed to work during delay(), I observed that the variable in charge of detecting the magnet didn't change all the time.

To solve this, I replaced most of the delays (longer than 2 seconds) with if statements. These if statements did quick calculations of the time without holding up other processes and allowed optimization of the timing of the codes. However, another problem came up with the LCD keyboard shield and the Arduino Mega.

When the right button is pressed, it changed the variable that represented a magnet was detected, even though there wasn't a magnet present. This is problem for the switching mechanism because the arduino won't properly know if it's supposed to switch the steering arms or not. However, this isn't a big problem as long as we do not use the manual mode with switching. For example, we only manually drive the bogie up the sloped track, and back down the sloped track.

Finally, I found limit switches in the shop, and started testing them and learning how to wire them correctly. Next week I will connect all eight limit switches and check if they change the booleans of the steering arms. These booleans check if the right or left arm is properly engaged when either all right or left switches are pressed. When the booleans are checked and the magnet is sensed, then the stepper motor will turn the arms in their correct position. In the future, I need to check the pin connections from the arduino to the H-bridges in order to control the motors correctly.

Friday, June 2, 2017

Spartan Superway 2017 Summer - Week 1

This summer, my partner, Adhi, and I are working on the mechatronics for the 1/2 scale bogie. The mechatronics for the bogie involve using an arduino to control the two DC motors and two stepper motors. The DC motors are for moving along the track and the stepper motors are used to control the steering and switching mechanisms. The last team successfully built the 1/2 scale bogie and demonstrated it at Maker Faire. This summer, we have to improve the code and simplify the electronics.

For the first week, May 31-June 2, we read up on the last team's final report and future recommendations, and then we brainstormed improvements and additional requirements. Starting with the old code, we realized that switching hasn't been implemented yet. To steer the bogie onto its intended track in a timely manner, we thought about using Hall Effect Sensors. I started researching about Hall Effect Sensors and found an example online that detects a magnet and another one that reads the strength of a magnet. By detecting the magnet, we can send an interrupt to the arduino and initiate the stepper motors to steer the bogie.

However, the last year's team warned us about the arms of the steering not pressing limit switches on the bogie. The limit switches are there so the arms don't go too far and to check if the arms are properly engaged. Since the arms weren't always parallel to press the switch, the drive shaft used for one of the stepper motors continued turning, and eventually bent. Therefore, my partner and I decided we should add six more limit switches and code for the bogie to stop if the proper switches aren't pressed before switching.

Finally, my partner and I are researching motor driver ICs to replace some of the relays and H-bridges built by the previous team. This will decrease the size and wires of the electronics.

Next week, I will work on the code and testing the hall effect sensor more. In the near future, we will start testing the improved code with the motors, switches, and sensors.