Skip to content

This page is archived material from a previous course. Please check for updated material.

    TINAH (2013)

     

     

    What is TINAH?

    TINAH is the micocontroller-based board designed and built for the ENPH 253 course.  The board is based on two key elements:

    1. Wiring, an open-source electronics I/O board and open-source programming environment based on the Atmel ATMega128 chip.
    2. the TINAH board shield, a printed circuit-board shield designed and built for Phys253 and first used in 2009 by Engphys students and staff.  The shield acts as a “buffer” for protecting the  the digital and analog inputs and outputs of the Wiring board, and allowing for built-in functions, including:
    • 4 DC motors (max 9V, 1A each with on-board h-bridge driver)
    • 3 RC Servo motors
    • buffered digital and analog inputs  (i.e. protecting the ATMega128 with op-amps and digital buffer ICs)
    • 2 switches and 2 knobs for on-board control
    • 16×2 backlit LCD screen
    • access to the enable/direction pins for external motor control

    Many of the design considerations for the board were inspired by the HandyBoard, a Motorola 68hc11=based controller system designed by Fred Martin at MIT in the mid-1990′s.  The board was used from 2001-2008 as the basis for the Physics 253 course and used by hundreds of Engphys students.

    Many thanks to the funding sources which made the development of the TINAH boards possible: UBC SkylightUBC Teaching and Learning Enhancement Fund, and UBC Physics and Astronomy

     

     

    Getting Started

    In order to get the TINAH board to operate, do the following:

    Step
    Downloads and Links
    Notes
    1.   Setup Wiring Environment & USB drivers on your computer.
    NB:   You must use Wiring Version 27 to use the TINAH board. The newest wiring software, Build 0100, has incompatibilites with the code used to control the servo motors)
    The Wiring files has already been put onto the computers in Hebb 42, so skip this step.   For your own laptops computers, Wiring ver 27 can be downloaded here (WindowsMac,  and Linux versions) can be downloaded and executed from a single directory, and does not need to go through an installation.  Instructions from wiring.org.co here.

    If you have problems connecting TINAH to your computer after copying the Wiring environment over (i.e. your computer does not automatically recognize and install the USB device), use the USB VCP driver to recognize the on-board hardware.

    2.  Copy the Phys253 Library into the Wiring Environment.
    Use ONE of the following:

     

    1.  Close down the Wiring environment.2.  Download the library directory “phys253library” and unzip the files into the folder “wiring-0xx/libraries”, where xx=the version name.   (Do not put it into the similarly named”wiring-0xx/lib”).3.  Restart the Wiring environment.
    3.   Download and use the template file. phys253_template.pde.txt When writing any file using the TINAH board, make sure to include the following #include statements before the void setup() declaration, and commands in the setup loop.

    4.   Power your TINAH Board The TINAH board requires external power to operate, either through an external battery or the power jack input.  Plugging the board into the USB port does not provide the power to operate the board. A small piece of plastic has been inserted into the power jack in the Wiring board – this is to prevent you from plugging power into that power jack; using this jack powers the Wiring board but does not power the TINAH shield board.
    5.   Write and Download code See the Toolbar instructions at WiringOnce your code is written, press the “Verify” button to compile the code, then press “Upload to IO Board”.   You then have ~5 sec to press the reset button on the Wiring board to initiate programdownload.When downloading code, the green and red LEDs just above the LCD screen should light up indicating communication transfer. A few things to look at in case the code doesn’t download:

    • Check “Tools –> Serial Port” that the correct serial port for the wiring board is selected.
    • Check “Tools –> Firmware” to select version 2.0.
    • Check “Tools -> Target Mictrcontroller” to get the ATMega128
    • Unfortunately, on most boards the green and red LEDs are not very bright, and might be hard to see in a bright room.
    • Press the Reset button on the TINAH periodically may get the bootloader to connect (hold down for one second, wait 2 seconds, repeat a few times).
    • On Windows 7 machines, you may occasionally get a Visual C++ Runtime Error – r6061.  This appears to be caused since the wiring environment isn`t supported natively as an 64-bit application.

     

    5.   Try the Demo Program
    phys253_demoprogram.pde The above demo program shows some of the functionality of the board (LCD screen, digital and analog inputs, and motor/servo motor outputs).

     

     

     

    tinah-diagram

     

    Hardware

    (1) Power Switch

    Used to turn the board on and off.  The board must be externally powered through either the 12V DC input jack or through the battery wire.  Plugging the USB cable into the board does not provide any power to the board.

    (2) 12V DC Input

    The board is fully functional with a DC input 12 to 16V.  The Wiring board, LCD and all digital logic works at voltages greater than 7V, but the motor outputs will not operate properly at voltages less than 12V.  The DC input jack is center-positive.

    (3) Battery Output

    This screw-down header connector gives direct connection to the battery connected to the TINAH board.   This connection can be used to connect the battery to any external circuitry (external motor drivers, sensors/switches which require power, etc).

    (4) and (5) Stop and Start Buttons

    The buttons are named start and stop, but can be used interchangably depending on the code that you write, using the stopbutton() and startbutton() commands.    Commands can be found in the Software writeup.

    (6) Motor outputs and indicators

    4 motors can be controlled using the setup (Motor 0, 1, 2, and 3).  The LEDs indicate the direction and intensity of the motor (brighter = higher PWM = faster motor).  Commands for using the motors can be found in the Software writeup.

    Motors can be connected directly to the board through either the screwdown terminals, or the header pins immediately to the left of the screw terminals (they are electrically connected).  The figure below shows the groupings for the screw terminals and the header sockets for the motors.

    Figure:  Motor Output Headers

    The header pins are in groups of 3 pins, with the middle pin not connected to anything; this means that a motor on a 3-pin header will not be powered in case the motor is accidentally shifted over by a single pin on the header.

    The TINAH board limits the output of the motors connected to 9V at a maximum of ~700 mA per motor (the board uses an H-bridge chip, the SN754410NE, with power through a 7809 regulator) .  Any motor with larger voltage or current requirements should be driven with an external H-bridge controller using the signals generated using these inputs/outputs or the motor control signal outputs described below.

    (7) Motor control signal outputs

    These digital logic-level signal outputs are meant to connect with an external H-bridge or other motor control circuit for arbitrary current or voltage requirements.  See the information for the H-bridge chip used on the TINAH, the SN754410NE. This is similar to many types of single-chip H-bridge chips as well, such as the L293D.   These are signal outputs, and do not source or sink sufficient current to directly to power a DC motor.

     

    Figure:  TINAH motor signal outputs

     

    (8) Servo Motor Outputs

    The servo motor outputs can be connected as shown.  The board can take any standard RC servo motors, as explained here with a default 5V power connection as shown.   Take care to insert RC servo motors into the plug-in headers so that the Signal Line is connected to the motor correctly (typically the white or yellow line).

    Figure:  TINAH Servo mtor connections and jumpers 

     

    (9) Reset Button

    This button is to be pressed when a program is uploaded to the board through the Wiring environment.  Press the button within ~5 seconds of pressing the “Upload to I/O Board” button.

    (10) Digital Inputs

    16 digital input lines grouped into two ports (Port0 and Port1).

    The pinout convention matches the setup used in the Handy Board, with a sensor signal pin, a gap, followed by a row of 5V and ground.

    Figure:   TINAH Digital Inputs:  

     

    (11) Analog Inputs

    8 analog input lines, with 0-5V input range.   Note that Analog Inputs 6 and 7 are tied to the two knobs, but can be redirected to the Analog Input header by changing the jumper settings next to the knobs.

     

    Figure:  TINAH analog inputs:  

    The pinout convention matches the setup used in the Handy Board, with a sensor signal pin, a gap, followed by a row of 5V and ground.

     

    (12) PWM Outputs

    Provide access to the 6 PWM output lines from the  Wiring board.  Four of these lines (PWM 0, 1, 4, and 5) are assigned to the motor outputs, but can be used as general PWM or digital outputs if motors are not connected to the outputs.  Commands for using the PWM outputs are found on the Software page

     

     

    Figure:   TINAH PWM outputs: 

      • PWM pins 5, 4, 3, 2, 1 and 0 map directly to digital pins 29, 30, 31, 35, 36, and 37.  This is part of the Wiring board default setup.  See here for an explanation from the Wiring documentation.
      • The PWM pins are all normally connected to other functions on the TINAH board.  A pinout diagram can be found here.
        • PWM 5, 4, 1, and 0 are connected to the enable signal of the motor drivers, and are normally used to provide the PWM output for motors 0, 1, 2, and 3.
        • PWM 2 is normally connected to RCServo1, and becomes active when the RC Servo is initialized with “RCServo1.attach(RCServo1Output)”
        • PWM 3 is normally connected to RCServo2, and becomes active when the RC Servo is initialized with “RCServo2.attach(RCServo2Output)”  PWM 3 is also connected to the on-board Buzzer, which at the moment has been disabled.
      • An excerpt from the full pinout table for the TINAH board:
    Wiring digitalPin# Wiring PWMPin # TINAH Function
    29 5 Motor_En 0
    30 4 Motor_En 1
    31 3 ServoOut1/Buzzer
    35 2 ServoOut 0
    36 1 Motor_En 2
    37 0 Motor_En 3

     

    (13) Rx/Tx Indicators

    LEDs indicate when there is communication along the USB/Serial port interface to the main computer.   This occurs if either the board is being reprogrammed, or if information is being transferred to or from the main computer using the Serial library commands.

    (14) LCD Screen

    16 column x 2 row LCD display.  Use the LCD commands as described in the Software writeup to write information to the screen.

    Note that the LCD does not automatically reset when the Reset Button is pressed.  This means that the program may be halted and a new program received and downloading while the LCD displays the most recent update, sometimes for several seconds while the program is downloading.

    (15) Power Indicator

    On when the TINAH board receives sufficient power to operate.

    (16) and (17)  Knobs

    Access the value of the two knobs by calling the knob functions knob(6) or knob(7).  Can change the jumpers in order to connect Analog Inputs 6 and 7 to the analog input header pins instead of from the knobs

    Figure:   TINAH knob jumpers: 

    Software

    The majority of software used for the TINAH board is the default Wiring language,which containsMany examples and tutorials showing how to interface the Wiring board to a variety of devices.   Note that the TINAH board contains several ICs used to protect and buffer the pins on the Wiring board, so you are not able to interface with some items)

    The following table summarizes the functions available specifically for the TINAH board through the phys253wiringvX library:

     

    Functional Area Command Description Notes

    LCD Commands

    Clears the display screen. The instructions for writing to the LCD screen are the same as described in Wiring, except the pinouts have already been defined and the class “LCD” has already been defined.
    Sets the cursor to the specified column and row. Note that the LCD screen used is a 16×2 character display, and will not automatically word wrap the text to the next line.
    Sets the cursor display in the upper-left corner.  Equivalent to LCD.setCursor(0, 0).

    Knobs and Buttons

    Returns the analog value of the hardware knob connected to pin 6 or pin7 on the TINAH board (a 10-bit input value, ranging from 0 to 1024).  Equivalent to the command analogRead(6) and analogread(7).
    Returns the Boolean value of the start and stop buttons on the board.  The buttons are named start and stop, but can be used interchangably depending on the code that you write.

    DC Motors

    motor_num = 0, 1, 2, or 3 velocity = -1023 to 1023   (negative values move motor in one direction, positive numbers in the opposite direction).
    turn off the output to the specified motor
    turns off all of the 4 DC motor outputs

    PWM Outputs

    outpin = 0, 1, 2, 3, 4, 5   (or 37 36, 35, 31, 30, 29) val = 0 to 1023 Sends a PWM signal on PWM Pin outputpin with a duty cycle of (val/1024), as described in greater detail in the Wiring Library documentation. ***See note below on PWM Examples
    Resets the PWM pin outpin and allows digital information to be written to outpin using the digitalWrite command.

    Servo Motors

    angle = integer from 0 to 180.   The RC Servo moves to the specified angular position. DO NOT EXCEED 180, as excess current is drawn through the motor circuit, which likely results in the servo motor glitching and may affect the rest of the board function.
    To remove the RC servo motor from usage, and to free up the corresponding PWM output for general use.

     

    ***PWM Examples

    The PWM pins can be used as standard digital output lines using analogWrite to generate a PWM output on the pin, or digitalWrite to create a High or Low signal on the pin.

    One glitch in the existing Wiring code is that once the function analogWrite is used on a pin, the pin does not respond to the digitalWrite command until the pin is reset. Use the command analogWriteReset(Pin) to reset the pin and allow the digitalWrite command to work properly on the given pin.

    In addition, four of the PWM pins on the TINAH board have been initialized for use with 4 motor outputs, and must also be reset using analogWriteReset prior to using them. See the Hardware page for further details.

    An example of several lines of consecutive code using the analogWriteReset command:

     

    Checklist, Bugs and Revisions

     

    Upload Checklist

    A brief list of items before compiling and uploading programs to the TINAH boards:

      1. DO NOT MODIFY ANY JUMPERS – for the time being, unless you verify your design with one of the course instructors please do not modify any of the jumpers on your board.
      2. DO NOT USE digitalWrite or portWrite COMMANDS – there is the potential for the board to have issues with the digital buffers and the wiring board if the digital output lines are used without resetting the jumper.  Unless you have your board design verified by one of the course instructors, refrain from using these two commands with Digital Ports 0 or 1.  Instead, write to one of the unused PWM lines (PWM 3 or PWM4) to gain an additional output line.

    Bugs and Code Revisions

      1. BUZZER – There is an onboard buzzer (located just under the LCD screen) which is connected to PWM3.  Originally, it was intended to use the pulseOut function to vary the frequency of the PWM output and change the sound of the buzzer.  There is currently a conflict with the signal generated by the pulseOut function and the DC motor outputs (which use PWM0, 1, 4, and 5), so that when the buzzer is connected there is always some audible “clicking” which currently cannot be turned off without disabling two of the DC motors.  The buzzer is connected by a jumper connection, and is currently disabled until the software is corrected.
      2. BUFFERS FOR DIGITAL INPUT/OUTPUT –  at present, the buffer chips (74ls245 octal bus transceivers) were used to connect the wiring board digital i/o lines to the pinouts on the TINAH board.  However, no series resistors were put in line between the 74ls245 pins and the wiring board pins.  This results in the situation whereby the jumper pins on the digital ports (used to select the input or output lines) must be changed in conjunction with changing the status of the ports using the “portMode” command.  Not doing so means that both the 74ls245 and the ATmega128 pins are both driving the same line, which may result in damage to either or both of the pins.  Care must be taken before changing the jumper pins on these settings..

     

    Advanced

    This involves features and functions that are likely not going to be used during Physics 253, but are available with the boards used in higher-level courses (e.g. APSC 459/479), or if you are interested in exploring some of the other features on the board.

    Core Libraries:

    • Core Libraries (likely not used for Phys 253, but has potentially useful items for later courses, and allows for modification of the lower-level functions on the board)    The TINAH board uses a modified version of the LCD and Servo commands.

    Undocumented features on the TINAH board

     

    Serial Ports / TWI  (Two-Wire Interface)

    ISP header

    Digital Outputs

    Accessing I/O lines normally used for the LCD screen

    Circuit Schematics

     

     

    Board Pinouts

    Wiring Pin# Wiring / TINAH Port# Port Pin# Wiring Functions TINAH functions External Interrupt
    0 0 1 I2C – SCL Digital IO Int 0
    1 0 2 I2C – SDA Digital IO Int 1
    2 0 3 Serial1 – Rx Digital IO Int 2
    3 0 4 Serial1 – Tx Digital IO Int 3
    4 0 5 Digital IO
    5 0 6 Digital IO
    6 0 7 Digital IO
    7 0 8 Digital IO
    8 1 1 Digital IO
    9 1 2 Digital IO
    10 1 3 Digital IO
    11 1 4 Digital IO
    12 1 5 Digital IO
    13 1 6 Digital IO
    14 1 7 Digital IO
    15 1 8 Digital IO
    16 2 1 LCD Data 0
    17 2 2 LCD Data 1
    18 2 3 LCD Data 2
    19 2 4 LCD Data 3
    20 2 5 LCD Data 4
    21 2 6 LCD Data 5
    22 2 7 LCD Data 6
    23 2 8 LCD Data 7
    24 3 1 Motor_Dir 0
    25 3 2 Motor_Dir 1
    26 3 3 LCD RS
    27 3 4 LCD R/W
    28 3 5 LCD E
    29 3 6 PWM 5 Motor_En 0
    30 3 7 PWM 4 Motor_En 1
    31 3 8 PWM 3 ServoOut1/Buzzer
    32 4 1 Serial0 – Rx
    33 4 2 Serial0 – Tx
    34 4 3 ServoOut2
    35 4 4 PWM 2 ServoOut0
    36 4 5 PWM 1 Motor_En 2 Int 4
    37 4 6 PWM 0 Motor_En 3 Int 5
    38 4 7 Motor_Dir 2 Int 6
    39 4 8 Motor_Dir 3 Int 7
    40 Analog 0
    41 Analog 1
    42 Analog 2
    43 Analog 3
    44 Analog 4
    45 Analog 5
    46 Analog 6 Knob 1 (jumper)
    47 Analog 7 Knob 0 (jumper)
    48 LED (board)
    49 Stop_button
    50 Start_button

    End of Page