??? 11/24/05 11:42 Read: times |
#104107 - C2051 & Magnetic pulse generator |
Dear Members
I am trying to interface 89C2051 uC with a magnetic pulse generator attached to a DC motor. The problem is that I am unable to count exact pulses. here are few details. uC is AT89C2051 running at 12Mhz crystal. Motor is 24VDC,speed 3350 rpm. Magnetic pulse generator operates at 5VDC and generates 2 pulses per revolution, and has 2 channels.signal rise time and decay time is 85 ns typical and 400 max. I have used a counter in 16 bit mode to measure pulses, as motor is running on 3350rpm and encoder generates 6700 pulses in one minute(2 pulses per rev). My program starts the motor and count pulses and as counter counts 6700 the motor stops. so in simple words i am trying to run motor for one minute using feedback from encoder. The problem is that instead of running motor for 1 min the motor runs for only 10 seconds and stops, I have tried different values for counter but no good at all, could anyone please pass any suggestion and share there thoughts on this, Below is the program. ORG 00H LJMP MAIN ORG 00BH LJMP T1ISR MAIN: MOV P1,#0FFH MOV TMOD,#05H ;counter in 16 bit mode SETB EA SETB ET0 START: JB P1.7,START ; press button and start motor CALL DEBOUNCE JNB P1.7,START MOV TH0,#0E5H ;loading values for counter, to count 6700 pulses MOV TL0,#0D3H CLR P1.5 ; start motor CLR P1.4 ;LED SETB TR0 HERE1: JNB P1.5,HERE1 ;wait for motor stop and jump back ;to start CLR TR0 JMP MAIN T1ISR: ;timer interrupt CLR TF0 SETB P1.5 ;stop motor SETB P1.4 RETI DEBOUNCE: MOV R6, #09H LOOP4: MOV R7, #09H LOOP3: MOV R4, #09H LOOP2: MOV R5, #09H LOOP1: DJNZ R5, LOOP1 DJNZ R4, LOOP2 DJNZ R7, LOOP3 DJNZ R6, LOOP4 RET END I have connected the channel A of pulse generator to pin 3.4 of uC which is T0. I am not using second channel of pulse generator at the moment. My idea is that as it requires 2 machine cycles to recognise 1-0 transition on P3.4 so may be I am missing the pulse, but is there any way of getting around it? any thoughts would be much appreciated Regards James |
Topic | Author | Date |
C2051 & Magnetic pulse generator | 01/01/70 00:00 | |
either i or o | 01/01/70 00:00 | |
hmmm..but | 01/01/70 00:00 | |
Debug suggestions | 01/01/70 00:00 | |
Software Debounce | 01/01/70 00:00 | |
magnetic pick up tachometers experiences | 01/01/70 00:00 | |
RE: magnetic pickup tachometer | 01/01/70 00:00 | |
RS482 - Typo? | 01/01/70 00:00 | |
darn thumbs | 01/01/70 00:00 | |
This could be the reason... | 01/01/70 00:00 | |
bufer amp | 01/01/70 00:00 | |
why the UG? | 01/01/70 00:00 | |
pc scopes | 01/01/70 00:00 | |
could you | 01/01/70 00:00 | |
What tells the oscilloscope? | 01/01/70 00:00 | |
Build simple test tools to fix your unit | 01/01/70 00:00 | |
Excessive rise times during startup? | 01/01/70 00:00 | |
Good, but even better would be | 01/01/70 00:00 | |
Full story | 01/01/70 00:00 | |
thanks, so can I... | 01/01/70 00:00 | |
yes, if and only if the channel A | 01/01/70 00:00 | |
cheerz | 01/01/70 00:00 | |
Time bomb.. | 01/01/70 00:00 | |
Perhaps a little explanation? | 01/01/70 00:00 | |
setting the hysteresis | 01/01/70 00:00 | |
Thank, Erik!![]() | 01/01/70 00:00 |