PWM with Direction Pin Control

12 years 2 months ago #29525473 by john_jsb
I have a controller that outputs a direction and PWM out for external h-bridge. is there some way i can use this? I just don\'t have time to rewrite software for roboteq hdc2450 motor controller. This is the controller im using:
www.roboticsconnection.com/p-16-serializ...obot-controller.aspx
Can the microbasic code be used to do this? Or is there a hardware solution that could use the direction pin and pwm to scale the siganl to 0v to 5v?

Please Log in or Create an account to join the conversation.

12 years 2 months ago #29525475 by roboteq
Replied by roboteq on topic Re:PWM with Direction Pin Control
It is possible to use one of the digital input as direction.

For the command, the controller will accept PWM pulse but within some range.

If your PWM is a typical RC pulse (ie 1.5ms +/- 0.5ms) it can be fed to the controller as-is.

If the range is different, let us know what it is (on time range, off time range, repeat rate) and we\'ll let you know what can be done.

Please Log in or Create an account to join the conversation.

12 years 2 months ago #29525477 by john_jsb
Ok i\'ll have to check with a oscope and see i think it is standard rc pwm it just has a direction pin. so i assume this is done with the micro code. I have not found any examples of this sort of thing has no one else needed it. I always do things the hard way.

Please Log in or Create an account to join the conversation.

12 years 2 months ago #29525479 by Michael Burton
Hi john,

I do not work for Roboteq but have do a bit of work with the controllers. If the PWM sig is compatible it should be easy to us one of the DIN lines to change the sign for the motor command

The code would be very small just read the motor command that would be generated for PWM and apply the sign as generated by the Din you choose to use and then send the mgo command. Would you like a sample of how I would do it or are you comfortable doing it yourself?

Mike

Warning!!!!
This code has not been tested.

top:
motor1 = GetValue(_CMDPLS, 1) \'get the number calculated internaly by the controller
motor2 = GetValue(_CMDPLS, 2) \'get the number calculated internaly by the controller
digin = GetValue(_DIGIN,1) \'read the digital input lines
motor1_direction = digin and 32 \'this number depends on the din used
Motor2_direction = digin and 1 \'this number depends on the din used

\'note that the logic here could be inverted.
if motor1_direction then
motor1 = -motor1 \'set the sign of the motor direction
end if
if Motor2_direction then
motor2 = -motor2 \'set the sign of the motor direction
end if
goto top

return

Please Log in or Create an account to join the conversation.

12 years 2 months ago #29525483 by john_jsb
Thanks Mike
I\'ll try it when i get home tonight. I\'m a little confused as to whats going on here can you elaborate?

motor1_direction = digin and 32 \'this number depends on the din used
Motor2_direction = digin and 1 \'this number depends on the din used

what does the 32 and 1 mean?

if motor1_direction then
motor1 = -motor1 \'set the sign of the motor direction

\"if motor1_direction\" shouldn\'t it have a number, >< or something ?

I got to say the more i look into these controllers the more impressed i become. I\'ve always tried to go cheap but it has bit me so many times and wasted more money in the long run. I have a segway that has a broken handle that won\'t let the controller start up so i\'m thinking of useing one of roboteqs brushless controllers.
I got my joystick hooked up for manual control last night it was confusing how to set the mode so i just went to the console and entered manually for tank mode and poof it worked. by the way here is my robot
code.google.com/p/talos-ros-pkg/

Please Log in or Create an account to join the conversation.

12 years 2 months ago #29525485 by Michael Burton
I got a message from Cosma that informed me that none of this code would be needed to implement the function you require however I will attempt to give an explanation.

When the digin var was set it was a combination of all the digital input pins. Each pin could be represented by one number

1, 2, 4, 8, 16, 32, 64, 128 in decimal

if the number were represented in binary

10000000, 01000000, 00100000, 00010000, 00001000, 00000100, 00000010, 00000001

As you can see only 1 bit is set in each number

(motor1_direction = digin and 32) is a logical function that sets motor1_direction to one if true or zero if false.

the following statement gets executed only when the tested var motor1_direction is nonzero

if motor1_direction then
motor1 = -motor1 \'set the sign of the motor direction

I hope that helps

Please Log in or Create an account to join the conversation.

12 years 2 months ago #29525487 by Michael Burton
I looked at your robot. I see that you are able to build complex mechanical systems. If you need help with software I would be happy to volunteer my assistance.

Please Log in or Create an account to join the conversation.

12 years 2 months ago #29525489 by john_jsb
I might just take you up on that mike, thanks again. I hooked up the serializer and used the windows example program just to see if i can get the wheels turning. It didn\'t work not sure why yet i need to get my other laptop with ros on it to try and see if its even communicating. Now another com problem with roboteq but i\'ll start a new thread for that one.

Please Log in or Create an account to join the conversation.

Moderators: tonysantoni
Time to create page: 0.078 seconds