Home - Search - Members
Full Version: shorting mechine control using AT89C51
caze
Jun 26 2008, 4:36 AM
HI everyone,

i am developping an application called " shorting mechine control " using 89c51.the key idea of this project is controlling pneumatic valves(24volt input) using IO ports. the valve has to be switched on (i.e. it should get open)for a time of 1.5 milisecond when it gets a 5 volt signal from outside world. now the problem is :-

1) i want the valve to be controlled using PWM concept. and
2) how do i design the driver ckt for the valve?

valve responce time is 0.6ms
stop time :0.05 ms

pdi33
Jun 26 2008, 9:13 AM


Try the following logic:
1. enable the external interrupt int0 and timer1 as a 16 bit timer.during the initialisation of the timer1, see that the TR1 bit (which starts the timer) is cleared.
Here set the TH1/TL1 according to the following formula:
if the time to turn ON the valve is T (in seconds),and crystal frequency of the uC is F (in Hz)then
TH1/TL1 = ( 65,536 - ( (F/12) x T)))
2.Now connect the external trigger voltage to the 8051 external interrupt. (inverted as the 8051interrupt senses only negative edge.)
In the interrupt service routine, start the timer1 (i.e. set the bit TR1) and turn on the valve through some port pin.
After T seconds, the timer interrupt will occur. Now in the timer interrupt service routine, clear the TR1 bit , reload the TH1/TL1 values and turn OFf the relay.
To compensate for the turn on delay (response time of the valve), add the delay to the required ON time. (For ur above values, T = 1.5+0.6 = 2.1 milliseconds.



As for the interfacing the valve, if the valve consumes a few milliamperes of current, then a simple NPN transistor like 2n2222/SL100 can be used to drive it but if the current is high use a high current driver like the ULN200X series buffer.


caze
Jun 26 2008, 12:34 PM
hi @ pdi33,

i am controlling 16 valves all together ,so i cant use interrupt logic here as all 32 io pins are used (16 for valves and 16 for input signal). therefor i have planed to use software delay with or without timer.

will that be ok ....?

and another thing is that the valve which i have to controll is an electromegnetic valve which needs 24volt to get excited (to get open) and after excitement it needs only 5 volts to be at open possition or else it will get burnt. so i have planed to make use of PWM logic.(i.e.first ill excite the valve using 100% duty cycle and after that X% duty cycle (which will drop the voltage to 5 volt) )

And would u please show me the driver ckt diagram for connecting valves(2 pin ,24volt electromagnetic valve)

to get a cleare idea of valve have a look on the attachment or the link given here ...

http://www.macvalves.com/bullet.pdf

regards

caze
Arun Kumar V
Jun 26 2008, 6:47 PM
Hello caze,

if you plan to do it in PWM, heres how it can be done :






change the output transistor according to your load. its always good to use optocoupler for isolation
between micro side and load side


all the best


Arun
pdi33
Jun 26 2008, 8:42 PM
hi caze,
o.k. now i understood the PWM requirement from ur second post.
If ur micro is not being used for any other purpose, then u can simply poll continuously the two input ports for any change and change the corresponding output port pin. But as far as the PWM is concerned , generating upto 16 PWM outputs from one uC is quite a challenge. But the silver lining is that u require only three states at ur output i.e. 0%,100% and 40% so i think it is just possible.... hmmmm. just give me a couple of days and i will give u the code once i simulate it and also explain the logic. Till then here is the logic i plan to use:

define a bit in ur code say PWM_bit. Then using the internal timer, continuously swtich it on/off equivalent to 40% PWM output. Now, poll the inputs and once an input is detected, turn the corresponding output port bit ON for 1.5mS and after that just copy the PWM_bit status to the port pin.This is just an idea and u require to solve some other issues while writing the code. So start out and let us see...
Good luck.
pdi33
Jun 26 2008, 8:59 PM
just confirm whether ur logic is as shown in the figure below

caze
Jun 27 2008, 6:09 AM
hi @ pdi33,

thanks for the reply. this is exactly what your last post (figure) says.

i have written an assembly program (its prototype)to execute my project . have a look on this and give your suggestion.

org 0000h
sjmp 0030h
org 0030h
sjmp here
here: mov a,#0ffh
mov p0,a //port 0 enable
mov p1,a //port 1 enable
mov a,p0 //read port p0
mov b,p1 //read port p1
mov p2,a //write to p2
mov p3,b //write to p3
mov r0,#0ffh
acall dealy //call dealy for PWM
sjmp here
delay:mov tmod,#01//intialize timer 0
mov tl0,#22h
mov th0,#3fh
setb tr0 // start timer
loop: jnb tf0, loop
clr tr0
clr tf0,#00h
mov p2,#00h
mov p3,#00h
loop4: mov tl0,#3fh
mov th0,#2eh
setb tr0
loop2: jnb tf0,loop2
clr tr0
clr tf0
mov p2,a
mov p3,b
mov tl0,#0aeh
mov th0,#20h
setb tr0
loop3: jnb tf0,loop3
clr tr0
clr tf0
djnz r0,loop4
end

note : timer values are not yet calculated . its an approx value.

this program is working fine now ...

but its so sad to say no boddy repplied for error in this program.
caze
Jun 27 2008, 6:18 AM
hi @ Arun ,

thanks for the help.this is exactly what i wanted.

how to choose the value of R1 and R2 , and how about the transister bc337 in your diagram . how to choose them.

and is there any 64 pins optocoupler available in the market.?
Arun Kumar V
Jun 27 2008, 7:20 AM

Hello pdi33,

But the silver lining is that u require only three states at ur output i.e. 0%,100% and 40% so i think it is just possible....


if i am not wrong 40% of 24 volts is 9.6 volts, it should be 21% of 24volts which would give approx 5.08 V.

caze: R1 can be 330 ohms, R2 can 2.2K. BC337 is a 800mA, 40Volts one, iam not sure of any 64 pin Opto in the market but you may have to use individual optos.

since you are using all the 32 I/O pins there is no room for additional controls, you can simplify the design if you used 2 micros.


Arun
caze
Jun 27 2008, 8:27 AM
hi @ arun,

the valve which i am using is of 35 watt,1.43 amp. can i use BC 337 for the same. and how about my program which i have posted before.
caze
Jun 27 2008, 8:37 AM
hi,
one more query..
do i need to connect a capacitor between groung and vcc of microcontroller.and between ground and power supply of PCB.

if it is so , what should be the values of the cap.
pdi33
Jun 27 2008, 11:42 AM
caze,
1.43A is too high a current for a small transistor like BC337. For that high a current u may have to use a power transistor like 2n3055 or mosfets like like he IRFXX series. just verify that the transistor /mosfet u use has a greater switching frequency than ur output PWM frequency.

As far as the capacitor is concerned, a 0.1uF cap across the uC is always recommended provided it is as close to the uC as possible. This is usually to eliminate the digital noise generated by the high frequency outputs of the uC. But in ur case that woud be hardly a problem as u are not using any analog ckt which may be affected so connecting the cap is only an option and not neccesarily required. But if the grounds of the +24V supply to the valve and the supply of the uC are same (i.e. if both are derived from the same power source, then the supply of the uC must contain a fast acting capacitor which can reduce the voltage spike the back emf of the valve coil generates when it is turned On/OFF as the load is highly inductive and the voltage surge can disrupt the flw of the uC (especially if it is of Atmel make as the AT89XX series does not have a efficient inbuilt EMI suppression like the phillips series of uCs ).
Arun Kumar V
Jun 27 2008, 6:17 PM

hello caze,

No, you can't use a 800mA transi for a 1.5 amp job, it'll fry ! try a mosfet or a power transi like BDX series

Arun
caze
Jun 28 2008, 8:09 AM
hi,

after a long search , i ve got IRFD014 power transistor , which has drain current of ID= 1.7 AMP.
can i use it .
Arun Kumar V
Jun 28 2008, 7:45 PM
Hi Caze,

as a general rule of thumb, you have to use a device which can handle 3-4 times your actual load. your load is 1.4 amp and your switching device is 1.7 amp, and since your load is a electromag device there is bound to be spikes and EMI stuff, so there should also be a protective diode across just like you have across a relay.

try using IRF540 or IRFZ44 ( price Rs.15-20)


Arun
caze
Jun 29 2008, 4:51 AM
hi , arun,

but the current rating of these devices are too high.its 28 amp for irf540 and 50 amp for irfz44. will it not burn the valve...


and if u have little much time , i would like u to explain me the logic behind the "relationship between the seitching devices current and load current . And their working too."

i hope these are no silly questions ..


caze
Jun 29 2008, 1:03 PM
HI @ Arun,

the very first post which u have posted me regarding optocoupler , In that the load is connected to the emiter. what if we connect it to the collector. is there any difference ?

AND is the value of R2 depends transistor ,connected to coupler, if it is so , how to calculate it.

Arun Kumar V
Jun 29 2008, 2:33 PM

Hi Caze,

you can connect it that way, and you need R only in case of mosfet and not transistor

it can be of 100k-1meg value. for R2 you can use 10k.

but the current rating of these devices are too high.its 28 amp for irf540 and 50 amp for irfz44. will it not burn the valve...


thats really silly, there is no harm in using a higher rated device, since you are using PWM there will be rapid Switching On and Off the Load which results in EMI and high voltage spikes across the load.

by using a higher rating you have two advantages:

1) the mosfet or transi remains cool, no heat sink is required
2) Mosfet/transis operates at a safe limit

may be you haven't noticed the Thanks button, use it if the replies helped you


Arun

sashijoseph
Jun 29 2008, 11:31 PM
Caze,it's typical of inductive loads to draw a pull-in current of ~10 to 20 times the hold current.So the mosfet suggested by Arun is just apt.With inductive loads it's always wise to have some headroom.
caze
Jun 30 2008, 5:32 AM
hi sashijoseph,

would u please be more clear for your last post .i m unable to make sense of the last sentanse. and also ""apt."""
caze
Jun 30 2008, 5:51 AM
hi @ arun,

my silly question was not that

i mean what i wantd to know is .."" Is there any procedure/rule/formula to determine the values of driver MOSFET depending on load.?""

Like while determining the GENERAL TRANSISTOR for a load we do following
1> transistor current must be greater then load current.
2>transistor min. current gain must be 5 times the load crt. devided by max. IC crt.
3>Rb=(Vc x Hfe)/(5 x Ic) *Vc=IC supply voltage.
or Rb=(.2 x Rl x Hfe)

caze
Jul 4 2008, 11:24 AM
hi @ arun ,

i am so sorry for my last post.. i would't have post like that ..

its was really a stupid thing done by me ..

m so sory for that....
Arun Kumar V
Jul 6 2008, 7:31 PM
hi caze,

you don't have to be too formal, i was just trying to emphasize that some times these things are not mentioned in any text books and you have to rely on your experience and gut feeling.

the mosfets i suggested are used extensively in all branded and unbranded Power Inverters and are available in plenty and they suit your task.

and what is the progress in the project


Arun
caze
Aug 2 2008, 5:36 AM
hi everyone ,

my project is finished and its in final stage .
thanks to everyone for their help and time...
Arun Kumar V
Aug 3 2008, 12:13 AM


Hello Caze,

Congrats on completion of your project !




Arun
Ajay
Aug 4 2008, 7:12 AM
Congrats caze
Do not forget to publish it here on 8051projects.net
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Rickey's World © 2003 - 2007