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.

8051 Assembly to control switches

Status
Not open for further replies.

Meero

Newbie level 1
Newbie level 1
Joined
Dec 21, 2004
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
10
Hello,
I was wondering could you describe the code i need and the hardware configuration i need to control
input swtiches on a medical device. The switches are driven by 5 volts, could I just attach say P2 on my
AduC812 microcontroller to the switches. I need the code to activate every 10 mins. This is the algorithm:
Switch 1 pressed, delay (1 sec).Switch 2 pressed, delay (1 sec).Switch 4 pressed, delay (1sec). Switch 2 pressed
delay (1 sec). Switch 2 pressed again delay (1sec). Switch 2 pressed once more, delay 1 sec. Switch 3 pressed, delay 15 secs.
Finally, switch 1 pressed. 10 mins later start the process again.
A code example would be great.Thanks.
 

That depends on the current drawn by the switches. If it is less than, say 5mA, you can use 1k pull-ups and connect directly to the CPU pins. However, because it is a medical device you should use optical isolation (example:74OL6000 which is TTL-to-TTL buffer).
Code:

Do you know how to start, what pins would you like to select as DOs (digital outputs)...to activate Switches,.. are Switches activated by H or L level, what is the frequency of the CPU's clock (you will need this to setup timers to count time)..

;Definitions

Switch1 P1.0
Switch2 P1.1 and so on..

Next you will have to declare the following:

ORG 0000h
LJMP Start

ORG 000Bh
LJMP Timer0_Int ; Timer0 overflow..

ORG 001Bh
LJMP Timer1_Int ; Timer1 overflow..

Start: ; here the main code will start


Depending on which assembler you use the code will slightly differ..
Which 51 family member do you have?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top