Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

pic programming 16f84......need help...

Status
Not open for further replies.

tcp

New Member
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 :oops: i'm still a newbies in pic programming.....pls help me.....thanks
 
tcp said:
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 :oops: 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:
 
tcp said:
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 :oops: 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.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top