Skip to content

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

    Software

    The majority of software used for the TINAH board is the default Wiring language,which contains

    Many 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 end-note on PWM outputs.

    Resets the PWM pin outpin and allows digital information to be written to outpin using the digitalWrite command.
    Servo Motors Used to initialize the pinouts for the RC servo motors before they can be used in your program.  Should be included in the “Setup” section of your code, not in the “loop” section.
    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:























    LCD.home(); Sets the cursor display in the upper-left corner.  Equivalent to LCD.setCursor(0, 0).
    LCD.setCursor(column, row); Sets the cursor to the specified column and row.












    Some examples using the print and println statements:



























    int variable = 10 ;
    LCD.print(“hello world!”); // prints “hello world” starting at current cursor position
    LCD.println(“hello world!”); // same as above, except moves the cursor to the next line
    LCD.print(variable); // prints “10” to the LCD screen
    LCD.print(variable, BIN); // prints “1010” to the LCD (10 in binary format). HEX, OCT and DEC are also available.



























    Note that the LCD screen used is a 16×2 character display, and will not automatically word wrap the text to the next line.






    Knobs:






    knob(6) ;

    knob(7) ;







    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).









    Stop an Start Buttons



    startbutton() ;
    stopbutton() ;



    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.speed(motor_num, velocity);



    where



    motor_num = 0, 1, 2, or 3



    velocity = -1023 to 1023   (negative values move motor in one direction, positive numbers in the opposite direction).



    The motor velocity is done by the microcontroller using a technique called pulse-width modulation.



    motor.stop(motor_num)



    motor.stop_all()



    motor.stop(motor_num) will turn off the output to the specified motor, while motor.stop_all() turns off all of the 4 DC motor outputs.









    PWM Outputs



    analogWrite(outpin, val) ;



    where



    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.



    analogWriteReset(outpin) ;



    Resets the PWM pin outpin and allows digital information to be written to outpin using the digitalWrite command.









    Description:



    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:



    digitalWrite(31, HIGH) ; // Digital pin 31 (PWM 3) goes high (assuming ServoOut1 has not been enabled).
    digitalWrite(30, HIGH) ; // Will NOT work, as digital pin 30 (aka PWM 4) is still attached to Motor 1
    analogWriteReset(30) ; // Resets digital pin 30 (PWM 4); pin can now use digitalWrite command.
    digitalWrite(30, HIGH) ; // Digital pin 30 (PWM 4) goes high (this works now)
    analogWrite(4, 512) ; // Digital pin 30 (PWM 4) now outputs a PWM signal, 50% duty cycle.
    digitalWrite(30, HIGH) ; // Will NOT work until pin is reset once again.



    Servo Motors



    In order to use the 3 servo motor outputs, the following must be completed:



    1. insert the following lines of code into the setup() loop of the software:



    RCServo0.attach(RCServo0Output) ;
    RCServo1.attach(RCServo1Output) ;
    RCServo2.attach(RCServo2Output) ;



    2.   Use the following instructions for controlling the RC servo  (examples are written for RCServo1, can be used for RCServo0 and RCSerrvo2 as well):



    RCServo1.write(angle) ;



    where 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 functin..



    RCServo1.detach() ;



    To remove the RC servo motor from usage .



    clears the display screen.



    clears the display screen.