Professional Documents
Culture Documents
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)
built-in 2 switches
built-in buzzer 1 Servo Port, UART Port and Programming(ICSP) Port
USB-to-TTL connection
The PhilRoboKit IDE 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
Getting Started:
//Hitech C #include <htc.h> //PhilRoboKit void init()
void main(void)
{ TRISC &= ~0x01; PORTC |= 0x01; while(1) { rc0 = ~rc0
{
makeOutput(D0); setPin(D0); }
void program() {
__delay_ms(500);
} } }
togglePin(D0);
delayMs(500);
Getting Started:
void init() { /* Statement here */
Getting Started:
Digital IO Pins:
D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13
Basic IO Interface
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
Basic IO Interface
Note: Initial state of Digital Outputs are Low. All pins are 5v Tolerant.
Generating Delay
Software Delay waste instruction cycles. Used in a non-critical timing requirement. Hardware Delay uses Timer peripheral. Used in time critical requirement.
ui16ToggleTimer = getMs();
togglePin(D0); } }
Using LEDs
void init() { }
void program()
{
setPin(LED1); setPin(LED2); clrPin(LED3); clrPin(LED4); }
Using Switches
void init() { }
HIGH at initial state with pull up resistor. Active Low outputs LOW when pressed.
void program()
{
if(!getPinState(SW1)){ /* Do Something here */ }
if(getPinState(SW2)){
/* Do Something here */ } }
Using Buzzer
void init() { }
void program()
{
setPin(BUZZER); }
What is ADC?
Stands for Analog-to-Digital Converter Converts Analog Signals (voltage or current) into Digital format (1s and 0s). 7 ADC Channels (AN0-AN7) 10bit ADC Resolution(210-1) 5v Internal Voltage Reference
ADCValue ADC Re solution(2^ n) 1 VoltagePin Voltage Re ference
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.
What is ADC?
uint16_t void init() { setupADC(); adcSetChannel(AN0); ui16ADCValue;
What is UART?
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?
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?
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 theres a data available in buffer serialFlushData() clears/reset the contents of the Transmit and Receive Buffer.
What is UART?
//PhilRoboKit void init() { serialSetup(9600); }
Questions?
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