Asked — Edited
Resolved Resolved by DJ Sures!

Roli Hbridge Movement Settings In Tutorial 43 (C# Sdk)

Which digital ports and which PWM settings should be used in Tutorial 43 to work with the Roli robot configuration?

More detail about what I'm seeing in case it helps...

When I use ARC's standard Roli project, the "Hbridge PWM Movement" control works fine. When I attempt the same behavior with Tutorial 43 code from the C# SDK, I do not get the same robot motor movements. In most cases, I get no movement at all. In the best case I've come across, I'm able to get one motor moving, but incorrectly (it goes backward when calling the EZB.Movement.GoLeft() method).

Since I'm able to get the correct behavior in ARC, this indicates to me that there are no issues with the robot assembly or hardware. It also indicates that the Tutorial 43 code is not identical to the code being used in ARC. In ARC, the instructions on how to assemble the Roli indicate the following HBridge settings:

HBridge Left Trigger A: D1 HBridge Left Trigger B: D2 HBridge PWM Left: D0

HBridge Right Trigger A: D3 HBridge Right Trigger B: D4 HBridge PWM Right: D5

The above settings don't match the default Tutorial settings. The default Tutorial settings don't work, so I tried the following code in Tutorial 43's Form1_Load method to see if using the instructional settings above might work better:

ezB_Connect1.EZB.Movement.MovementType = EZ_B.Movement.MovementTypeEnum.HBridge; ezB_Connect1.EZB.Movement.HBridgeLeftWheelTriggerA = EZ_B.Digital.DigitalPortEnum.D1; ezB_Connect1.EZB.Movement.HBridgeLeftWheelTriggerB = EZ_B.Digital.DigitalPortEnum.D2; ezB_Connect1.EZB.Movement.HBridgeRightWheelTriggerA = EZ_B.Digital.DigitalPortEnum.D3; ezB_Connect1.EZB.Movement.HBridgeRightWheelTriggerB = EZ_B.Digital.DigitalPortEnum.D4; ezB_Connect1.EZB.PWM.SetPWM(EZ_B.Digital.DigitalPortEnum.D0, EZ_B.PWM.PWM_MAX); ezB_Connect1.EZB.PWM.SetPWM(EZ_B.Digital.DigitalPortEnum.D5, EZ_B.PWM.PWM_MAX); ezMovement1.SetEZB = ezB_Connect1.EZB;

I got no movement from any of the motors when calling any of the button click methods in the tutorial.

I tried commenting out each of the PWM.SetPWM calls, but it had no effect.

I used a debugger breakpoint to verify that the button click events were in fact firing and the ezB_Connect1.EZB.Movement methods were completing successfully (GoForward(), GoStop(), GoRight(), GoLeft(), GoReverse()).

It seems like the most likely problem is probably that the incorrect digital ports are being assigned to the ezB_Connect1.EZB.Movement.HBridge... properties and passed to the ezB_Connect1.EZB.PWM.SetPWM() method.

Could you please confirm which digital ports should be assigned to each ezB_Connect1.EZB.Movement.HBridge... property to match what ARC is doing for the standard Roli configuration?

And could you also please confirm what digital port(s) should be used when calling ezB_Connect1.EZB.PWM.SetPWM()?

And do you see any other issues that might cause the ARC code to be different from the Tutorial 43 code and cause this problem?

Many thanks in advance for your help!


ARC Pro

Upgrade to ARC Pro

Become a Synthiam ARC Pro subscriber to unleash the power of easy and powerful robot programming

PRO
Synthiam
#1  

The tutorial for HBridge is not related to roli.

You can view the roli assembly tutorial to obtain the ports for roli.

#2  

DJ Sures, thanks, but I already consulted the assembly tutorial and the ports listed there do not work. See my post above for more detail including the exact port settings from the tutorial, and the specific lines of code I used to reflect those port settings.

Could you maybe copy/paste the relevant ARC code, including port settings and any other relevant lines of code you have there?

Any help would be appreciated. Thanks again.

PRO
Canada
#3  

Hi @chas9000c

One thing to keep in mind is that we do have the motors hooked up in a specific polarity pattern on our H-bridges. Assuming you have motors with the positive marker labelled and are using an L298 H-bridge this would be the configuration:

OUTA - Right Motor Positive OUTB - Right Motor Negative OUTC - Left Motor Negative OUTD - Left Motor Positive

You could try swapping polarities when using the SDK.

Hope that helps!

#4  

Jeremie, thanks for the additional info. I opened up the Roli to check, and I can confirm it is wired as you describe:

OUTA - Right Motor Positive OUTB - Right Motor Negative OUTC - Left Motor Negative OUTD - Left Motor Positive

I'm assuming that physically changing the wires to reverse the polarity would be the same as switching TriggerA vs. TriggerB in the code. So, I changed the code to reflect this, but still got no movement. Here's the exactly lines of code changed:

ezB_Connect1.EZB.Movement.HBridgeLeftWheelTriggerA = EZ_B.Digital.DigitalPortEnum.D2; // Used to be D1 ezB_Connect1.EZB.Movement.HBridgeLeftWheelTriggerB = EZ_B.Digital.DigitalPortEnum.D1; // Used to be D2 ezB_Connect1.EZB.Movement.HBridgeRightWheelTriggerA = EZ_B.Digital.DigitalPortEnum.D4; // Used to be D3 ezB_Connect1.EZB.Movement.HBridgeRightWheelTriggerB = EZ_B.Digital.DigitalPortEnum.D3; // Used to be D4

The encouraging thing is that we already know what the solution is: The code in the ARC's "Hbridge PWM Movement" control works fine. So if I could see what that code looks like, I should be able to recreate the same behavior as ARC.

Thanks again.

#5  

@DJ Sures, I would be happy to create a nice, simple tutorial folder in C# for you to include in your next SDK release if you could send me the relevant code from the ARC's "Hbridge PWM Movement" control, including any variable assignments specific to how that control would work when loading the standard Roli project in ARC. Less work for you, new valuable SDK tutorial for customers, my problem resolved, everyone wins!

Would that work for you?

If so, you could send the code either through this community or in private; just let me know where I should send you the ZIP'ed tutorial folder when I'm done.

Thanks again.

PRO
Synthiam
#6  

The HBridge PWM Movement Panel in ARC is not part of the SDK and lives within the ARC framework, which is different than the SDK.

From the LEARN Tutorial of Roli, here are the wire codes

Quote:

D0 - Green (Left PWM) D1 - Blue (Left Trigger A) D2 - Purple (Left Trigger B) D3 - Grey (Right Trigger A) D4 - White (Right Trigger B) D5 - Black (Right PWM)

If you are running an HBridge with PWM, you need to do this (Specifically for roli) set to MAX Speed...


      ezB_Connect1.EZB.Movement.MovementType = EZ_B.Movement.MovementTypeEnum.HBridge;
      ezB_Connect1.EZB.Movement.HBridgeLeftWheelTriggerA = EZ_B.Digital.DigitalPortEnum.D1;
      ezB_Connect1.EZB.Movement.HBridgeLeftWheelTriggerB = EZ_B.Digital.DigitalPortEnum.D2;
      ezB_Connect1.EZB.Movement.HBridgeRightWheelTriggerA = EZ_B.Digital.DigitalPortEnum.D3;
      ezB_Connect1.EZB.Movement.HBridgeRightWheelTriggerB = EZ_B.Digital.DigitalPortEnum.D4;

     // Set the PWM for the HBridge to MAX speed
      ezB_Connect1.EZB.PWM.SetPWM(EZ_B.Digital.DigitalPortEnum.D0, EZ_B.PWM.PWM_MAX);
      ezB_Connect1.EZB.PWM.SetPWM(EZ_B.Digital.DigitalPortEnum.D5, EZ_B.PWM.PWM_MAX);
   
      // Sample how to make the robot move forward
      ezB_Connect1.EZB.Movement.GoForward();

If you are using sliders to control the speed, you need to set the movement type to HBridgePWM and sliders or controls for the speed, you do this...


      ezB_Connect1.EZB.Movement.MovementType = EZ_B.Movement.MovementTypeEnum.HBridgePWM;
      ezB_Connect1.EZB.Movement.HBridgeLeftWheelTriggerA = EZ_B.Digital.DigitalPortEnum.D1;
      ezB_Connect1.EZB.Movement.HBridgeLeftWheelTriggerB = EZ_B.Digital.DigitalPortEnum.D2;
      ezB_Connect1.EZB.Movement.HBridgeRightWheelTriggerA = EZ_B.Digital.DigitalPortEnum.D3;
      ezB_Connect1.EZB.Movement.HBridgeRightWheelTriggerB = EZ_B.Digital.DigitalPortEnum.D4;
      ezB_Connect1.EZB.Movement.HBridgeLeftWheelPWM = EZ_B.Digital.DigitalPortEnum.D0;
      ezB_Connect1.EZB.Movement.HBridgeRightWheelPWM = EZ_B.Digital.DigitalPortEnum.D5;

      // Set the speed through some control or what ever you're using
      byte speed = 255;

      // sample how to make the robot move forward
      ezB_Connect1.EZB.Movement.GoForward(speed);

#7  

@DJ Sures, thanks. I finally got it working. As promised, I've packaged up a new tutorial and sent it to you by e-mail.

The bizarre thing about this is that your first code was virtually identical to my original code, and it didn't work when I used your code. However, when I moved the code from the Form_Load() event to a button click event, it started working. But when I then moved it back to the Form_Load() event (with no changes) it worked from there, too, even though it hadn't originally worked from that event. The best I can guess is that perhaps there was something strange going on with the compiler, and I might have solved the issue with a Clean/Rebuild.

Regardless of what the root cause was, I've got it working now and have packaged up a new tutorial that uses the HBridgePWM technique in your second code sample so that the new tutorial offers something beyond Tutorial 43. Hope that helps.

Thanks again for your help.

#8  

I used to have that kind of problem when I used VB6. I would copy a piece of code that used an activeX control into a new project and it wouldn't work, but if I retyped the exact same thing, it would. Sometimes I could just backspace the line to the last "." and start retyping and it would autocomplete and work fine after that.

Alan