Discussion in "Project Help" started by    cenadius    Aug 19, 2007.
Wed Sep 12 2007, 02:41 pm
#81
as per your program.. it will surely work, only if the switch is a latched one.. i mean like the one you have in your circuit SPDT switch. the above code will work with that..
rest all parts depends on your code
and you wrote a good and correct code. so don't worry
Wed Sep 12 2007, 04:29 pm
#82
Thx for the reply. wat about the micro-tact switch? the switch which will nt remain in the"pressed" position how shud i write the code? I mean how shud i detect it after it has been pressed.


[ Edited Wed Sep 12 2007, 04:34 pm ]
Wed Sep 12 2007, 04:58 pm
#83
they are to be detected in the same way... but the thing is they wont be latched..
as per your program, you are reading a switch and then doing the work auto or manual according to the position of switch.. and after doing the work, you are again jumping back to read the switch again.. for micro-tact switches, the code wont work..
So all you can do is.. when you press the switch, clear or set a bit as per you want.. that bit can be as mode bit for your application..
So all you will do is.. read the mode bit, and see if its set then do auto if clear do manual..
and when the mode switch is pressed for changing the mode, just toggle the bit.. and mode will be changed automatically
Wed Sep 12 2007, 06:04 pm
#84
oic...actually i m using the same circuit as the rest of them... the micro-tact switches are used to control fan speed during the manual code...i was using code as below:

MANUAL: SETB P1.2
SETB P1.3
JNB P1.2,FAST
JNB P1.3,SLOW
CALL OFF

wher P1.2 & P1.3 are connected to the switches.
Then i realized it cant work.

FAST,SLOW, OFF are subroutines to control fan speed

thx for telling me it actually wont work..haiz.. i will try another code to detect the input from tis two switches.

Wed Sep 12 2007, 06:19 pm
#85
well..
try the other way i tell you..

Manul:
JNB key1,off
JNB key2,slow
JNB key3,fast
sjmp manual

off:
;your code for fan off
JNB key1,$
sjmp manual

slow:
;your code for slow speed
JNB key2,$
sjmp manual

fast:
;your code for fast speed
JNB key3,$
sjmp manual

try this one.. is better.. it waits for user to release key and then go back for scanning agian..
Wed Sep 12 2007, 06:36 pm
#86
If i use tis code, den i hav to add another switch?
i m wondering that must i "SETB Px.x" to use the particular pin? i do nt hav a correct idea wat must i write for the code to use hardware(the switch) to control the flow.
i juz learn it from some example codes,which they will use SETB Px.x before they start detecting the input from the pin.
Anyway thx alot for ur reply.. i hav asked lots of ppl (seniors, lecturers) they dun seem like wan to help ..
Wed Sep 12 2007, 07:33 pm
#87
there is no need to do setb Px.x as by default on startup all the pins are i/p pins so no need to make then i/p again.
In the code i wrote above..
its goes this way..
in first three lines of code.. it wait for any key to press.. and waiting in the loop until a key is pressed. as soon as a key is pressed.. it jumps to the label specified..
after jump it execute that part of code.. and the statement
JNB keyx,$ will wait for user to release the key.
and as soon as user release the key.. it again wait for key press from the user...
Wed Sep 12 2007, 08:37 pm
#88
oo..so i need 3 pins/switches(key1,key2 and key3) to control the fan speed, m i right? coz i plan to use only 2 pins in the beginning , but since u tell me tis code is easier to b used den i will change it to 3 pins. thx again...


Wed Sep 12 2007, 11:36 pm
#89
Yes you have to use 3 keys...
and fourth for Auto/Manual.. it depends on you if you want it as the SPDT switch or micro-tact switch.. accordingly program will change..
Sat Sep 15 2007, 01:00 am
#90
I need help regarding the report.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am
DonaldKnown
Thu Apr 18 2024, 12:24 am
utaletxcyw
Wed Apr 17 2024, 10:21 am
Anthonyvab
Wed Apr 17 2024, 08:48 am
RobertCix
Wed Apr 17 2024, 06:46 am