I just got my encoders and my Axon this week WooHoo!
I am brand new with robotics, but have a little programming and electrical knowledge.
I am trying to come up with a program that will count the number of encoder clicks from these quadrature shaft encoders
http://www.robotshop.us/PDF/rbsol01_manual.pdfmounted on the rear shaft of these motors.
http://www.robotshop.us/PDF/rbsol02_manual.pdfI have checked the Avr encoder library and it says it uses one of the encoder outs as the clock for sampling the other i don't want to do this as it defeats the purpose of using quadrature encoders in the first place for bidirectional data also it needs an external clock input which i don't see on the axon although i haven't really looked
the biggest issue i have is not knowing how to sample the input and how to do this constantly while still running a motor control algorithm
do i need a separate processor or chip? and then just retrieve the count from it? or can i do this all on one inside my control algorithm or with a timer somehow?
I am pretty ignorant of the hardware
my current idea is to sample the input and look for state changes then increment or decrement a count based on the state change from low to high.
here is my pseudo code for getting the data
set a=0,b=0,count=0
while(1)
{
sample porta and portb(how?)
if porta!=a
if(a=0)
a=1
if a>b
inc count
else
dec count
else
a=0
if portb!=b
if b=0
b=1
if b>a
dec count
else
inc count
else
b=0
}
also at the same time
Control Motor Function()
{
while(1)
{
Get count
calculate stuff
move a bit
}
}
I also need to find some wire connectors to conect to the Axon pins if someone could point me in the right direction