Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/04/06 15:30
Read: times


 
#115592 - UP Down and zero not really difficult.
Responding to: ???'s previous message
Dear Manan,

Your HCTL2020 has U/D output telling you if it is counting up or down. It also has output to to indicate if theres an overflow / underflow.

For your DRO application I would do the following,

1. Move the machine table to home machine at start up and reset the encoder.

2. Tie the state change output of HCTL to an interrupt and read the decoder count when ever there is an interrupt.

3. Also read the Overflow If there is an overflow read the u/d pin to determine it is underflow or overflow. If it is overflow Add 0xFFFF as offset to the reading from HCTL. Everytime an overflow is detecting go on increasing offset by 0xFFFF.

4. If U/d detects down count and at the same time overflow this indicates an underflow. In this case subtract 0xFFFF from offset.

5. Remember that at underflow the HCTL count becomes 0xFFFF and with further down counts the count goes like 0xFFFE 0xFFFD....... To handle this what you need to do is read the U/D pin and if it is down count then the actual value is -(0xFFFF-read value) for example if you decoder reads 0xFFFD and it shows down count then the actual reading is -(0xFFFF-0xFFFD) = -2.

The above can be sumarrised like this.

1. Reset countet at start counter=0x0000.
2. Counter shows 0x1234 decoder says its couting up no overflows yet DRO should dispay 0x1234 = 4660
3. Counter reads 0x0000 and overflow set and it says its counting up. You need to add offset 0xFFFF to the read value making DRO display 65535.
4. Your counter reads 0xFFFF and overflow set and says its couting down. You need to subtract offset 0xFFFF from present counter value.
5. Counter reads 0xFFFA and it says it is couting down. Your DRO should display -(0xFFFF-0xFFFA)= -5.

Thats it nothing complex in it.

Also remember that your Decoder output pulses [ U/D, OVerflow, Transition] are very narrow and they depend on the HCTL clocking freq. At high clks of decoder the pulses are narrow enough to be detected by standard 8051 micros. In that case you may need to use a monoshot to increase the signal pulse width.

Try to write program for your app using above info and if still in trouble come up with specific questions. Asking questions like how to detect zero or how to detect up down are difficult to unerstand and answer.

Hope this helps.

Regards,
Prahlad Purohit

List of 9 messages in thread
TopicAuthorDate
Detect UP or Down detect            01/01/70 00:00      
   CJNE may solve your problem            01/01/70 00:00      
   Err...            01/01/70 00:00      
   Why Separtae Beast            01/01/70 00:00      
      WHICH ''counter I.C."            01/01/70 00:00      
      detail            01/01/70 00:00      
         More detail?            01/01/70 00:00      
            that consitute work on the behalf of the            01/01/70 00:00      
   UP Down and zero not really difficult.            01/01/70 00:00      

Back to Subject List