Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to assign logic 1 to PORTB of PIC16F877A??

Status
Not open for further replies.

thibraani

Newbie level 5
Joined
Oct 8, 2007
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,403
pic and uln2804a

I'm doing a school assignment using PIC. I'm programming my microcontroller, the PIC16F877A using C language. I'm stuck on how to assign logic 1 to PORTB?

This is how the system should work:
1. User turn on DIP switch 1
2. The 5V DC motor (located at port B) turn ON
3. User turn on DIP switch 2
4 The motor turn OFF

There's no need a DC motor driver as logic 1 from the microcontroller is already 5V and that should turn on the voltage.

Please, I need your help to provide me the sample code.

Thank you.
 

Cortex

Full Member level 3
Joined
Mar 26, 2005
Messages
182
Helped
12
Reputation
24
Reaction score
4
Trophy points
1,298
Location
Morocco
Activity points
2,733
You better use a transitor to power on the dc motor

Configure the pin as output and SET it, to power on the motor
Clear it to power off !

If you ASM

BSF to power on
BCF to power off

regards
 

Joined
Sep 3, 2007
Messages
853
Helped
66
Reputation
132
Reaction score
16
Trophy points
1,298
Activity points
0
Hi,
I recommend you to use a ULN28XX for driving the Motor.
 

thibraani

Newbie level 5
Joined
Oct 8, 2007
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,403
I'm not familiar with assembly language. Can you provide me with C Language to set the Port B in order to turn on the motor?
 

xorcise

Full Member level 2
Joined
Sep 27, 2007
Messages
124
Helped
20
Reputation
40
Reaction score
1
Trophy points
1,298
Location
NYC
Activity points
2,169
Set the Port direction as output first then assign value to PORTB:

Code:
TRISB = 0 ;     // all pins as output
PORTB = 1;      // RB0 pin is high all other off
PORTB = 2;      // RB1 pin is high all others off
PORTB.7 = 1;    // RB7 is high, RB1 remains high also
 

crowinu

Member level 2
Joined
Apr 1, 2005
Messages
48
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
1,621
thibraani said:
I'm doing a school assignment using PIC. I'm programming my microcontroller, the PIC16F877A using C language. I'm stuck on how to assign logic 1 to PORTB?

This is how the system should work:
1. User turn on DIP switch 1
2. The 5V DC motor (located at port B) turn ON
3. User turn on DIP switch 2
4 The motor turn OFF

There's no need a DC motor driver as logic 1 from the microcontroller is already 5V and that should turn on the voltage.

Please, I need your help to provide me the sample code.

Thank you.

@bold: it's true that it is already 5V but restricted in current, you need a transistor as someone mentioned before or use a dedicated ic like L298 etc.
 

Joined
Sep 3, 2007
Messages
853
Helped
66
Reputation
132
Reaction score
16
Trophy points
1,298
Activity points
0
bear in mind that max current from Pic's Pins is about 20 mA. Yiou can burn you Pic if your motor demand more than that from Pic. So, use transistor, darlington or simply ULN.
Hope it help!
Cheers,
 

stevenson

Newbie level 4
Joined
Apr 26, 2007
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,302
If you are using MikroC do this:

PORTB.F0 = 1;
PORT.F1.....7

AND I AGREE WITH master_picengineer USE AND ULN2804A FOR 500mA current output.

Eng. Canó
Dominican Republic
2007
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top