Curtain system

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

Re: Curtain system

Postby shahrul » Sat Jan 22, 2011 12:11 am

nagufever WROTE:You mean your example is a full code or syntax?

NO
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: Curtain system

Postby ober » Sat Jan 22, 2011 12:50 pm

What do you mean by full code and syntax? I think shahrul have given a good example.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: Curtain system

Postby shiyan » Sat Jan 22, 2011 11:31 pm

ober WROTE:What do you mean by full code and syntax?


Same question here :roll:
User avatar
shiyan
Amateur
 
Posts: 189
Joined: Wed Jun 09, 2010 10:59 am

Re: Curtain system

Postby nagufever » Sat Jan 29, 2011 5:51 pm

i am using his example to do the program but it returns error.can u explain his example?
nagufever
Newbie
 
Posts: 15
Joined: Mon Sep 06, 2010 10:46 pm

Re: Curtain system

Postby shahrul » Sat Jan 29, 2011 7:36 pm

nagufever WROTE:i am using his example to do the program but it returns error.can u explain his example?

What I write here, is not full code. For sure it's error. See this ex wireless code http://shahrulnizam.com/pic-lesson-low-cost-rf-module/
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: Curtain system

Postby nagufever » Wed Feb 02, 2011 8:45 pm

Attached the code,schematic and error message for the code.Can you correct the mistakes or point how to correct it?i want to send data using switch to the transmitter.
Attachments
Tx.zip
(74.69 KiB) Downloaded 395 times
nagufever
Newbie
 
Posts: 15
Joined: Mon Sep 06, 2010 10:46 pm

Re: Curtain system

Postby shahrul » Mon Feb 07, 2011 10:10 pm

nagufever WROTE:Attached the code,schematic and error message for the code.Can you correct the mistakes or point how to correct it?i want to send data using switch to the transmitter.

Your code is lack. I give you easy code.
CODE: SELECT_ALL_CODE
#include <pic.h>
#include <htc.h>         
__CONFIG(0x3F32);
#define PB1               RA0
#define PB2               RA1
#define PB3               RA2
#define PB4               RA3
#define BAUD             1230        //~1200
#define _XTAL_FREQ  20000000   

void pic_init(void);
void uart_init(void);
char read_button(void);
void uart_transmit(char data);

main()
{
unsigned char data;
pic_init();                                 //initialize PIC
uart_init();                             //initialize UART
for(;;){
                data=read_button();
                uart_transmit(0xFF);
                uart_transmit(data);
}
}

void pic_init(void)
{
TRISA=0b001111;
TRISB=0b00000000;
TRISC=0b10000000;
TRISD=0b00000000;
TRISE=0b000;
ADCON1=0b00000110;         
PORTA=0b00000000;
PORTB=0b00000000;
PORTC=0b00000000;
PORTD=0b00000000;
PORTE=0b00000000;
}

void uart_init(void)
{
TXSTA=0b10100000;      
RCSTA=0b10010000;
SPBRG=(int)(_XTAL_FREQ/(64.0*BAUD)-1);
}

char read_button(void)
{char i=0;
if(PB1==0) i=i+1;
if(PB2==0) i=i+2;
if(PB3==0) i=i+4;
if(PB4==0) i=i+8;
return i;
}

void uart_transmit(char data){
while(TXIF==0) continue;
TXREG=data;
}

This code combination Push Button and RF Module.
If PB1 pressed, uart send 0x01,
If PB2 pressed, uart send 0x02,
If PB1 and PB2 pressed, uart send 0x03, and so on.
I just write this code without execute. Don't know if something error.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: Curtain system

Postby nagufever » Sun Feb 20, 2011 8:30 am

Does L293D motor driver enough to carry load for 12V car power window DC motor?how much does the current need for the 12 power window to rotate or i need to use different motor driver?
Attachments
Power Window.rar
(239.84 KiB) Downloaded 432 times
nagufever
Newbie
 
Posts: 15
Joined: Mon Sep 06, 2010 10:46 pm

Re: Curtain system

Postby shiyan » Sun Feb 20, 2011 12:10 pm

nagufever WROTE:Does L293D motor driver enough to carry load for 12V car power window DC motor?how much does the current need for the 12 power window to rotate or i need to use different motor driver?


So is the program functioning already? What is the error?

power window motor, I don think L293D can support it. L293D max can supply 800mA? Or 1A? The power window motor can simply take 5 to 10A on current. You will burn your L293D :D

Suitable driver? Maybe can search for 10A or higher motor driver. Or use relay.
User avatar
shiyan
Amateur
 
Posts: 189
Joined: Wed Jun 09, 2010 10:59 am

Re: Curtain system

Postby nagufever » Sun Feb 20, 2011 12:14 pm

i had compile and edited the program until no errors.can u advise me on the uart setup in the program?are they suitable or need to add something more?
Attachments
code.rar
(1.8 KiB) Downloaded 429 times
nagufever
Newbie
 
Posts: 15
Joined: Mon Sep 06, 2010 10:46 pm

PreviousNext

Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 4 guests

cron