This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BeagleBone Black Bare-Metal eQEP Driver

Hello,

Walking through the starterware driver, I found that there are drivers for PWM and eCAP modules. But I didn't find a driver for the eQEP module although the pins of the three eQEP modules are connected to headsers P8 and P9 on the beaglebone black. Is there a specific technical reason?

Best regards, 

  • I think the reason is simple: the drivers are incomplete. So I afraid you have to write it for your own. What do you want to do with QEP? May be I have some code for you...

  • Thanks qxc for your reply.

    I'm working in a project to build a control system for electromechanical and servo-hydraulic machines.

    I need to write bare-metal code of a servo-control algorithm and communicate with the PC through USB/Ethernet.

    I'll read a position signal through the eQEP input and then a PID will generate a PWM/analog signal for motor control.

    Let me know if you have any thing to help me out.

    Best regards,

  • Assumed power domain and clock are already enabled and pin-muxing is done properly in order to enable the QEP inputs, the code is quite simple. For QEP0:

    // initialise
    HWREGH(SOC_EQEP_0_REGS+QEP_QDECCTL)=0x0800;
    HWREGH(SOC_EQEP_0_REGS+QEP_QEPCTL) =0x1038;
    HWREG(SOC_EQEP_0_REGS+QEP_QPOSMAX) =0xFFFFFFFF;
    HWREG(SOC_EQEP_0_REGS+QEP_QPOSINIT)=0x7FFFFFFF;
    HWREGH(SOC_EQEP_0_REGS+QEP_QCAPCTL)=0x0000;
    
    // reset counter to value defined by QEP_QPOSINIT
    HWREGH(SOC_EQEP_0_REGS+QEP_QEPCTL) =0x10B8;
    
    // read current position
    int_fast32_t currPos;
    
    currPos=HWREG(SOC_EQEP_0_REGS+QEP_QPOSCNT)-0x7FFFFFFF; // let it become negative for movements in negative directions