officinerobotiche / uNAV.X

Project MPLABX for drive uNAV on dsPIC33
http://rnext.it/project/unav/
MIT License
9 stars 2 forks source link

Encoder swap must be configurable #17

Closed katodo closed 9 years ago

katodo commented 9 years ago

For each encoder QEI module the QEIxCONbits.SWPAB bit must be configurable to simplify encoder connection.

Myzhar commented 9 years ago

Sure? This means that according to this bit you can connect A & B as you want and then you can change the rotation verse by software... I think this is dangerous. Cable must be assembled in one way only and if you make a wrong cable you disconnect it and you redo it. Too much variables of this type bring a lot of confusion and when something is not working correctly you do not understand what's wrong....

This is valid if I understood the correct functionality of the pin :-)

guiott commented 9 years ago

Often you connect the two motors in the same way to the cables but the left one must rotate in reverse direction compared to the right one. IMHO It’s useful.

Il giorno 10/dic/2014, alle ore 00:20, Walter Lucetti notifications@github.com ha scritto:

Sure? This means that according to this bit you can connect A & B as you want and then you can change the rotation verse by software... I think this is dangerous. Cable must be assembled in one way only and if you make a wrong cable you disconnect it and you redo it. Too much variables of this type bring a lot of confusion and when something is not working correctly you do not understand what's wrong....

This is valid if I understood the correct functionality of the pin :-)

— Reply to this email directly or view it on GitHub https://github.com/rbonghi/uNAV.X/issues/17#issuecomment-66377545.


http://www.guiott.com/

katodo commented 9 years ago

Tank you @guiott , we can use QEIxCONbits.SWPAB configuration in different mode:

Mode1 -> QEI1CONbits.SWPAB in opposition of QEI2CONbits.SWPAB bit: in this case is used to change the "front direction" of robot.

Mode2 -> Only QEI1CONbits.SWPAB or QEI2CONbits.SWPAB bit swappable: useful to use fixed wiring.

Mode3 -> QEI1CONbits.SWPAB and QEI2CONbits.SWPAB bit indipendent: This is case with mayor risk and benefit :)

To reduce user configuration difficult we can introduce an auto learn mode in future, by protocol we can enable this mode and turning the wheel by hand ( if it's possible ) software can establish right QEIxCONbits.SWPAB configuration :) But, this is future :)

rbonghi commented 9 years ago

Now I modified a old message parameter_motors and I dived in two struct, the first one, with only parameter associated ad unicycle platform and the last with parameters associated only at motors:

/**
 * Parameters definition for unicycle robot:
 * - radius (left and right)
 * - wheelbase
 * - minimal space for odometry
 */
typedef struct parameter_unicycle {
    float radius_r;
    float radius_l;
    float wheelbase;
    float sp_min;
} parameter_unicycle_t;
#define LNG_PARAMETER_UNICYCLE sizeof(parameter_unicycle_t)

In new structure parameter_motor_t you can modified the encoder swap and default level Enable bits.

/**
 * Parameter definiton for motor:
 * - k_vel
 * - k_ang
 * - boolean encoder swap
 * - boolean set enable
 */
typedef struct parameter_motor {
    float k_vel;
    float k_ang;
    uint8_t encoder_swap;
    uint8_t enable_set;
} parameter_motor_t;
#define LNG_PARAMETER_MOTOR sizeof(parameter_motor_t)

I update serial_bridge repository https://github.com/officinerobotiche/serial_bridge with new feature. If you like to try this feature switch branch to https://github.com/officinerobotiche/uNAV.X/tree/feature/message_pin_conf feature/message_pin_conf (the same on serial_bridge) and test.

Myzhar commented 9 years ago

This is a good choice. Please add a comment for each variable of the structure to describe their functions. This is important for motor parameters

rbonghi commented 9 years ago

Thx @Myzhar , In the real repository I wrote a link to officinerobotiche wiki's https://github.com/officinerobotiche/uNAV.X/blob/feature/message_pin_conf/includes/packet/motion.h#L117 to understand and set correct value on parameters.

Now I must write the page on wiki: http://wiki.officinerobotiche.it/index.php?title=Robot_configuration_guide :+1:

katodo commented 9 years ago

I'm testing encoder_swap functionality but don't work. In yaml file I'm changing "encoder_swap" pararameter for test:

Left: {k_vel: 27925268.0, k_ang: 0.00017453292093705386, encoder_swap: 1, default_enable: 0} Right: {k_vel: 27925268.0, k_ang: 0.00017453292093705386, encoder_swap: 0, default_enable: 0}

I've placed MPLABx in debug mode on parsing_other_messages.c row 92 and 97 and in info->packet.parameter_motor.encoder_swap variable I don't see any change in relation with yaml change.

Obviously, after any change of https://github.com/officinerobotiche/example_robot_ros/blob/master/example_robot.yaml file, I close roscore and any other node.

rbonghi commented 9 years ago

The problem is in repository serial_bridge: https://github.com/officinerobotiche/serial_bridge/tree/feature/message_pin_conf

rbonghi commented 9 years ago

Solve with 7c521dc7b8a8784a64661951bae9efc6258d1f5d