Continue to Site

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.
 

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
 

Hi,
I recommend you to use a ULN28XX for driving the Motor.
 

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?
 

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
 

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.
 

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,
 

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.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top