PDA

View Full Version : Encoder/Motor control



mc33033
- 20th February 2006, 15:20
Hi everyone,

I want to do something that I imagine lots of people have done before, but I don't know the best way to do it!

I have a small dc motor which drives via a pulled a rod which has a worm gear on it and a arm moves up and down the pulley (part of an old CD duplicator robot). There is a small disc with stripes on it at the end of the pulley and a "transmissive encoder sensor". That's the background, the idea is that if the arm hits something, the PIC recognises a lack of change in the encoder and stops the motor. Hooking it up is OK, but what method do I use for reading in the pulses? Pulsin or count over a time period (or something else?) The motor will no doubt take a fraction of a second to spin up, too - this may also need to be taken into account. I'd appreciate any advice, thanks!

G8RPI
- 20th February 2006, 15:45
Hi,
A quick and dirty way of doinig this is to use PULSIN. If the value returned is zero then there was no pulse. Note that PULSIN will take .65 seconds to time out if there is no pulse, this can be reduced by using the DEFINE PULSIN_MAX
A value of 1000 will time out in 0.01S (assuming a 4MHz clock).

HTH,
Robert G8RPI.

mc33033
- 21st February 2006, 20:43
Hi Robert, I think I'm getting there. I've used pulsin successfully now to detect movement after wasting a lot of time by not putting CMCON=7 at the head of the file :-(

Thanks again!