Shop OBEX P1 Docs P2 Docs Learn Events
Need a Sense circuit without op amp — Parallax Forums

Need a Sense circuit without op amp

T ChapT Chap Posts: 4,223
edited 2006-09-25 06:21 in General Discussion
Can anyone think of a sense circuit without using a specialized IC or op amp, I have limited space an am trying to avoid adding parts, but need to monitor current on a motor and turn it off if stall detected. I am usig he SX28. I could fit a few small parts like a diode, resistor etc, but no room for DIPs.

Comments

  • T ChapT Chap Posts: 4,223
    edited 2006-09-24 09:03
    Ok here is a thought, maybe somebody with some real electronics background might know the answer as I can't test this just yet:

    Say you put an LED from an opto across the shunt, and the voltage drop across the shunt, which could be in the range of 1 volt per amp depending on an Rvalue of .1 ( guessing). Would this work to turn on an LED without having a ground? It would really be like 15v on one side of the LED and 13 on the other depending on the load.

    If by some chance this worked, then I could put 3.3 on the transistor side, and output a logic 1 to the SX without having to put in an opamp and comparator. I might have a spare opto on the board already.
  • stamptrolstamptrol Posts: 1,731
    edited 2006-09-24 12:33
    With a bit of experimentation, you can make an overload detector with a reed switch.

    Take the glass reed switch and wind several turns of insulated wire around the outside. Run your motor current through the reed switch coil. Monitor the reed contacts while you load the motor shaft.

    If you've got the right number of turns of wire on the reed switch, it will operate as the motor current increases. More turns will let the reed switch operate sooner; less turns will require more motor current to make it operate.

    Use the reed contacts as a signal to your SX28. You will have to have some code to manage the brief reed closures as the motor starts.

    You don't say how big your motor is, but I've used this technique (modified a bit) on 400 amp electric vehicle motors.

    Cheers

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • T ChapT Chap Posts: 4,223
    edited 2006-09-24 17:32
    Thanks for the idea. The motor is rated at 12v 4 amps under max load. What about ahall effect sensor? I've never used one, maybe the will output something just over the threshold to turn on an SX input. THey could actually be mounted on the motor cable it Think.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-09-24 19:06
    Why not use the comparator on the SX?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • T ChapT Chap Posts: 4,223
    edited 2006-09-24 19:29
    I thought the SX comparator only compared logic states, which would still be useful. But, what is different about just having an input logic 1 that says to stop motor? Please let me know how you meant to use it Paul. Thanks.

    I just made a Library object folr the Glass Reed and can pick some up today. That solution may work nicely, just hold an SC input low, and on contact closure, send it 3.3V. Ok that works for software shutdown, but as Bean suggested I should have hardwire option instead in case the chip locks up.

    Below is the concept stamptrol suggested which seems workable.


    **** Actually the wire coil should have been drawn on one side of the motor to reflect stamptrols idea, I have it shown on the low side still where the sense was.***

    Post Edited (originator99) : 9/24/2006 7:51:53 PM GMT
    1084 x 535 - 100K
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-09-24 21:23
    The analog comparator on the SX (pins RB0-RB2) measures and compares two analog voltages, producing a logic level out stating which input is higher. You place a low ohm power resistor in series with the motor (typically between the motor and ground, these types of resistors are called sense resistors), and place this on one of the comparator pins, use a resistor divider to establish a reference voltage, or use a reference voltage IC for a more accurate reference (voltage reference ICs have a small footprint). The reference voltage and the resistance of the resistor are chosen such that the voltage drop across the resistor is greater than the reference voltage only when a stall condition occurs. This technique uses either 3 resistors, or 1 resistor a 3 pin device. The output of the comparator can be used via software, or pin RB0 can be used to generate an automatic signal to hardware to shut down the motor.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • T ChapT Chap Posts: 4,223
    edited 2006-09-24 22:07
    Ok thanks Paul, below is what I think you are suggesting. I am curious how to do the comparison while running the motor. I suppose it could follow each iteration of motor move command. Ideally I'd like top send it to a pause loop of say 2 seconds if stall detected. I used a trim pot for REF. I am assuming the SENSE voltage is going to increase(0 to X per 1 amp increase) at higher current? So setting the REF at say 1.5 V, and finding a value that works nicely for the SENSE.

    result VAR byte
    cmpValue VAR result.0

    CMP_B = 0 ' enable comparator
    TRIS_B = %11111110 ' RB.0 is output

    main:

    serByte = RX_BYTE
    IF serByte = %00000001 THEN
    UP = ON
    PWM PW, 150, 50
    CMP_B = result ' exchange result with CMP
    IF result = 1 Then
    PauseLoop
    UP = OFF
    ENDIF
    IF serByte = %00000011 THEN
    DN = ON
    PWM PW, 150, 50
    CMP_B = result ' exchange result with CMP
    IF result = 1 Then
    PauseLoop
    DN = OFF
    ENDIF
    GOTO Main


    PauseLoop:
    pause 2000 'stay here 2 seconds
    goto main

    This code will likely not work using the PWM line as the compare only takes place after the PWM has taken place. I may have to write:

    IF serByte = %00000011 THEN
    DN = ON
    PW = 1
    'compare here
    DN = OFF
    PW = 0

    Post Edited (originator99) : 9/24/2006 10:19:08 PM GMT
    643 x 398 - 49K
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-09-24 23:40
    The circuit appears correct, the sense resistor should take precedence, since high values will decrease the efficiency of the motor. The Rsense should not be greater than 1 ohm and typically is on the order of .01 Ohms or less. While you want R to be small to improve efficency, you dont want it so small that Vsense will be·so near ground glitches in the signal occur causing false compares.·You'll have to play with the numbers to·obtain·the proper values. Vsense(stall) = I(stall)*R(sense).· Vsense(stall) should be probably between .5 and 1V, Then Vref should be set just low enough to guarantee triggering the comparator at stall.

    Im not a wiz at SX/B, so I can't offhand tell you if your code is correct. The nice thing about using the onboard comparator is you can respond via program, or via hardware using RB.0. If doing the hardware route, the easiest method would be to use two AND gates·to and the comparator output with the both the UP and DOWN signal before they enter the resistor leading to the opto-isolators. However what this will do is cause the motor to stutter because it will stall, clear the stall, stall again ad-infinitum. There is a way of keeping it from doing this by using flip flops (S-R or D type with S-R inputs), but you need to make it so the SX can detect such a situation since the hardware will reset the motor and clear the stall condition and its associated comparator result. This can be done via comparing the expected motor state (the output UP and DOWN) with the actual motor state (the output of the flip-flop)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.

    Post Edited (Paul Baker (Parallax)) : 9/24/2006 11:45:43 PM GMT
  • T ChapT Chap Posts: 4,223
    edited 2006-09-25 00:34
    Many thanks Paul, that is a big help. I will go the software route, and have boards made up with what I have shown you, and deal with the software when I get the boards in.

    I will have RB.3 asssigned as a variable on bootup, and set it to HIGH. I'll run that pin to an AND to the LOW side of the Hbridge PWM. A positive result in the comparator will set the pin to LOW until the machine is rebooted, plus do a software pause too on stall condition as well, then the machine will not run any longer until power cycled.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-09-25 01:46
    No problem, glad to help. To avoid the problem of the SX going into software lockup, you should use the watchdog timer. This will need to be done after your testing of code since it's incompatible with the in circuit debugging. The response from a watchdog timer reset should be to turn all motors off, this can be done during normal power up so you should have to test for a time out, just set all motors to off right after initalizing the pins to outputs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • metron9metron9 Posts: 1,100
    edited 2006-09-25 06:21
    Just in case you want to try a sense IC, I have used the ZXCT1009FTA or digikey# ZXCT1009FCT-ND

    I use the sot23 package. Tiny buggers they are though.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think outside the BOX!
Sign In or Register to comment.