Shop OBEX P1 Docs P2 Docs Learn Events
H bridge question — Parallax Forums

H bridge question

TyroneRTyroneR Posts: 22
edited 2012-05-21 10:23 in Propeller 1
Hello,
I found a .spin driver to controll my h bridge. I have tested the driver and succesfully it works with my h bridge. So here is my problem. Im having a hard time hooking my potentiometer to my proppeller to controller the h bridge threw the hbridge driver. if you can help me, or point me in the right direction. I would apreciate it. This is the driver that I am using.




PWM Motor Driver (H Bridge)







Thank you, Tyrone

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-17 09:46
    The link you provided doesn't work, but there are all sorts of PWM motor drivers in the Object Exchange and they all start with something like a % on time and a direction. Some use negative values for one direction and positive values for the other direction. For the purpose of discussion, let's say you've got a driver that uses a value from -100 to +100 to set the speed and direction of the motor.

    How do you want to read the value of the potentiometer? You can use the same technique used with the Stamp and its RCTIME statement. This is described in detail in the Basic Stamp Syntax and Reference Manual under the RCTIME statement. You can download this manual from Parallax's Downloads webpage under Basic Stamp Documentation. The Object Exchange has a BS2_Functions object that provides a lot of the functionality of the Stamp using Spin methods including an RCTIME method.

    Another technique would be to set up the potentiometer as a voltage divider. Let's say you have a 1K pot. A 10K pot would do as well. You connect one end of the fixed resistor to ground (Vss) and the other end to 3.3V (Vdd). The slider / wiper will have a variable voltage between 0V and 3.3V. You set up the Propeller to act as a sigma-delta ADC (analog to digital converter) as shown in the AN001 application note on the counters.

    So, one way or another, you get a number from the setting of the potentiometer. You just have to multiply or divide that number and add or subtract some base value from it to get another number that you can pass to the PWM routine to set the motor speed and direction.
  • TyroneRTyroneR Posts: 22
    edited 2012-05-17 10:16
    Thanks Mike I will give it a try.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-17 10:54
    In the future, either give the name of the object or a link to its page in the ObEx. If people add or delete other objects, its location in the lists may change.

    So, this object accepts a value from -100 to +100 as I described with 0 defined as stop. At this point, what's the question?
  • StefanL38StefanL38 Posts: 2,292
    edited 2012-05-17 10:57
    Hi Tyrone,

    first of all welcome to the propellerforum!

    To really help you it is important that you provide more iformation.
    I took a look on link that you posted
    your link http : / / forums . parallax . com / objects / 455/
    but the objects are not in the forum they are in the obex

    your description
    I got the object from the object exchange,on page four. Sorry about that
    is much to vague as is would help.
    Page four of the OBEX
    - in view all objects?
    - in view motor control ?
    search results for pwm?
    search results for h-bridge?

    I guess you meant this object http://obex.parallax.com/objects/455/

    The sourcecode of the object is very important. How should anybody help you without knowing the sourcecode you are using??

    You might have a wrong picture about how electronics in the microcontroller-world works.
    In the microcorntroller-world things are NOT standardised as in the PC world. In the PC-world take any kind of USB-device plug it into any kind of PC., laptop netbook, tablet or whatever
    and the thing will work (if you or windows got the right driver)

    In the microcontroller-world things are not standardised like this. It would be very helpful if you tell us what you want to do in the end. Give us an overview about your project.
    If all you want to do is that a potentiometer should determinate the speed of a motor. You wouldn't need the propeller-chip at all. A simple NE555 to drive a MOSFET would be enough.

    how fast does the potentiometer or another "inputdevice" change its value. Depending on this speed there are different ways how to interface to the potentiometer.
    slow speeds (method RC-time) high-speed method sigma-delta ADC (which does not work reliable for the DIP-40 housing of the propeller-chip) alternative using an external ADC like the MCP3208.

    If the potentiometer is just for testing and later you use different ways to setup the motor-rpm do it right now this other way.

    So next step is that you provide information about your project what you want to do IN THE END

    best regards
    Stefan
  • TyroneRTyroneR Posts: 22
    edited 2012-05-17 18:40
    Thanks StefanL38,
    Yeah it makes more sense to give more detail. The object you have above is the driver i am refering to. What I am trying to do is power an mosfett h bridge with that object. I have tested it and it works fine.The only thing I have done with object is adjust the PWM Freq. and conected my propeler and loaded the object. The motors I am using are 24v 14amp. What I want to do is controll the hbridge with a pot by hand(forward,reverse,and speed). The motors are high powered and are fast.
    In the end I want to make a high powered servo. I have cogs and chains to connect to the motor for the torq needed. Also I think the MCP3208 would probably be the best choice. I looked at the data sheet, and from you're suggestion I think I want to go with that. What would be the best way to hook it up to the pot and hbridge? Does it need the propeller?
    Thanks Tyrone,
  • StefanL38StefanL38 Posts: 2,292
    edited 2012-05-18 00:28
    There are still some more things to be cleared:
    Do you want the pot to use in way a or way b

    way A:
    middle-position of the pot means motor stands still no rpm
    turn pot from middle to the right means motor turns clockwise
    turn pot from middle to the left means motor turns counter-clockwise


    way B:

    You have a switch for motor-direction
    switch-position 1: motor turns clockwise
    switch-position 2: motor turns counter-clockwise

    Pot at left end 0 rpm
    Pot at right end max rpm

    I'm no expert about control-circuits that give their signals towards H-bridges
    From my medium experience I suggest for way A the propeller is one way you can do it.
    If somebody who is a more advanced expert about H-bridges than me can chime in. This person
    might know a circuit for way A that works without propeller too.

    For way b a PWM-circuit using a NE555-chip is enough.

    I'm pretty sure lokking at a rotating a DC-motor cw/ccw is not the final purpose of your project.

    Just some really wild guessings:
    - Are you building a kitchen-machine for mixing cake-ingredients?
    - are you building an electric driven car similar to a golf caddy?
    - are you building a winch to move loads up and down?

    Are you planning to add some more features like displaying motor-turn-direction with LEDs, motor-rpm on a LCD or a 7-segment display etc. ?
    which are reasons to use the propeller-chip instead of a "thumb" NE555 H-bridge-control-circuit

    best regards
    Stefan
  • StefanL38StefanL38 Posts: 2,292
    edited 2012-05-18 11:39
    Hi Tyrone,

    I knew as soon as you give the global overview about your project that new possabilities can be found.
    First of all rc-servos do NOT work with PWM. PWM means a regular pulsetrain with variant on/off-time ratio.

    Now standard rc-servos are controled by maybe I can call it repeated single-pulses. Every 20 milliseconds a single pulse
    of 1-2 milliseconds is send to the servo-electronic. Anyway the graphic at the link you posted is correct and could be used with a PWM-signal too.

    For positioning-purposes I suggest using a magnetic encoder from austria microsystems.

    BIG SHOUT @Duane Degn: are you ready to publish your propeller-code about the magnetic encoder?

    (Duan is developing code for the AS5055-Chip) thread is here http://forums.parallax.com/showthread.php?138736-Magnetic-Encoder-Project-(AS5055)&highlight=magnetic+encoder

    These chips offer a pretty high accuracy 4096 pulses per rotation for a low price (around $5 per piece). Very robust as the encoder works with a magnetic field.
    You can turn each normal rc-servo or any other DC-motor into a continous rotating servo which has still the ability to stop at any angle with more precision as any other rc-servo.
    for a spider-robot standard rc-servos and a propeller-chip will do.

    @OBC: I think your banana-synth is a great starting point for those guys to get a quick result that makes fun and start fiddling with the sound.
    Tyrone do your guys like to rap or make music in general?
    OBC Can you support them?
    http://forums.parallax.com/showthread.php?140128-What-do-you-get-when-you-cross-a-Propeller-with-eight-bananas&highlight=bananas

    additional edit:
    if you read the word project-management you might think "huh that's a bit oversized for what I'm doing." You may be right. But I want you to watch this video
    about a special project management method called SCRUM. http://www.youtube.com/watch?v=XU0llRltyFM
    http://www.youtube.com/watch?v=WxiuE-1ujCM&feature=related

    SCRUM is completely different to classical project management. My personal opinion is that SCRUM will become the leading method as it offers consequently evolutional
    development of projects. It comes from the software-guys but these guys are using it for hardware-developing http://blog.opensourceecology.org/2012/04/extreme-manufacturing/

    Anyway there is a good chance that even SCRUM is oversized for what you are doing. But if not and your guys can add the point
    "experienced with project-management SCRUM in their applications for a job I guess this is a big plus to choose them.

    best regards

    Stefan
  • TyroneRTyroneR Posts: 22
    edited 2012-05-19 05:48
    I think this could work for us. i am going to do some more research on the magnetic encoder.

    Thanks for youre help Stefan\
    Tyrone and kids
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-05-19 10:35
    Stefan is correct about the advantages a magnetic encoder offers.

    I've updated the AS5055 software thread (in Propeller forum). I should be able to release the software this coming week.

    I've been working on several different PCB designs for these encoders. I'm hoping to have several designs that could fit inside a CR servo and be located where the pot had previously been located. A magnet would need to be mounted to the final gear of the servo in order for the encoder to measure the servo's rotation.

    In the AS5055 hardware thread (in the general forum), I've posted designs for using these encoders with an on-board microcontroller in order to make them easier to use with Basic Stamps and Arduinos.

    @Stephan, Sorry for missing your shout. I hadn't checked this thread yesterday.
  • TyroneRTyroneR Posts: 22
    edited 2012-05-21 05:00
    Thankd Duane
  • TyroneRTyroneR Posts: 22
    edited 2012-05-21 10:23
    Thanks for the information on the magnetic encoder. I think it would be a better alternative than a regular pot. But since I am new to this, I think I am going to keep it old school for now, and use the pot until I have better understanding on my project http://digitalnemesis.com/info/docs/rcservo/ ( My Project ).
    I found this OBEX (http://obex.parallax.com/objects/285/ ) and plan to use it as a starting point to make my servo. I understand PWM is not suitable for what I am doing. but instead a timer chip like the (ADCO831) is to read the position of pot.
    I also found this (http://obex.parallax.com/objects/455/) to drive my h-bridge. I have tested this driver with my hbridge and motor and it works perfectly with my h-bridge.
    I plan to replace the SN754410 (motor driver) object inside(http://obex.parallax.com/objects/285/) with the one I found that works with my hbridge to hopefully achieve my goal. I have ordered a couple of ADC0831 chips and hopefully they will be here by the weekend.
    Q1.
    Will this work? And if so what other changes will be needed to make it work?
    Thanks for your help,
    Tyrone and kids
Sign In or Register to comment.