Archive for February, 2010


Circuit Board Etching

I would like to share this video I found about circuit board etching:

#include <p18f2221.h>
#include <p18cxxx.h>
#include <delays.h>

#pragma config WDT = OFF
#pragma config LVP = OFF // Este bit debe estar desactivado para poder usar PORTA5
#pragma config OSC = HSPLL
#pragma config PWRT = ON //Power On timer enable

void initialization (void)
{
LATA=0;
ADCON1=0x0f;
CMCON=0×07;
TRISA=0;
PORTA=0;

PORTB=0;
LATB=0;
TRISB=0;
PORTB=0;

LATC=0;
TRISC=0xc0;
PORTC=0;
}
//——————————————–

void main (void)
{
unsigned short digits[10] = {0b10111110,0b00000110,0b01111100,0b01011110,
0b11000110,0b11011010,0b11111010,0b00001110,
0b11111110,0b11011110};
unsigned short i;
unsigned long j;

initialization();

while(1){
for (i=0;i<=9;i++){
PORTB = digits[i];
PORTAbits.RA0=!PORTAbits.RA0;

for (j=0; j<150000; j++){
Delay100TCYx;
}
}
}
}
//     end of file

I found this phone line status indicator online:

PhoneLineStatusIndicator

Right Arm for humanoid robot controlled by a Maxstream Zigbee radio and a Microchip microcontroller (18F2221) using timer interrupt and generating PWM signals to control servos.
Video shows transmitter and receiver.

Robot fully assembled: http://embeddedelectronica.wordpress.com/2010/03/18/peterbot-was-born/

Click here for the Xbee radio datasheet

//     usando compilador C18 11/19/2008

//——————————————–
// subrutina de inicializacion

#include <p18f2221.h>
//#include <p18cxxx.h>
#include <usart.h>
#include <timers.h>

#pragma config WDT = OFF
#pragma config LVP = OFF // Este bit debe estar desactivado para poder usar PORTA5
#pragma config OSC = HSPLL
#pragma config PWRT = ON //Power On timer enable

unsigned short const_timer = 178; // 238 parametro para ajustar tiempo de base a 10us
unsigned long pwm_fcy = 0;   // contador para frecuancia PWM
unsigned short cte_servo[14] = {200,200,200,90,150,210,90,150,210,90,150,210,90,150};
unsigned short servo[14] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0};
unsigned short i = 0;
unsigned short u = 0;

void InterruptHandlerHigh (void);

void initialization (void)
{
// porta
LATA=0;
ADCON1=0x0f;
CMCON=0×07;
TRISA=0;
PORTA=0;

//portb
PORTB=0;
LATB=0;
TRISB=0;
PORTB=0;

//portc
LATC=0;
TRISC=0xc0;
PORTC=0;

//timer0
T0CON = 0xC1;        // Assign prescaler to TMR0
TMR0L = const_timer;
INTCON = 0xA0;       // Enable TMRO interrupt

}

void main (void)
{
INTCON   = 0;

initialization();

OpenTimer0 (TIMER_INT_ON &
T0_8BIT &
T0_SOURCE_INT);

OpenUSART (USART_TX_INT_OFF &
USART_RX_INT_OFF &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_LOW, 64);  // 64: calcular el valor de este para 2400bps

while(1){

if (pwm_fcy >= 2000) {       //t= 20ms (200) 2000
pwm_fcy = 0;
}else{
for (u=0;u<=13;u++){
if (pwm_fcy < cte_servo[u]){
servo[u] = 1;
}else{
servo[u] = 0;
}
}
}

if (DataRdyUSART()) {
i = ReadUSART();
if (i==0×30) {
cte_servo[0]= 90;         //valores entre 90 y 200
cte_servo[1]= 90;
cte_servo[2]= 90;
cte_servo[3]= 90;         //valores entre 90 y 200
cte_servo[4]= 90;
cte_servo[5]= 90;
}
if (i==0×31) {
cte_servo[0]= 90;         //valores entre 90 y 200
cte_servo[1]= 90;
cte_servo[2]= 150;
cte_servo[3]= 150;         //valores entre 90 y 200
cte_servo[4]= 90;
cte_servo[5]= 90;
}
if (i==0×32) {
cte_servo[0]= 90;         //valores entre 90 y 200
cte_servo[1]= 150;
cte_servo[2]= 150;
cte_servo[3]= 200;         //valores entre 90 y 200
cte_servo[4]= 150;
cte_servo[5]= 90;
}
if (i==0×33) {
cte_servo[0]= 150;         //valores entre 90 y 200
cte_servo[1]= 150;
cte_servo[2]= 150;
cte_servo[3]= 90;         //valores entre 90 y 200
cte_servo[4]= 200;
cte_servo[5]= 150;
}
if (i==0×34) {
cte_servo[0]= 150;         //valores entre 90 y 200
cte_servo[1]= 150;
cte_servo[2]= 200;
cte_servo[3]= 90;         //valores entre 90 y 200
cte_servo[4]= 90;
cte_servo[5]= 200;
}
if (i==0×35) {
cte_servo[0]= 150;         //valores entre 90 y 200
cte_servo[1]= 200;
cte_servo[2]= 200;
cte_servo[3]= 150;         //valores entre 90 y 200
cte_servo[4]= 150;
cte_servo[5]= 150;
}
if (i==0×36) {
cte_servo[0]= 200;         //valores entre 90 y 200
cte_servo[1]= 200;
cte_servo[2]= 200;
cte_servo[3]= 200;         //valores entre 90 y 200
cte_servo[4]= 200;
cte_servo[5]= 200;
}
if (i==0×37) {
cte_servo[0]= 200;         //valores entre 90 y 200
cte_servo[1]= 90;
cte_servo[2]= 200;
cte_servo[3]= 90;         //valores entre 90 y 200
cte_servo[4]= 90;
cte_servo[5]= 90;
}
if (i==0×38) {
cte_servo[0]= 200;         //valores entre 90 y 200
cte_servo[1]= 150;
cte_servo[2]= 150;
cte_servo[3]= 150;         //valores entre 90 y 200
cte_servo[4]= 90;
cte_servo[5]= 150;
}
if (i==0×39) {
cte_servo[0]= 150;         //valores entre 90 y 200
cte_servo[1]= 200;
cte_servo[2]= 200;
cte_servo[3]= 200;         //valores entre 90 y 200
cte_servo[4]= 150;
cte_servo[5]= 200;
}
if (i==0×40) {
cte_servo[0]= 200;         //valores entre 90 y 200
cte_servo[1]= 150;
cte_servo[2]= 200;
cte_servo[3]= 200;         //valores entre 90 y 200
cte_servo[4]= 200;
cte_servo[5]= 200;
}

}

PORTAbits.RA0 = servo[0] ;
PORTAbits.RA1 = servo[1] ;
PORTAbits.RA2 = servo[2] ;
PORTAbits.RA3 = servo[3] ;
PORTAbits.RA4 = servo[4] ;
PORTAbits.RA5 = servo[5] ;
PORTBbits.RB0 = servo[6] ;
PORTBbits.RB1 = servo[7] ;
PORTBbits.RB2 = servo[8] ;
PORTBbits.RB3 = servo[9] ;
PORTBbits.RB4 = servo[10] ;
PORTBbits.RB5 = servo[11] ;
PORTBbits.RB6 = servo[12] ;
PORTBbits.RB7 = servo[13] ;

}
}

//—————————————————————————-
// High priority interrupt vector

#pragma code InterruptVectorHigh = 0×08
void InterruptVectorHigh (void)
{
_asm
goto InterruptHandlerHigh //jump to interrupt routine
_endasm
}
//===============================================================
// High priority interrupt routine

#pragma code
#pragma interrupt InterruptHandlerHigh

void InterruptHandlerHigh ()
{
if (INTCONbits.TMR0IF)                //check for TMR0 overflow
{
pwm_fcy++;
TMR0L  = const_timer;

INTCONbits.TMR0IF = 0;            //clear interrupt flag

}
}

//—————————————————————————-

// Display 7 segmentos      code for mikroC Version: 7.0.0.3

//
//config WDT = OFF
//config LVP = OFF // Este bit debe estar desactivado para poder usar PORTA5
//config OSC = HSPLL
//config PWRT = ON //Power On timer enable
//——————————————–
// subrutina de inicializacion

void initialization (void)
{
LATA=0;
ADCON1=0x0f;
CMCON=0×07;
TRISA=0;
PORTA=0;

PORTB=0;
LATB=0;
TRISB=0;
PORTB=0;

LATC=0;
TRISC=0xc0;
PORTC=0;
}
//——————————————–

void main (void)
{
unsigned short digits[10] = {0b10111110,0b00000110,0b01111100,0b01011110,
0b11000110,0b11011010,0b11111010,0b00001110,
0b11111110,0b11011110};
unsigned short i;

initialization();

while(1){
for (i=0;i<=9;i++){
portb = digits[i];
porta.ra0=!porta.ra0;
Delay_ms(1000);
}
}
}
//     end of file

Using Pic18F2221, this is the code for RX Xbee:

// RECEPTOR Zigbee      code for mikroC Version: 7.0.0.3
//
//config WDT = OFF
//config LVP = OFF // Este bit debe estar desactivado para poder usar PORTA5
//config OSC = HSPLL
//config PWRT = ON //Power On timer enable
//——————————————–
// subrutina de inicializacion

void initialization (void)
{
LATA=0;
ADCON1=0x0f;
CMCON=0×07;
TRISA=0;
PORTA=0;

PORTB=0;
LATB=0;
TRISB=0;
PORTB=0;

LATC=0;
TRISC=0xc0;
PORTC=0;
}
//——————————————–
void main (void)
{
unsigned short i;
unsigned int counter=0;

initialization();
USART_init(2400);
porta.ra0= 1;

while(1){
if (Usart_Data_Ready()){
i = Usart_Read();
if (i==0×12){
counter++;
}
}
if (counter==0){
PORTB=0b10111110;
}
if (counter==1){
PORTB=0b00000110;
}
if (counter==2){
PORTB=0b01111100;
}
if (counter==3){
PORTB=0b01011110;
}
if (counter==4){
PORTB=0b11000110;
}
if (counter==5){
PORTB=0b11011010;
}
if (counter==6){
PORTB=0b11111010;
}
if (counter==7){
PORTB=0b00001110;
}
if (counter==8){
PORTB=0b11111110;
}
if (counter==9){
PORTB=0b11011110;
}
if (counter>9){
counter=0;
}
}
}
//     end of file

=================================================================

Using Pic18F2221, this is the code for TX Xbee:

// Transmisor Zigbee      code for mikroC Version: 7.0.0.3

//
//config WDT = OFF
//config LVP = OFF // Este bit debe estar desactivado para poder usar PORTA5
//config OSC = HSPLL
//config PWRT = ON //Power On timer enable
//——————————————–
// subrutina de inicializacion

void initialization (void)
{
LATA=0;
ADCON1=0x0f;
CMCON=0×07;
TRISA=0;
PORTA=0;

PORTB=0;
LATB=0;
TRISB=0;
PORTB=0;

LATC=0;
TRISC=0xc0;
PORTC=0;
}
//——————————————–
void main (void)
{
initialization();
USART_init(2400);

while(1){
porta = ~porta;
USART_Write(30);
Delay_ms(10000);

porta = ~porta;
USART_Write(31);
Delay_ms(10000);

porta = ~porta;
USART_Write(32);
Delay_ms(10000);

porta = ~porta;
USART_Write(33);
Delay_ms(10000);

porta = ~porta;
USART_Write(34);
Delay_ms(10000);

porta = ~porta;
USART_Write(35);
Delay_ms(10000);

porta = ~porta;
USART_Write(36);
Delay_ms(10000);

porta = ~porta;
USART_Write(37);
Delay_ms(10000);

porta = ~porta;
USART_Write(38);
Delay_ms(10000);

porta = ~porta;
USART_Write(39);
Delay_ms(10000);

porta = ~porta;
USART_Write(40);
Delay_ms(10000);
}
}
//     end of file

My first job was very interesting (Intelsa, Giron Bucaramanga), I had the opportunity to  design a communications systems for buildings and it was called “Consola Digital Fonex 100″,  I used a Zilog Z80 microprocessor, the program was done on assembly language and the PCB was done with SmartWork.

Mi primer trabajo fue bastante interesante (Intelsa, Giron Bucaramanga), tuve la oportunidad de disenar un sistema de citofonia que se llamo “Consola Digital Fonex 100″, Utilize un microprocesador Z80 de Zilog, el programa fue hecho en lenguaje ensamblador y el PCB con el programa SmartWork.

Mi email: romancanas@gmail.com

tarjeta cpu fonex100

tarjeta cpu fonex100

gabinete fonex100

terminal consola fonex100

terminal consola fonex100

KiCAD Tutorial (pdf file)

KiCAD is an open source program to create schematics and PCB layout and it is easy to use, even you can create your own libraries and also it comes with a 3D viewer.

I found a tutorial on the web and I would like to share that with you,  cleck here to see the Mini tutorial – KiCad (pdf)

Tutorial de KiCAD (en ingles) haciendo click en el link de arriba.

Microchip’s microcontrollers were the first ones I tried years ago and sometimes I still like to work on them, I think pretty soon I would like to try another brands, AVRs are very popular nowadays.

This is a board for the PIC18F2221 that I did a few months ago, it has a crystal on board, headers to acces all ports and a ICSP interface in order to program it, I have used the Pickit2.

The board was design using the open source program KiCAD which is pretty good, schematic can be found here: PIC18F2221 Board

PCB for Microchip PIC18F2221

PCB for Microchip PIC18F2221

Follow

Get every new post delivered to your Inbox.