Sunday, August 30, 2015

On Recreating my Childhood

from mariokart.wikia.com
Like many tech-slanted children of the nineties I have many fond memories of some classic video games.

Mario Kart 64 was one such game.

It was a fantastic example of simple, well thought out design meeting pure simplicity of gameplay...except for the blue shells...those terrible, terrible things.

And while cruising Rainbow Road was a certain sort of cathartic, it was always the balloon battles that got the shouting started and the players ready to splatter each other into the wall.

Which leads me to my next problem. Admin has challenged me to present something about robotics at our club week and it was suggested that it should be interactive.

And I asked, "what would it take to do a real life Mario Kart balloon battle?"


Apparently, according to Rooster Teeth, it requires mild to severe inebriation, a budget for robots and a lack of love for your baseboards and your ankles.

I pitched it, jokingly, to my Assistant Principal. He responded as any sane person would..."knives ..in a school?...seriously?"

I wasn't serious about the knives, but I was serious about the balloon fight. So here is the plan.

A) Create 2-4 robotic platforms that will be challenging to drive.
B) Attach balloons to one end and sewing needles to the other
C) Have students battle them to the death.

This post will cover A.

For this project I used the following supplies:

Arduino Uno (I used Sparkfun's Redboard for the prototype but am going to test Solarbotics' Sketchboard as well.)
Magician Chassis
Breadboard (all of the chassis in my classes have breadboards stuck on them for prototyping)
RC Car 9.6V Battery(pictured right - The ones I have were there when I inherited the lab and will be replaced this year as they are dying)
TSOP4038
A Toy IR Remote Control(This bad boy cannot be found online. It is cheap, probably Chinese, and irreplaceable. They were a part of a kit and I can't find the kits. It has 8 channel IR transmission and 8 buttons.)
Seeed Studio's I2C Motor Driver


The Magician chassis is perfect for this as it has high speed motors and is easily adaptable.

I hooked up the I2C Motor Driver into the Arduino according to my I2C lesson(see right panel for Arduino Theory Lessons from my class). One problem that I noted was that the Uno R3 (the official Arduino ones) don't have labelled SCL and SDA ports. Can anyone confirm if the unlabelled ports above the AREF port work for this application?

The main hack here is that I used a 4-pin adapter for my Motor Driver instead of a Grove Shield. This is much more cost effective if you aren't using the rest of the Grove system.

The second piece of this was to wire the IR receiver into the breadboard according to it's datasheet.

At this point the electronics people reading this are asking, "why is nothing tied down?" I was testing, we will get to that.

With all of the hardware in place, I was able to tackle the hardest part, the code.

Let me start my saying that I am not a trained coder, I am self taught and began in PBASIC with Parallax robots.

Needless to say, my code often looks different than the standards for C.

I began by taking readings from my infrared receiver using Ken Shirrif's terrific IR Library.

Using the IRrecvDemo I manually recorded the sensor values for each of the buttons. They all come in hex code which was noted as I will need to explain how hex works to my kids if we do this as a projects this year.

Following this I fired up my DC motor test code, which can be found in the right panel under Arduino Theory.

After confirming that it ran the motors properly I created a series of functions to simplify calling moving forward, back, left and right pivots and swerves and three different speeds.

These functions were than applied to a series of if and else...if commands to connect them with each button press

I spent two evenings fighting with datatypes as C is something that I am learning at this point. In the end though, it is like winning on rainbow road when you press the buttons and the robot responds to your commands.



I've posted the code below and will place it in the Arduino Programs section of the sidebar. (video of the first run is at the bottom of the page)


   1:  /*
   2:    Grove- i2C motor driver demo v1.0 Modified for James Fowler Robotics
   3:    by: http://www.seeedstudio.com
   4:  //  Author:LG Modified by Mitchell Way
   5:  //
   6:  // The Modifications to this code serve to make it able to run 2 DC motors while being controlled by an Infrered remote
   7:  //
   8:  //  This demo code is free software; you can redistribute it and/or
   9:  //  modify it under the terms of the GNU Lesser General Public
  10:  //  License as published by the Free Software Foundation; either
  11:  //  version 2.1 of the License, or (at your option) any later version.
  12:  //
  13:  //  This library is distributed in the hope that it will be useful,
  14:  //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15:  //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16:  //  Lesser General Public License for more details.
  17:  //
  18:  //
  19:  */
  20:   
  21:   
  22:  //Data to communicate with motor Controller via I2C
  23:  #include <Wire.h>
  24:   
  25:  #define MotorSpeedSet             0x82
  26:  #define PWMFrequenceSet           0x84
  27:  #define DirectionSet              0xaa
  28:  #define MotorSetA                 0xa1
  29:  #define MotorSetB                 0xa5
  30:  #define Nothing                   0x01
  31:  #define I2CMotorDriverAdd         0x0f   // Set the address of the I2CMotorDriver
  32:   
  33:   
  34:  #include <IRremote.h>
  35:   
  36:  //The following describes the controller outputs on setting 1
  37:  #define None   0x85EC7D0F
  38:  #define u       0x9ACDD255
  39:  #define d      0xEE228A5
  40:  #define l      0x28C6631A
  41:  #define r      0xE6DFAB16
  42:  #define ur     0x3FC4F8DA
  43:  #define ul     0x27C66187
  44:  #define a       0x5D30FCF1
  45:  #define b       0xA51DA0F
  46:  #define x       0x96A9455E
  47:  #define y       0x657C3134
  48:   
  49:  int RECV_PIN = 11; //TSOP4038 set up on Arduino Pin 11
  50:   
  51:  IRrecv irrecv(RECV_PIN);
  52:   
  53:  decode_results results;
  54:   
  55:  void setup()  {
  56:    Wire.begin(); // join i2c bus (address optional for master)
  57:    delayMicroseconds(100);
  58:    irrecv.enableIRIn(); // Start the IR receiver
  59:    Serial.begin(9600);
  60:    Serial.println("setup begin");
  61:   
  62:  }
  63:   
  64:  void loop()
  65:  {
  66:    if (irrecv.decode(&results)) //When a nonzero value is read determine proper function to pursue based on button pressed
  67:    {
  68:      irrecv.resume(); // Receive the next value
  69:      Serial.print("Results =\t");
  70:      Serial.println(results.value);
  71:   
  72:      if (results.value == y)
  73:      {
  74:        SpeedFull ();
  75:        Serial.println("Y");
  76:        delay(1);
  77:      }
  78:        else if (results.value == b)
  79:      {
  80:        SpeedMed ();
  81:        Serial.println("B");
  82:        delay(1);
  83:      }
  84:      
  85:     else if (results.value == a)
  86:      {
  87:        SpeedStop ();
  88:        Serial.println("A");
  89:        delay(1);
  90:      }
  91:   
  92:      else if (results.value == u)
  93:      {
  94:        Forward();
  95:        Serial.println("U");
  96:        delay(1);
  97:      }
  98:   
  99:      else if (results.value == d)
 100:      {
 101:        Back();
 102:        Serial.println("D");
 103:        delay(1);
 104:      }
 105:   
 106:   else if (results.value == l)
 107:      {
 108:        PivotLeft();
 109:        Serial.println("L");
 110:        delay(1);
 111:      }
 112:   
 113:       else if (results.value == r)
 114:      {
 115:        PivotRight();
 116:        Serial.println("R");
 117:        delay(1);
 118:      }
 119:   
 120:   else if (results.value == ul)
 121:      {
 122:        SwerveLeft();
 123:        Serial.println("UL");
 124:        delay(1);
 125:      }
 126:   
 127:       else if (results.value == ur)
 128:      {
 129:        SwerveRight();
 130:        Serial.println("UR");
 131:        delay(1);
 132:      }
 133:   
 134:   
 135:   
 136:   
 137:    }
 138:  }
 139:  //function to set motor speeds
 140:  void MotorSpeedSetAB(unsigned char MotorSpeedA , unsigned char MotorSpeedB)  {
 141:    MotorSpeedA = map(MotorSpeedA, 0, 100, 0, 255);
 142:    MotorSpeedB = map(MotorSpeedB, 0, 100, 0, 255);
 143:    Wire.beginTransmission(I2CMotorDriverAdd); // transmit to device I2CMotorDriverAdd
 144:    Wire.write(MotorSpeedSet);        // set pwm header
 145:    Wire.write(MotorSpeedA);              // send pwma
 146:    Wire.write(MotorSpeedB);              // send pwmb
 147:    Wire.endTransmission();    // stop transmitting
 148:    Serial.println("MotorSpeedSetAB");
 149:  }
 150:  //set the prescale frequency of PWM, 0x03 default;
 151:  void MotorPWMFrequenceSet(unsigned char Frequence)  {
 152:    Wire.beginTransmission(I2CMotorDriverAdd); // transmit to device I2CMotorDriverAdd
 153:    Wire.write(PWMFrequenceSet);        // set frequence header
 154:    Wire.write(Frequence);              //  send frequence
 155:    Wire.write(Nothing);              //  need to send this byte as the third byte(no meaning)
 156:    Wire.endTransmission();    // stop transmitting
 157:    Serial.println("MotorPWMSetAB");
 158:  }
 159:  //set the direction of DC motor.
 160:  void MotorDirectionSet(unsigned char Direction)  {     //  Adjust the direction of the motors 0b0000 I4 I3 I2 I1
 161:    Wire.beginTransmission(I2CMotorDriverAdd); // transmit to device I2CMotorDriverAdd
 162:    Wire.write(DirectionSet);        // Direction control header
 163:    Wire.write(Direction);              // send direction control information
 164:    Wire.write(Nothing);              // need to send this byte as the third byte(no meaning)
 165:    Wire.endTransmission();    // stop transmitting
 166:    Serial.println("MotorDirSetAB");
 167:  }
 168:   
 169:  void MotorDriectionAndSpeedSet(unsigned char Direction, unsigned char MotorSpeedA, unsigned char MotorSpeedB)  { //you can adjust the direction and speed together
 170:    MotorDirectionSet(Direction);
 171:    MotorSpeedSetAB(MotorSpeedA, MotorSpeedB);
 172:  }
 173:   
 174:   
 175:  //This last section my seem inessecary but it is arranged this way for ease of student use.
 176:  void Forward()
 177:  {
 178:    MotorDirectionSet(0b1010); //FWD
 179:  }
 180:   
 181:  void Back()
 182:  {
 183:    MotorDirectionSet(0b0101); //FWD
 184:  }
 185:   
 186:  void PivotRight ()
 187:  {
 188:    MotorDirectionSet(0b1001); //Pivot R
 189:  }
 190:   
 191:  void PivotLeft ()
 192:  {
 193:    MotorDirectionSet(0b0110); //Pivot L
 194:  }
 195:   
 196:  void SwerveRight ()
 197:  {
 198:    MotorDirectionSet(0b1110); //Swerve R
 199:  }
 200:   
 201:  void SwerveLeft ()
 202:  {
 203:    MotorDirectionSet(0b1011); //Swerve L
 204:  }
 205:   
 206:   
 207:  void SpeedFull ()
 208:  {
 209:    MotorSpeedSetAB(100, 100); //defines the speed of motor 1 and motor 2;
 210:  }
 211:   
 212:  void SpeedMed()
 213:  {
 214:    MotorSpeedSetAB(50, 50); //defines the speed of motor 1 and motor 2;
 215:  }
 216:   
 217:  void SpeedStop()
 218:  {
 219:    MotorSpeedSetAB(0, 0); //defines the speed of motor 1 and motor 2;
 220:  }
 221:   




Part B will follow once I have laid out the game and have attached some sharp objects to the robots.

Wednesday, August 5, 2015

On Planning Ahead

I was told today "You know that it's summer holidays right?" as I booked a field trip for one of my classes this year.

Which brings me to what I was doing today, laying out my Intermediate/Advanced Medical Studies Outline for the year.

The last bit is unfinished and I will likely need a few days of thinking about it to decide which credits I want to teach this time around.

Also, I get a set of damaged Roombas tomorrow. I will be posting my initial thoughts when I receive them.



Medical Studies Intermediate/Advanced Outline (WIP)


“Your body, your health, your career”


This course will be offered for those interested in a Healthcare career. It will be organized into the three themes above:


Your body: This course will act as an introduction to anatomy and physiology of the human body. This is also covered in Biology 20 and 30, but this course will seek to deepen students’ knowledge of these topics especially in how the apply to the human body.


Your health: The second theme of this course will focus on personal health and the choices that individuals can make to improve their own health and well-being. This will include personal studies into each student's health and interventions that can have a lasting impact on it.


Your career: There are a multitude of careers in medicine that students never consider. Many enter the area of healthcare assuming that it is only doctors and nurses, not knowing that the profession also includes paramedics, radiology technicians, occupational therapists to name just a few. This course aims to expose students to these other career paths as well as to shed light on the path to doing any profession in healthcare.


Credits offered:
CCS 1030: Caring for Body Systems 1
HCS 2020: First Aid/CPC C with AED
HCS 3050: Reproduction and Readiness For Parenting
HCS 3060: Pregnancy,Birth and Infant Care
HCS 2910: HCS Project B OR HCS 3910: HCS Project D


CCS 1030: Caring for Body Systems 1
In this unit, students will review concepts in Medical Studies that will assist them in the remainder of the course. This course will also be used as the foundational content knowledge for our semester-long project “The You Study.”


HCS 2020: First Aid/CPC C with AED
During this credit, an outside instructor will be welcomed to our class to certify all of the students in the class in Standard First Aid and CPR. This certification is recognized across Canada and is something that can be used on students’ resumes and professionally. The certification lasts for three years at which point individuals can re-certify with a short 8-hour course rather than this full 16 hour course.
Cost: $85 (This course costs $135 on average to take elsewhere)


HCS 2910: HCS Project B OR HCS 3910: HCS Project D
To earn this credit, students must successfully complete a semester-long project known as “The You Study” that will challenge them to study themselves physiologically before making a major change to their behaviour, lifestyle, or diet and measuring the results. They must carry out the study and then must present the results during the final week of the semester.


HCS 2120: Pain and Pain Management
HCS 3050: Reproduction and Readiness For Parenting
HCS 3060: Pregnancy,Birth and Infant Care
Two of the following three credits will be covered in the course. I received overwhelming support for doing a unit on pregnancy and childcare in my end-of-year survey last year and this is where the 3000 level courses come in. The 2120 course is appealing to me because I am planning to take this group on a field trip to Telus Spark’s Direct from the Operating Room Program.

These will be updated as I make a decision on what to do about them.