Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > General Electronics Chat


General Electronics Chat This forum is for general chat about electronics, eg: Dont know what a part does? Dont know how to read a circuit? Want to get an opinion?

Reply
 
LinkBack Thread Tools Display Modes
Old 30th November 2004, 01:48 AM   (permalink)
Default pic programming 16f84......need help...

hi,i'm doing a project using pic(16f84) to control a dc motor. there are 3 position sensors....i have set three switch to input and my sensors should detect the position accordingly...for example if i press switch 1 it should rotate until position sensor 1 is on then it will stop the motor. the problem is i use port b to set all my inputs RB0-RB2(switch) and RB3-RB5(sensors)....how do i write the program so that when both are match,it will stop the motor....i have try to use BTFSS and ANDLW but i stuck...due to the numbers of bit involved i,m stucked... can i group a number of bits ANDLW with a group of bits??for example from port b pin 0-2 a group and again port b pin 3-5 a group ops: i'm still a newbies in pic programming.....pls help me.....thanks
tcp is offline  
Old 30th November 2004, 02:53 AM   (permalink)
Default Re: pic programming 16f84......need help...

Quote:
Originally Posted by tcp
hi,i'm doing a project using pic(16f84) to control a dc motor. there are 3 position sensors....i have set three switch to input and my sensors should detect the position accordingly...for example if i press switch 1 it should rotate until position sensor 1 is on then it will stop the motor. the problem is i use port b to set all my inputs RB0-RB2(switch) and RB3-RB5(sensors)....how do i write the program so that when both are match,it will stop the motor....i have try to use BTFSS and ANDLW but i stuck...due to the numbers of bit involved i,m stucked... can i group a number of bits ANDLW with a group of bits??for example from port b pin 0-2 a group and again port b pin 3-5 a group ops: i'm still a newbies in pic programming.....pls help me.....thanks
Post this in the microcontroller section of this board..
or maybe Nigel has a quick answer for you..
:wink:
Optikon is offline  
Old 30th November 2004, 07:01 AM   (permalink)
Default

thanx a lot....i'll post it rite away.....
tcp is offline  
Old 30th November 2004, 07:17 AM   (permalink)
Default Re: pic programming 16f84......need help...

Quote:
Originally Posted by tcp
hi,i'm doing a project using pic(16f84) to control a dc motor. there are 3 position sensors....i have set three switch to input and my sensors should detect the position accordingly...for example if i press switch 1 it should rotate until position sensor 1 is on then it will stop the motor. the problem is i use port b to set all my inputs RB0-RB2(switch) and RB3-RB5(sensors)....how do i write the program so that when both are match,it will stop the motor....i have try to use BTFSS and ANDLW but i stuck...due to the numbers of bit involved i,m stucked... can i group a number of bits ANDLW with a group of bits??for example from port b pin 0-2 a group and again port b pin 3-5 a group ops: i'm still a newbies in pic programming.....pls help me.....thanks
You can use the shift commands (RRF and RLF) to align the bits in the two values (move them to variables first). Once they are aligned use ANDLW to mask off any unused bits, then use XORWF or SUBWF to compare them.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 30th November 2004, 08:03 AM   (permalink)
Default

....thanx a lot.....cheeeers~~!
tcp is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 04:19 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

eXTReMe Tracker