Using 3 roboclaw, packet serial, USB

Questions about using encoders with the Roboclaw product line
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Using 3 roboclaw, packet serial, USB

Post by Basicmicro Support »

Yes a common ground is required between all roboclaws when you are using multiple units like that. The USB only supplies a ground between the PC and the first Roboclaw.
quentin
Posts: 17
Joined: Mon Apr 13, 2020 11:50 pm
Re: Using 3 roboclaw, packet serial, USB

Post by quentin »

Hi,

Thank you for your advises so far, I have my roboclaws running great together now.

I am wondering however if, using python, I can assign values to a single encoder channel?
Here is what I mean, is there a function, related to ResetEncoders() that would allow me to do something like ResetEncodersM1() or even something that would look like:
SetEncoderM1(), that way I could assign any value I want when the physical motor reaches a position, without impacting the other channel...

Let me know if that seems possible, in the meantime, I will go through the Manual one more time.
I have 4 more Roboclaws on the way and 3 cases to keep them nice and cool! very exciting!

Regards,

Quentin
quentin
Posts: 17
Joined: Mon Apr 13, 2020 11:50 pm
Re: Using 3 roboclaw, packet serial, USB

Post by quentin »

Found it! Great!
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Using 3 roboclaw, packet serial, USB

Post by Basicmicro Support »

So others know, it is SetEncoder, IIRC.
quentin
Posts: 17
Joined: Mon Apr 13, 2020 11:50 pm
Re: Using 3 roboclaw, packet serial, USB

Post by quentin »

Now that I have everything working like I want it (and a huge thank you to BASICMICRO staff) I need to leave some schematics behind. Would you be able to provide me with a .cmp file? I am using KiCad to render the drawing and I do not need something with too much detail but something where I could label connections and make a nice comprehensible drawing. I know there is a .igs in the download section but my CAD software only takes 2D .cmp files.

Thanks,

Quentin
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Using 3 roboclaw, packet serial, USB

Post by Basicmicro Support »

Sorry, we dont have that format cad file. I've never actualy heard of KiCad. You may be able to take the IGES file model and add it to your cad project. IGES is a very generic 3d model. There are conversion apps that can be used ot create other format CAD files from them as well.
quentin
Posts: 17
Joined: Mon Apr 13, 2020 11:50 pm
Re: Using 3 roboclaw, packet serial, USB

Post by quentin »

I was able to fix it. In the end the CAD tool I am using could not take in IGES but I only needed a "black box" so I made a quick drawing to show electrical wiring.

Now, I am almost done. If I have not explained before, I am making a glider drone LAUNCHER. So basically a automated arm with a launching ramp attached to it. 6 motors on board and 3 roboclaws.

I am trying to write a quick test routine that should bring all the motors back to their lower position and then refresh the encoders:

Code: Select all

def refresh_enc():
    rc.SpeedDistanceM1(master_address, -pitch_speed_pulses, pitch_pulses_max, 1)
    master_buffers = (0,0,0)
    while(buffers[1]!=0x80):
        master_buffers = rc.ReadBuffers(master_address);
    pitch_enc_normalize()
    rotation_enc_normalize()
    rc.SpeedDistanceM1(slave_1_address, -lift_speed_pulses, lift_pulses_max, 1)
    slave_1_buffers = (0,0,0)
    while(buffers[1]!=0x80):
        slave_1_buffers = rc.ReadBuffers(slave_1_address);
    lift_enc_normalize()
    rc.SpeedDistanceM2(slave_1_address, -launch_speed_pulses, launch_pulses_max, 1)
    slave_1_buffers = (0,0,0)
    while(buffers[2]!=0x80):
        slave_1_buffers = rc.ReadBuffers(slave_1_address);
    lift_enc_normalize()
    case_close()
    slave_2_buffers = (0,0,0)
    while(buffers[1]!=0x80 and buffers[2]!=0x80):
        slave_2_buffers = rc.ReadBuffers(slave_2_address);
    case_enc_normalize()
    rc.SpeedAccelDeccelPositionM1(slave_1, std_accel, launch_speed_pulses_slow, std_deccel, launch_ready, 1)
I need it to test 1 motor at a time as some of these motors move heavy loads and as this would be the "switch on" routine, I would be happy to see it do one thing at a time.
Basically I want to know if you think this is and ok code and if it will, like I hope it should, move a motor, wait until it stops, clean the encoder, repeat...

Thanks,

Quentin

PS: you will see that the rotation motor refrsehes but doesn't move, this is by design as I have not yet figured out a way for it to find an absolute 0 value for it to turn to. If you need to see more of the code, I can send that too.
pitch -> lifts launching platform
rotation -> rotates the entire arm/platform
lift -> raises the platform out of reach for clear take off
launch -> operates a belt that slings out the glider drone
case -> two actuators opening the launcher platform's protective case
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Using 3 roboclaw, packet serial, USB

Post by Basicmicro Support »

Are you using limit switches to reset the motors? I would recommend doing that. Alternatively you could use a hard stop and current limit.
quentin
Posts: 17
Joined: Mon Apr 13, 2020 11:50 pm
Re: Using 3 roboclaw, packet serial, USB

Post by quentin »

Yes, I am using switches. Basically making the motors travel back until they hit home and then refresh.
I haven't thought too much about current limits or hard stop but I could look into that, as I have two actuators that do not have a switch stop. I was thinking about sending them backwards a distance larger than their shaft and when they give up on not being able to clear the distance (clearing their buffer then and only then, I hope) they would reset to 0 and the routine can move on to the next motor.
Basically I have switches for rotating motors but the actuators have hard limits that they physically can't exceed... Or at least that is how I am thinking about it.

Any suggestion is welcome!
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Using 3 roboclaw, packet serial, USB

Post by Basicmicro Support »

Depending on you actuator they may have built in hard limits that disconnect the motor. The problem with these is how far they move once this trips depends on the speed the motor was moving at the time. Becuase of this I dont recommend using the hard limits built into most linear actuators. I recommend adding a limit switch on these instead. That way the speed of the motor doesnt matter. THe encoder will zero the instant the limit/home switch is triggered and how long it takes for the motor to stop will have no effect on that zero position.

Post Reply