[PIC] PIC16F84A initial coding using micro C

Status
Not open for further replies.

Nazrin Rain Nazam

Newbie level 2
Joined
Jun 15, 2014
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
19
hello, i am newbie in this area ^_^
i need help for my coding.. since the coding i made cannot give expected simulation ouput.


this is my coding
anyone might help this newbie one?


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void main() {
  TRISA=0x01;
  PORTA=0;
  TRISB=0;
  PORTB=0;
   while(1){
          (PORTA.B1 = 0);
          (PORTA.B2 = 1);
          (PORTA.B3 = 0);
           if (porta.b0=1){     
              (PORTA.B2 = 0);
              (PORTA.B3 = 1);
              Delay_ms(7000);
              (PORTA.B1 = 1);
              };

 
Last edited by a moderator:

That schematic is very strange.
1. Why two 1A regulators when U3 only has to supply ~100uA and U2 only 50mA during reset and almost nothing at any other time.
2. There is also no VSS connection to U3 so unless it is made through the 12V supplies the PIC could be damaged.
3. It is highly unlikely you can drive an LED and relay in series from RA1. I predict the current would only be ~5mA with only about 2V across the relay.
4. Even accepting the relay probably wouldn't operate, it should have a clamp diode across it's coil.

In the code, it's difficult to tell what you are trying to do. You seem to possibly pulse PORTA bits 1, 2 and 3 for a few uS depending on the state of RA0. The signal to RA0 has a long time constant so it would be very slow (possibly several seconds) to react to a loss of V2.

Perhaps it would help if you explained what it is supposed to do.

Brian.
 

to mr Brian,
im very sorry not to mentioned how this circuits work.

for V2, actually it is a port later to be connected with Earth Leakage Relay (ELR)
when ELR trip, it will transmit a 230VAC signal to the port V2.
i already apply transformer, bridge rectifier and voltage drop circuit before input of V2.
therefore, i expect a 5V signal to be the input for the RA0 as a fault signal.

for the coding,
i'm very new, so i need help over here
what i want to do,
first in normal condition,
RA2 will always on, to indicate the system is in normal condition.
when ELR trip and send fault signal to RA0,
i want RA2's LED to be turn OFF, and turn on RA3's led.
after 7 second (in order to allow enough time for leakage current flow to the ground),
RA1 will send a 5V as its output. may anyone help me?
 

if you are comparing any bit you should use this ==
if (porta.b0=1)

for example

if (porta.b0==1){
 

I suggest you rewire it like this:



It won't work with the present fault signal ciruit because the time taken for the voltage on RA0 to fall away when the V2 voltage is removed will probably be longer then 7 seconds, you want it to appear and disappear almost instantly.

If your relay works on more than 5V, connect it's coil and the diode/LED to the voltage it needs and adjust the LED series resistor for the desired current through it.

Brian.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…