BB Blue with single pulse encoder input

395 views
Skip to first unread message

Mark Barton

unread,
Jun 22, 2017, 7:12:33 PM6/22/17
to beagl...@googlegroups.com
Hey All,
I am trying to use a Beaglebone blue with a cheap
single pulse encoder (Sparkfun
https://www.sparkfun.com/products/13260). I have
connected the pulse output to both eQEP A and B
connection on the blue thinking this will work,
but I am not so sure that this is legitimate. I do
see the pulse count up, but sometimes the
accumulated pulse value will actually decrease. I
suspect this might be a issue since the edge
feeding the two inputs are aligned.

I am using Strawson Design Roboticscape code and I
am displaying the count returned by the
rc_get_encoder_pos function. Also the pulse train
out of the encoder looks good.

From /etc/dogtag: BeagleBoard.org Debian Image
2017-03-19

As usual any help or thoughts is greatly appreciated.

Mark

Clark Sann

unread,
Jun 23, 2017, 7:56:39 AM6/23/17
to BeagleBoard
Mark

I suspect your cheap encoder is incompatible with the Blue. The BB Blue is designed to operate with quadrature encoders. The Sparkfun site does not indicate your encoders are quadrature. There's a lot of other gobblygook in their encoder specifications...magnets and sensors etc...but sadly it's missing the word "quadrature".

Here is a link to a simple explaination of quadrature encoders....https://www.dynapar.com/Technology/Encoder_Basics/Quadrature_Encoder/

Note that the quadrature encoder A and B outputs are 90 degrees out of phase. This is critical. Without them being out of phase it is not possible to determine what direction the shaft is being rotated.

So find a way to watch both encoder outputs while you slowly turn the encoder in both directions. A dual channel oscilloscope or logic analyzer is best but you might be able to do it with LEDs or two voltmeters. The A and B pulses should never rise or fall at the same time. They need to be 90 degrees out of phase with each other.

Get back to me if you have more questions.

Clark

Mark Barton

unread,
Jun 23, 2017, 9:12:17 AM6/23/17
to beagl...@googlegroups.com
Thanks Clark for the info. The encoder is a hall
effect sensor coupled with a disk that has a
series of magnets. It is quite low resolution but
does spin at motor speed which gives several
hundred pulses per second. I am using it mainly
for learning about motor control and I really
don't care about direction at least for now.

I did notice the ePEP hardware does support a
simple up (or down) count from the A input. If
this is the case I might be able to change the
Strawson library. I will post back one way or the
other

Mark

Clark Sann

unread,
Jun 23, 2017, 10:05:36 AM6/23/17
to beagl...@googlegroups.com
> Thanks Clark for the info. The encoder is a hall effect sensor coupled with a disk that has a series of magnets. It is quite low resolution but does spin at motor speed which gives several hundred pulses per second. I am using it mainly for learning about motor control and I really don't care about direction at least for now.
>
> I did notice the ePEP hardware does support a simple up (or down) count from the A input. If this is the case I might be able to change the Strawson library. I will post back one way or the other
>
> Mark
>


Since you don’t care about direction, for now, you might try hooking the encoder to just the A channel. I’m not sure what will happen when the quadrature encoder input is missing the B channel, but it might work. Whatever you do, don’t hook the output from the sensor to both inputs, that will cause the quadrature input to be really confused….sometimes counting up and sometimes counting down.

If that doesn’t work then I think you will have to modify the eQEP code.

Clark

Przemek Klosowski

unread,
Jun 25, 2017, 3:21:14 PM6/25/17
to beagl...@googlegroups.com

On Fri, Jun 23, 2017 at 10:05 AM, Clark Sann <acs...@icloud.com> wrote:
Since you don’t care about direction, for now, you might try hooking the encoder to just the A channel.

If the decoder is in quadrature mode, this probably won't work---it needs the B channel signalling to disambiguate the direction, so I think the counter will not change. This is just my guess based on general knowledge, so I may be wrong---check it for yourself.

Mark Barton

unread,
Jun 25, 2017, 4:12:34 PM6/25/17
to beagl...@googlegroups.com
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CAC%3D1GgF8b1KVXTRh%2B3qw_Gg1RjQHhtV74TK1r_fXGizWruBs5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Yep as you and Clark have surmised, neither connecting the pulse to A and B would work nor connecting just the A input. The counter would sometimes decrement if A and B were connected, and the counter would simply toggle from 1 to -1 if only A was connected.

However the good news is I was able to get it to work by changing one of the control registers in the eQEP hardware to a simple up count. The encoder pulse is connected to the A input whereas B is not used. The pulse count is now solid on both channels.

Mark

justin...@trimble.com

unread,
Feb 28, 2018, 12:05:24 PM2/28/18
to BeagleBoard
Hi Mark,

I am interested in doing the same thing (i.e. a basic hall effect sensor connected to the encoder channel on BB Blue). 
Can you provide more details on how you got it to work? 
How did you change the control registers in the eQEP hardware?
Could you provide a code sample that I could use?

Justin

Mark Lazarewicz

unread,
Feb 28, 2018, 5:30:15 PM2/28/18
to beagl...@googlegroups.com
Depending on the mode the eQEP is configured the pulses may need to out of phase. The eQEP users guide explains this quite well


--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsub...@googlegroups.com.

Mark Barton

unread,
Mar 1, 2018, 2:27:08 PM3/1/18
to beagl...@googlegroups.com

For more options, visit https://groups.google.com/d/optout.

Hi Justin,

I modified the roboticscape source that changed  the QDECCTL EQEP register. This changed
the encoder from expecting a quadrature input to a simple up counter. Input A should be used
to sense the hall effect pulses. I can't remember, but I do believe I had to ground input B
This will only work for the first three encoders as the fourth is handled by the PRU.
I fully intended to submit my changes so hopefully they would end up in mainline code,
however I am not familiar PRU what changes were needed for the PRU. Of course I
moved on to other projects.

I hope this helps
Mark

Here are the sections of code I changed:


In roboticscape.c (just a comment change)
/*******************************************************************************
* int rc_set_encoder_mode(int ch, int mode)
*
* set encoder for quadrature pulses or single pulse. Single pulse on input A
*******************************************************************************/
int rc_set_encoder_mode(int ch, int mode){
    if(ch<1 || ch>4){
        fprintf(stderr,"Encoder Channel must be from 1 to 4\n");
        return -1;
    }
    return write_eqep_mode(ch-1, mode);       
}

In rc_nmap_pwmss.c
This is where the real change takes place

//set encoder to quadarature or single pulse mode.
int write_eqep_mode(int ch, int val){
    if(init_eqep(ch)) return -1;
    if(val == MODE_SINGLE_PULSE)
        *(uint16_t*)(pwm_base[ch]+EQEP_OFFSET+QDECCTL) = 0x8000;
    else
        *(uint16_t*)(pwm_base[ch]+EQEP_OFFSET+QDECCTL) = 0x0;           
    return 0;
}


In rc_mmap_pwmss.h

//defs for setting encoder mode
enum{
    MODE_SINGLE_PULSE,
    MODE_QUADRATURE
};

Reply all
Reply to author
Forward
0 new messages