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.

Help with C Programming code

Status
Not open for further replies.

pikashi

Newbie level 6
Joined
Sep 4, 2010
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,409
Hi, do anyone know how to read or write C Programming souce code for interfacing DS89C450 with PPI 82C55?

---------- Post added at 22:54 ---------- Previous post was at 22:52 ----------

I have the C Programming code but need someone to assist me with it. Thank you. (Urgent)
 

what code you want to write ? and which hardware you want to implement so that u can write th code ?

briefly explain your requirements....
 

you can post the code in the forum some one may help you
atleast we will try to tell you block wise
 

Hi, do anyone know how to read or write C Programming souce code for interfacing DS89C450 with PPI 82C55?

---------- Post added at 22:54 ---------- Previous post was at 22:52 ----------

I have the C Programming code but need someone to assist me with it. Thank you. (Urgent)

you can post your code here so that somebody can help you...
 

#include <DS89C4xx.H>
#include <absacc.h>
#define PortA 0x 4000 //PPI PortA address
#define PortB 0X4001 //PPI PortB address
#define PortC 0X4002 //PPI PortC address
#define Control_Register 0x4003 //PPI Control R egister address
void delay(int time) //time delay
{
int i,j;
for(i=0;i<time;i++)
for(j=0;j<1200;j++);
}
unsigned char rx(void)
{
while (R I_0 ==0); //check RI until set
RI_0=0;
return(SBUF0 );
}
main (void)
{
char labview;
delay(5000);
XBYTE[Control_Register] = 0x80; //initialise PPI all ports output
XBYTE[PortA] = 0xFF; //turn off relays
XBYTE[PortB] = 0xFF; //turn off relays
XBYTE[PortC] = 0xFF; //turn off relays

SCON0=0x52; //initialize serial 4800 BR; 8 Bit; NP
TMOD=0x21;
TH1=0xFA;
TR1=1;
P2=0; //multiplexer select code initialise to zero
while(1)
{
labview=rx (); //receive from labview via rs232
if (labview < 0x40)
{
switch(labview)
{
case 0x 01 : XBYTE[Control_Register]=0x00; break; //turn
on relay 1, relay 1 @ PortC bit 0
case 0x 02 : XBYTE[Control_Register]=0x02; break; //turn
on relay 2, relay 2 @ PortC bit 1
case 0x 03 : XBYTE[Control_Register]=0x04; break; //turn
on relay 3, relay 3 @ PortC bit 2
case 0x 04 : XBYTE[Control_Register]=0x06; break; //turn
on relay 4, relay 4 @ PortC bit 3
case 0x 05 : XBYTE[Control_Register]=0x08; break; //turn
on relay 5, relay 5 @ PortC bit 4
case 0x 06 : XBYTE[Control_Register]=0x0A; break; //turn
on relay 6, relay 6 @ PortC bit 5
case 0x 07 : XBYTE[Control_Register]=0x0C; break; //turn
on relay 7, relay 7 @ PortC bit 6
case 0x 08 : XBYTE[Control_Register]=0x0E; break; //turn
on relay 8, relay 8 @ PortC bit 7
case 0x 09 : XBYTE[PortA] =0; break; //turn on relay 9,
relay 9 @ PortA bit 7
- 88 -

case 0x 0A : XBYTE[PortB]=0; break; //turn on relay 10,
relay 10 @ PortB bit 4
}
}
P2=labview; //send labview data to multiplexor select
}
}

---------- Post added at 14:26 ---------- Previous post was at 14:24 ----------

Hi all, this is the code. My doubt was from switch(labview) onwards.
 

Hi Pikashi,

Let me try this and let me know if you get your ans.
as such this is very simple C code, on top level... Labview is receiving a signal from RS232 and as per that signal you are switching ON/OFF of you relay.

From the below cade you can see...
switch(labview)
{
case 0x 01 : XBYTE[Control_Register]=0x00; break; //turn
on relay 1, relay 1 @ PortC bit 0
case 0x 02 : XBYTE[Control_Register]=0x02; break; //turn
on relay 2, relay 2 @ PortC bit 1
case 0x 03 : XBYTE[Control_Register]=0x04; break; //turn
on relay 3, relay 3 @ PortC bit 2
case 0x 04 : XBYTE[Control_Register]=0x06; break; //turn
on relay 4, relay 4 @ PortC bit 3
case 0x 05 : XBYTE[Control_Register]=0x08; break; //turn
on relay 5, relay 5 @ PortC bit 4
case 0x 06 : XBYTE[Control_Register]=0x0A; break; //turn
on relay 6, relay 6 @ PortC bit 5
case 0x 07 : XBYTE[Control_Register]=0x0C; break; //turn
on relay 7, relay 7 @ PortC bit 6
case 0x 08 : XBYTE[Control_Register]=0x0E; break; //turn
on relay 8, relay 8 @ PortC bit 7
case 0x 09 : XBYTE[PortA] =0; break; //turn on relay 9,
relay 9 @ PortA bit 7
- 88 -

case 0x 0A : XBYTE[PortB]=0; break; //turn on relay 10,
relay 10 @ PortB bit 4
}

that foe every input received by LABVIEW (from 0x00 to 0x0A) there are total 10 inputs and every input is corresponding to a particular bit of the port. So at every bit a Relay is attached and which every input you are turning that particular relay.

As such this is the functionality. If you have anyother doubt regarding this , please let me know.
 

birdy explained ryt...but i think so there is a problem in your programm that it keeps your relay ON ....

main (void)
{
char labview;
delay(5000);
XBYTE[Control_Register] = 0x80; //initialise PPI all ports output
XBYTE[PortA] = 0xFF; //turn off relays
XBYTE[PortB] = 0xFF; //turn off relays
XBYTE[PortC] = 0xFF; //turn off relays

here 0xFF is not for Turning OFF it For turning ON the relays

here it will turn off your relays...

Xbyte[portA]=0x00

feel free to ask if still confused...
 

hi Chaudhry,

You are right. Its looks to me also but the relay is fitted in such a way that for 1 its OFF and for 0 Is on.
 

Hi, thanks for your reply.

I would like to check with you that, the PPI consist of 3 ports which are Port 1(A), Port2(B) and Port3(C).
I understand that each port are declared and serve as an output port to the relay so that it will trigger the relay once it receive information from the Labview program. May i know why it was declared in this way "case 0x 01 : XBYTE[Control_Register]=0x00; break; //turn on relay 1, relay 1 @ PortC bit 0" Why the [Control_Register] was declared Instead of declaring XBYTE[PortC] because I am connecting PortC to the relay? What is the Control Register and those bits 0X00 use for. Next, why was the "case 0x 09 : XBYTE[PortA] =0; break; AND "case 0x 0A : XBYTE[PortB]=0; both of them were equal to 0? Thank you.


#define PortA 0x 4000 //PPI PortA address
#define PortB 0X4001 //PPI PortB address
#define PortC 0X4002 //PPI PortC address
#define Control_Register 0x4003 //PPI Control R egister address
void delay(int time) //time delay

case 0x 01 : XBYTE[Control_Register]=0x00; break; //turn
on relay 1, relay 1 @ PortC bit 0
case 0x 02 : XBYTE[Control_Register]=0x02; break; //turn
on relay 2, relay 2 @ PortC bit 1
case 0x 03 : XBYTE[Control_Register]=0x04; break; //turn
on relay 3, relay 3 @ PortC bit 2
case 0x 04 : XBYTE[Control_Register]=0x06; break; //turn
on relay 4, relay 4 @ PortC bit 3
case 0x 05 : XBYTE[Control_Register]=0x08; break; //turn
on relay 5, relay 5 @ PortC bit 4
case 0x 06 : XBYTE[Control_Register]=0x0A; break; //turn
on relay 6, relay 6 @ PortC bit 5
case 0x 07 : XBYTE[Control_Register]=0x0C; break; //turn
on relay 7, relay 7 @ PortC bit 6
case 0x 08 : XBYTE[Control_Register]=0x0E; break; //turn
on relay 8, relay 8 @ PortC bit 7
case 0x 09 : XBYTE[PortA] =0; break; //turn on relay 9,
relay 9 @ PortA bit 7
case 0x 0A : XBYTE[PortB]=0; break; //turn on relay 10,
relay 10 @ PortB bit 4
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top