Monday, November 27, 2017

24 October '17- Day 17- Pointers in function references & Joystick and robot car

Day 17 of class began with the lab involving the use of a joystick to control the robocar we had worked on previous to utilize a motor control board.  once both motors were hooked up to the drive line on the car it was a simple task to connect the wires to the motor control board.  The tricky part became trying to figure out which wire was going to move the motors in unison or opposite directions.  A little bit of testing out each motor by applying a voltage for a short moment, we took note of the direction of the motor spinning in order to hook them up correctly.
After ab we began lecture which introduced then use of pointer in function references.  Character strings were also discussed and how they can used in cryptography and pattern recognition software.

(screen shot of the code for the motor controller)

(the over head view of the robocar and components)

(close up of joystick connections to line up the correct wire color code on the arduino board)

(First getting one motor to work using the motor control board; also the motor controller we used is different)

(close up of breadboard with one motor control by the potentiometer)

26 October '17- Day 18_ Bluetooth wireless connection & Dynamic memory allocation

Day 18.  The class began with the overall excitement to learn about blue tooth connectivity with Arduino.  A few student additions ,from days of past, came into the class to learn of this so called bluetooth magic.  The Lab included the bluetooth shield we were to work on and get connected with via our laptop or smartphone.  This task was no small feat.  Since everyone in the class was trying to connect to their bluetooth Arduino shield, it became a fiasco to figure out whose board belong to whom in the slue of identical device names.  Some were more successful than other when it came to identifying the correct devices and only one or two groups were successful in renaming their devices.  As the lab went on, certain students fell onto dark times as they were unable to ultimately crack the davinci code for their bluetooth lab.  The professor of the dark arts, Sir Martin Mason, began to instruct on how to properly utilize dynamic memory allocation in our C programming for the class.  This became a vital process as to run a program with not enough memory available could cause it not to run.  it can also optimize the amount of run time the program would need to complete what ever process we assign it.
(the arduino bluetooth shield connected including the lcd screen for the project)
 

Wednesday, November 15, 2017

17 October '17- Day 15- Higher dimensional arrays and pointers

Beginning of class we were introduced to higher dimensional arrays and pointers.  most engineering problems can be solved using 1 or 2 dimensional arrays but on occasion a 3 dimensional array can be useful.  We also began discussion on addresses and pointer in C.  An address is a specific integer value to specify the memory location.   in order to properly utilize this feature we must move away from using repl.it and use a compiler that we can use offline.  Virtual-C IDE is one example of a downloadable compiler from the many out there.
Once an offline compiler has been installed, using pointer to reference memory locations is much more reliable.  The overall advantage to using pointers in a program is to optimize the speed at which the program runs and use less memory.
(example showing the Virtual-C IDE program and a sample code using pointers.)
In Lab we began discussion on how to wire up and control a c motor using a potentiometer.  The POT value in the middle would stop the motor and turning the POT to the left or right would speed up the motor in that direction.  Certain precautions must be made to protect the Arduino board since the pins are not designed to run a dc motor so having protection diodes and a secondary power source to run the motor are necessary.  

(Lab using a potentiometer to control the direction of the spinning dc motor)
(mounted dc motor on the robocar chassis)









Monday, November 13, 2017

19 October '17- Day 16- H-Bridge and and Motor Driver

The class began with Mason introducing our lab for the day.  The lab was to be able to control a motor using an H-bridge controller.  Named so because the diagram of the switches looks similar to the letter H.  The h-bridge controller allows you to control a dc motor and be able to reverse its direction with a command to close 2 diagonally located switches and vice versa for forward movement.  The L9110s is another type of motor controller but allows to connect two dc motors on the same shield as opposed to the single motor controller.  L9110s also is more affordable and convenient with the terminal blocks on the board instead of having to solder directly to the board.  


(diagram of L9110s, the power and ground are connected where the motor inputs should go)
(wired up one motor with the single motor controller and a potentiometer to control the spinning direction of the motor)
(An L9110s installed on robocar with two dc motors and joystick to control movement in every direction)

After Lab we began discussion about pointers and how they're used in C.  A pointer is a variable containing the address of another variable.  Plain and simple, these pointers are used to run programs faster and use less memory.  Pointers are also utilized to allocate memory for an array at future usage.  

(examples on how pointers and arrays work together)
(more examples of pointers)

(more pointer examples)

05 October '17-Day 12- Virtual-C IDE and LCD shield for Arduino

Class began with the new lab and Professor Mason introduced the LCD shield for the Arduino board.  The LCD consists of 16 column and 2 rows to display characters on and also has buttons built in that can be programmed to your liking.  The potentiometer at the top right corner of the board is to adjust the contrast of the screen.  The data pins 4-7 are used to transmit data.  Using the LiquidCrystal.h library allows the user to use set functions to make it user friendly and easy to interface.

(LCD displaying Engr-6 and increasing progress bar)



(a snap shot of the code for using the LCD in lab)

After messing with the LCD screen, we went on to talk about data files in lecture.  Data files allow you the ability of analyzing large data sets and store the information on a file that the program can access.  Utilizing an online compiler like Repl.it won't allow the creating and storing of data files since its in a directory the program may not have access to.  Using an IDE like Virtual-C allows the user to create and store data files locally for ease of access.  In order to access data files you must use a pointer "*" to reference the file in the program.  A pointer is a variable whose value is the memory address of another variable, like the memory address.  Reading data files is fairly straight forward with calling to them by name and with an "fopen" statement to associate the file with its pointer.  

10 October '17- Day 13- I2C Bus

Class began with Mason introducing the I2C bus and it features. This communication protocol was invented in the 80s and became a standard in the industry by the 90s.  The I2C bus is controlled by a master device (such as the Arduino) and talk to one or more slave devices utilizing only two input and output pins.  Each slave device has a unique address that can be called on by the master in order to communicate with that specific slave device.  This allows for many slave devices to be called upon via the same master device.

After the brief introduction into the I2C we began lecture with two dimensional arrays.  in the C language we can include data that is in a grid or table setup.  Rows begin with 0 as the first horizontal grouping and columns are the vertical groupings of data.  A good implementation of two dimensional arrays is for terrain navigation.  a value is representing an elevation on a terrain and an indication of a peak or valley can be identified by a large differentiation of values surrounding any given point.  Peaks are represented by a large value and valleys are depicted with lower values.  For homework we were to write a program that will read the data file for elevation and then print out the number of peaks and their locations.  
(White board exercises on two dimensional arrays)

(more exercises going over two dimensional arrays)

Friday, October 27, 2017

03 October '17 Day 11 - Sorting, Searching, Statistics & Serial IO: Controlling micro from PC

Beginning of class we went over the notes from day 10 on one dimensional arrays.  We then began discussion on two and three dimensional arrays and how to read them from given values using some hand examples on the whiteboard.  Mason introduced a new compiler that we can download and be able to start write to our own files.  Virtual-C is one of many compilers available online for use on personal computers.  Learning how to write to files in C has very similar syntax to printf and scarf.  Only difference is the addition of the letter "f" in front to call to the file.  Same goes for opening and closing the file with "fopen" & "fclose".  For homework we were assigned to write a program that would print out data from a weather balloon.  The program would store time, velocity, and altitude in a data file called "balloon1.txt".


(Hand example of an array and example exercise )

(hand examples to get familiarized with arrays)


(Screen shot of Virtual-C IDE, program showing the opening/closing of a file)