| ??? 07/18/03 12:03 Read: times |
#50952 - RE: First Step....Mr. Fedia Responding to: ???'s previous message |
Hi Rashu,
it is maybe my fault, I should explain some more. The example I gave is really an example. It has really these errors you had observed. Why? Let remember the basics of a programmable controller and how the 'user' program is handled. Start: Read all inputs (make input image) Execute user program (work with image here) Write the output image to the outputs Go to Start It is very rare case when a PLC will use the real inputs, usually in high speed routine, and this should be a subject of special attention by the programmer. "Real" outputs are usually not used by PLC program itself. In your case, if a NPN transistor is connected to P2.0, you really will read always 0 from P2.0 and this I think was discussed before on this forum. lets see it. assume we have 16 inputs at P0 and P1, 8 outputs at P2 bIN_0 equ 020h ;in bit addressable space! bIN_1 equ 021h ; bOUT_0 equ 022h ; Start equ bIN_0.0 Stop equ bIN_0.1 OVL equ bIN_0.2 K1 equ bOUT_0 begin: ; Read all inputs mov A,P0 mov bIN_0,A mov A,P1 mov bIN_1,A ;user program ;..Start.. Stop...OVL...........K1 ;|---||-+---|/|----|/|----------( )----| ;| K1 | ;+---||-+ ;with macros: in asm: _RD Start mov C,Start _OR K1 orl C,K1 _ANDNOT Stop anl C,/Stop _ANDNOT OVL anl C,/OVL _WRT K1 mov K1,C ;... more statements ;END2 user program ; Write the output image to the outputs mov A,bOUT_0 mov P2,A jmp begin hope this helps, regards, Fedia |



