Quote:
Originally posted by Rickertsen2
could you be so kind as to post the asm code for the PICs that interface w/the encoders? im not very good with asm. I havn't had the time to learn it.
|
We have decided not to use a PIC because it would not be something that our highschool students could program or understand completely within the 6 weeks. Instead, we purchased a basic stamp 2p, which has software (polled) interrupts.
The encoder hardware consists of an IR break-beam sensor (digikey: OR518-ND) connected to a ripple-carry counter. The purpose of the counter is to offload the actual counting from the microcontroller because the microcontroller can only poll the pins and has the potential to miss counts. With the hardware counters, we can feed them a signal up to a few megahertz with no problems. So, the encoders on the wheel will be very precise, along the lines of 100 counts/revolution (before actually working the numbers). All while the basic stamp gets a nicely formed digital signal from the counters. Only one of the output lines from the counters will be hooked up to the microcontroller. Each consecutive output on the counter will toggle at half the speed of the last with twice the period, so we can choose which of those pins gives the processor enough time to count without compromising resolution.
So, the code we will be using will setup the polled interrupts on the counter input pins of the basic stamp. Then whenever a rising edge occurs, the stamp will run the interrupt page of code that polls the pins to see which encoder caused the interrupt, then add 1 to the corresponding variable location (in scratchpad ram).
good luck.
-Craig