LTspice IV Getting Started GuideLTspice IV Getting Started Guide
Getting Started with PhilRoboKit Anito
-
Upload
noli-bellen-rafallo -
Category
Documents
-
view
11.774 -
download
0
description
Transcript of Getting Started with PhilRoboKit Anito
![Page 1: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/1.jpg)
Getting started with PhilRoboKit
Anito BoardJanuary 19, 2013
Giancarlo Acelajado
Software/Firmware Developer
![Page 2: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/2.jpg)
OBJECTIVES• Understand what PhilRoboKit Anito is.• Learn how to program PhilRoboKit Anito.
– configure a Pin– write output state– read input state– read analog input– using built-in components
• Blinking LED• Input Switch• Controlling Buzzer• Serial Communication (UART)
![Page 3: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/3.jpg)
• An open-source Microcontroller development kit powered by Microchip PIC16F877A**beta.
• 100% Filipino-made by PhilRobotics.• Arduino-inspired project.• Programming made-easy built-in functions• Multiplatform programming IDE.• Programmable using built-in bootloader(tinybldr)
or PICKit2 through ICSP.• Uses Microchip XC8 Compiler (with Redisitribution agreement)
Who is PhilRoboKit Anito?
![Page 4: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/4.jpg)
Specifications:
• up to 21 Digital I/Os (14 at default)
• 7 Analog-to-Digital Pins
• built-in 4 LEDs
• built-in 2 switches
• built-in buzzer
• 1 Servo Port, UART Port and Programming(ICSP) Port
• USB-to-TTL connection
Who is PhilRoboKit Anito?
![Page 5: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/5.jpg)
Who is PhilRoboKit Anito?
![Page 6: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/6.jpg)
Who is PhilRoboKit Anito?
![Page 7: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/7.jpg)
The PhilRoboKit IDE
![Page 8: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/8.jpg)
The PhilRoboKit IDE
![Page 9: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/9.jpg)
• Code Folding• AutoComplete• Line Numbers• Find/Replace Tool• PICKit2 Support with Bootloader Recovery• Import Hex file (Flash and Bootload Programming)
• Library Imports• Load Examples• Serial Monitor
The PhilRoboKit IDE
![Page 10: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/10.jpg)
My First PhilRoboKit ‘HelloWorld’ Program
![Page 11: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/11.jpg)
Getting Started:
//Hitech C
#include <htc.h>
void main(void)
{
TRISC &= ~0x01;
PORTC |= 0x01;
while(1)
{
rc0 = ~rc0
__delay_ms(500);
}
}
//PhilRoboKit
void init()
{
makeOutput(D0);
setPin(D0);
}
void program()
{
togglePin(D0);
delayMs(500);
}
![Page 12: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/12.jpg)
• Init() – where initializations are placed.
• Program() – main loop program.
Getting Started:
void init()
{
/* Statement here */
}
void program()
{
/* Statement here */
}
![Page 13: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/13.jpg)
Getting Started:
• Digital IO Pins:– D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11,
D12, D13
• Analog Input Pins:– AN0, AN1, AN2, AN3, AN4, AN5, AN6– Configurable to Digital IOs (D14 to D20)
![Page 14: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/14.jpg)
• makeInput(x) – configures a pin to Input
• getPinState(x) – get the state/logic of a pin whether it is HIGH(1) or LOW(0).
Basic IO Interface - Inputs
![Page 15: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/15.jpg)
• makeOutput(x) – configures a pin to Output
• setPin(x) – set Output Pin to HIGH(1)
• clrPin(x) – set Output Pin to LOW(1)
• togglePin(x) – Toggles Output Pin (invert its previous state)
Basic IO Interface
![Page 16: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/16.jpg)
• setADCPinsToDigital() – Sets your Analog Input Pins as Digital Input/Output.
Basic IO Interface
![Page 17: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/17.jpg)
Note:
Initial state of Digital Outputs are Low.
All pins are 5v Tolerant.
Basic IO Interface
![Page 18: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/18.jpg)
• Software Delay – waste instruction cycles. Used in a non-critical timing requirement.
• Hardware Delay – uses Timer peripheral. Used in time critical requirement.
Generating Delay
![Page 19: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/19.jpg)
Generating Delay - Software Delay
void init()
{
makeOutput(D0);
setPin(D0);
}
void program()
{
togglePin(D0);
delayMs(500);
}
![Page 20: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/20.jpg)
Generating Delay - Hardware Delay
uint16_t ui16ToggleTimer; /* Create a Timer Variable */
void init()
{
makeOutput(D0); /* Configure D0 as Output */
setPin(D0); /* Initialize D0 as HIGH */
ui16ToggleTimer = getMs(); /* Initialize Timer */
}
void program()
{
if(getElapsedMs(ui16ToggleTimer) >= 500){
ui16ToggleTimer = getMs();
togglePin(D0);
}
}
![Page 21: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/21.jpg)
Using built-in Peripherals
![Page 22: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/22.jpg)
Using built-in Peripherals
• Composed of:• 4 LEDs• 2 Switches• 1 Buzzer• Analog-to-Digital Converter Port• USB-to-UART Connectivity
• Pre-initialized pin directions
![Page 23: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/23.jpg)
Using LEDs
void init()
{
}
void program()
{
setPin(LED1);
setPin(LED2);
clrPin(LED3);
clrPin(LED4);
}
![Page 24: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/24.jpg)
Using Switches
void init()
{
}
void program()
{
if(!getPinState(SW1)){
/* Do Something here */ }
if(getPinState(SW2)){
/* Do Something here */ }
}
• HIGH at initial state – with pull up resistor.
• “Active Low” – outputs LOW when pressed.
![Page 25: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/25.jpg)
Using Buzzer
void init()
{
}
void program()
{
setPin(BUZZER);
}
• LOW at initial state.• Turn on by setting it HIGH.
![Page 26: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/26.jpg)
• Stands for Analog-to-Digital Converter• Converts Analog Signals (voltage or current) into
Digital format (1’s and 0’s).• 7 ADC Channels (AN0-AN7)• 10bit ADC Resolution(210-1)• 5v Internal Voltage Reference
What is ADC?
ferenceVoltage
nsolutionADC
VoltagePin
ADCValue
Re
1)^2(Re
![Page 27: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/27.jpg)
What is ADC?
• setupADC() – setups the ADC Peripheral/module.• adcSetChannel() – select channel needed to be read.• adcStart() – start the ADC conversion (used in
conjunction with adcReadOnly).• adcReadOnly() – Reads the ADCValue (used in
conjunction with adcStart).• adcRead() – directly reads the pin, and wait for the
conversion to be finished, returns ADCValue.• adcReadOnChannel(x) – combination of adcSetChannel
and adcRead.• isADCConversionDone() – used to check/poll if the
conversion is already done.
![Page 28: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/28.jpg)
What is ADC?
uint16_t ui16ADCValue;
void init()
{
setupADC();
adcSetChannel(AN0);
}
void program()
{
ui16ADCValue = adcReadOnChannel(AN0);
}
![Page 29: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/29.jpg)
• Universal Asynchronous Receiver/ Transmitter• No clock signal required on data transmission• Simplest Serial Communication Interface• Used in conjunction with RS232, RS422 or
RS485
What is UART?
![Page 30: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/30.jpg)
• Start– Signal to begin the transmission. – High to Low transition
• Data Bits– May compose 5-9 bits.– Usually in 8bits.
• Parity (optional)– Parity bit is added to ensure that the number of “active” bits in a frame is even or odd, depending on your settings.
• Stop– Signal to end the transmission– Low to High transition
What is UART?
![Page 31: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/31.jpg)
• setupSerial(x) – setup the serial and its baudrate.• serialSendChar(x) – sends 1 byte/character• serialSendString(x) – sends a series of characters• serialSendBlock(x,y) – sends block characters with
defined size/count.• serialRead() – Read the received character from the
buffer.• isSerialDataAvailable() – checks if there’s a data
available in buffer• serialFlushData() – clears/reset the contents of the
Transmit and Receive Buffer.
What is UART?
![Page 32: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/32.jpg)
//PhilRoboKit
void init()
{
serialSetup(9600);
}
void program()
{
serialSendString(“Hello World!\r\n”);
}
What is UART?
![Page 33: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/33.jpg)
Questions?Questions?
![Page 34: Getting Started with PhilRoboKit Anito](https://reader033.fdocuments.net/reader033/viewer/2022051820/5530ab764a79595c2b8b47f4/html5/thumbnails/34.jpg)
References
• Hardware Manual:
• Firmware Manual:
Online Reference in wiki and Document Generated by Doxygen
• Software Manual:
Online Reference in wiki and Document Generated by Doxygen
• PhilRobotics Forum:
http://philrobotics.com/forum/index.php/board,14.0.html
• PhilRobotics Bugzilla(Issue Tracker):
http://philrobotics.com/bugzilla