Discussion in "Project Doubts" started by    redzs08    Dec 13, 2010.
Tue Jun 14 2011, 10:25 am
#11
hi i need to ask is this code for microcontroller...
im using 4 input 2 temperature sensor and vibration sensor...
the output will be interfacing with pc using FT232BM chip and from pc we command to off or on the machine(only one machine) using relay....
please check the code that i modify for abbas code is correct and what type of relay driver can be use or can i use the uln 2803 maybe can use relay straight away...need urs opinion
and can i change adc0808 to (AD974: 4-Channel, 16-Bit, 200 kSPS Data Acquisition System) or u can suggest better 4 channel multiplexer....
the code are below here...
#include <reg51.h>

sbit start=P3^3;
sbit end=P3^4;
sbit oe=P3^5;
sbit ale=P3^6;
sbit clock=P3^2;
sbit relay1=P1^3;

unsigned char sens_1;
unsigned char aray[]={'0','1','2','3','4','5','6','7','8','9'};
void delay()
{
	int k,l;
	for(k=0;k<40;k++)
		for(l=0;l<80;l++);
} 
void initSerial()
{
	TMOD=0x22;
	TH1=0xFD;
	SCON=0x50;
	TR1=1;
	EA=1;
	ES=1;
}
void usDelay(int a)
{
	TH0=256-(a/1.085);
	TR0=1;
	ET0=1;
}
void timerRoutine() interrupt 1
{
	clock=~clock;
}	
void sendChar(unsigned char ch)
{  
	SBUF=ch;
	while(!TI);
	TI=0;
}
void serialRoutine() interrupt 4
{
	if(RI==1)
	{
		sens_1=SBUF;
		switch(sens_1)
		{
			case('a'):
				relay1=1;
				break;
			case('b'):
				relay1=0;
		
		}
		RI=0;
	}
}
void sendReading(unsigned char val)
{
	unsigned char l,m;
	l=val%10;
	m=(val/10)%10;
	sendChar(aray[m]);
	sendChar(aray[l]);
	sendChar(',');
}
void latch()
{
	ale=0;
	delay();
	ale=1;
}
void startConv()
{
	delay();
	start=0;
	delay();
	start=1;
}
void wait()
{
	while(end==1);
}
void get()
{
	delay();
	oe=0;
	delay();
	oe=1;
}
void main()
{
	
	unsigned char sensor=0,reading;
	P1=0;
	initSerial();
	usDelay(50);
	while(1)
	{
		if(sensor==4)
			sensor=0;
		if(sensor==0)
			sendChar('N');
		P1=(P1&0xf8)+sensor;
		latch();	
		startConv();
		wait();
		get();
		reading=P2;
		sendReading(reading);
		sensor++;
	}
}

the code not showing error....
Tue Jun 14 2011, 02:01 pm
#12
@ redzs08
i has bad experience to use adc0808
use pic chip for better result
Tue Jun 14 2011, 02:43 pm
#13
what pic chip ur proposing and thank for advise majoka.....
about the programing coding how is it..... is it ok or i made mistake in modifying.....
Wed Jun 15 2011, 10:25 am
#14
i also got problem with visual basic when i install it ask for MSDN i try to search in web it no use ............. i want to change the vb program of abbas to my output....and can anyone confirm that the code for temp and vibration sensor is correct and the relay part is it correct that it will be controlled by the pc using vb to shut the machine................
Wed Jun 15 2011, 08:52 pm
#15


i also got problem with visual basic when i install it ask for MSDN i try to search in web it no use

redzs08


MicroSoft Developer Network.
This is a shell program that you could plug Visual C or Visual Basic into.
It may be out of date now, but you should get lots of hits.
Try the Microsoft site.
Wed Jun 15 2011, 09:20 pm
#16
thanks for the info and i will try the microsoft site....
about the code can anyone tell me is it wrong or i need to change the code some info on the code pls......
Thu Jun 16 2011, 01:28 am
#17

please check the code that i modify for abbas code is correct

redzs08


code is fine add small delay after sensor++ in while(1) loop. this will help in stable values.

can i use the uln 2803 maybe can use relay straight away...need urs opinion

redzs08


yes you can use... do not forget to check ratings of your relay and see if ULN2803 can drive them or not.

and can i change adc0808 to (AD974: 4-Channel, 16-Bit, 200 kSPS Data Acquisition System) or u can suggest better 4 channel multiplexer....

redzs08


of coarse you can, but again you have to rewrite the whole program as new ADC wont work the same way as old one.
Thu Jun 16 2011, 02:05 am
#18
thanks ajay for your advise.... i will change as you propose.... i will attach a circuit diagram which show ft232bm used for interfacing pc and microcontroller... (this is to replace max232).... is this circuit is good enough as usb communication interface.....

Thu Jun 16 2011, 02:22 am
#19
Though i have never used FTDI chips. but i would suggest you to follow reference circuit from their datasheet. its will work for sure. you can also refer to many circuits available online. I dont think you will find any problem regarding FTDI USB-UART converter
Thu Jun 16 2011, 11:37 am
#20
thanks ajay for the comment.... there is another thing the vb is asking for msdn disk 1 when i try install, but i can install without it and will it work like normal and can i do an application without msdn.... cozs when i open abbas vbp file and try to run it it show error as it cant compile and no library....

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am
ArnoldDiant
Fri Apr 26 2024, 03:53 am
RodneyKnorb
Thu Apr 25 2024, 07:08 pm
Williamjef
Thu Apr 25 2024, 02:08 pm
SamuelSmise
Thu Apr 25 2024, 09:56 am
DustinErele
Thu Apr 25 2024, 08:44 am
ztaletpzca
Wed Apr 24 2024, 11:19 pm