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 16f84 programming

Status
Not open for further replies.

jenks

New Member
Hi,

Im really new to the Microcontroller field and have become seriously stuck trying to get this to run in Multisim10 using the Hi-tech software.

I am trying to use the Pic to read inputs from a detector on pin's RA1 and RA2 and then output these onto RB1 or RB2.

The PIC should output on RB1 until an input is recieved on RA2 this should then create an output on RB2 which needs to be held for X amount of time. If another detection occurs in this time the timer of the output (RB2) needs to be reset. Once the timer has been completed the output should revert back to the output on RA1. These outputs are controlling Solid state relays.

In addition to this I am looking at sending the detaail of the output using a ZigBee to a further pic to change its relay states.

Any information would be hugely appreciated!!!

Thanks
Lee
 
This is the Code i have added to which i used to simulate in Visual C++

#include "stdio.h"
#include "time.h"

#include "pic.h"
#include "htc.h"


void setPorts(void)

int get_inputs();
int lamp_up();


void wait( int seconds )
{
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait) {}
}



void main(void)
{ setPorts();

int n;
//printf ("Starting countdown...\n");
for (n=3; n>0; n--) ; // woulde be 300 when complete

get_inputs();

}

// Function will setup the ports for the PIC
void setPorts(void)
{
TRISB = 0xFF; // set Port A as inputs
TRISA = 0x00; // set Port B as outputs
}

int get_inputs()
{ int hi
int low

if (RA1==1) // HIGH O/P
{Output_high(RB1==1) // HIGH O/P
{for hi=3;hi>0;--) // countdown from timer

if (RA2==1) // low O/P
{Output_high(RB2==1) // low O/P
{for low=3;low>0;--) // countdown from timer

}
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top