Shop OBEX P1 Docs P2 Docs Learn Events
PWM usage with Solenoid proprtional valves?? — Parallax Forums

PWM usage with Solenoid proprtional valves??

SiriSiri Posts: 220
edited 2008-12-09 00:06 in Propeller 1
I am working on a project that requires to mix two(2) gases 0% to 100%- that is when gas “A” is 100% - GAS “B” is 0%.When is gas “A” is 75% - gas “B” is 25% - in other words the mixture is inversely proportional all the time.

I am planning to use two solenoid proportional valves(2 identical valves).The valves are
5VDC(Specs attached) – can be driven by PWM.

The question is can I drive these two proportional valves directly with the Prop using
1-10K current limiting resistors to protect the prop and using counters specially using the differential mode.
I have not used counters before but have been reading a lot about them.

I would appreciate advice on all fronts – hardware wiring,coding hints
Any help before I do any damage to the proportional valve/PROP etc.

I do not have code written yet but plan to use both SPIN and ? PASM if needed.

Thank you.

Siri

PS:The gases A and B are very safe and are used daily with no problems in public areas.

Comments

  • LeonLeon Posts: 7,620
    edited 2008-11-25 16:50
    You need to use a driver. I'd use a suitable MOSFET.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • scottascotta Posts: 168
    edited 2008-11-25 17:33
    I would get one with a higher working voltage, one that matches your primary
    power supply (12 volts ?). This would reduce the current requirement.
  • SiriSiri Posts: 220
    edited 2008-11-29 18:06
    I taken your advise and have come up with a tentative circuit which I plan to build soon as I get my proportional valves.

    Please check my circuit diagram(attached) and further advise - if this is OK or if not suggest any changes to anty
    components,better new circuit etc,

    Thank you,

    Regards,

    Siri
  • LeonLeon Posts: 7,620
    edited 2008-11-29 18:17
    You need to ensure that the MOSFET is off when the Propeller is reset.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • SiriSiri Posts: 220
    edited 2008-11-29 19:25
    Leon,
    Can you explain why? and How would I go about doing what you suggested.
    (I am a week-end electronics junky - so you need to bring me upto speed.)

    Regards
    Siri
  • SiriSiri Posts: 220
    edited 2008-12-04 16:11
    The parts I require to connect the proportional valves required will be here to-day.

    Before I connect the Solenoid proportional valve to test them - I would like to connect the hard ware

    and test the software - PWM signal.

    I am attaching a dummy load (@ 12-15 Ohms) instead of the proportional valve and then connect the scope

    in parallel with the resistor to caprture the wave form details on the scope.

    Is this the proper way to go about doing it?

    Siri
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-04 18:19
    How much current does the solenoid draw?
    Sorry, I found the datasheet and the current looks like it's always less than 300mA which is well within the capability of a simple NPN switching transistor like the 2N2222A. A simple circuit like on the last page of Nuts and Volts Column #6 would work fine using 5V and a smaller base resistor (www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol1/col/nv6.pdf). You want about 10mA of base current to saturate the transistor when on, so you'd want a 270 Ohm base resistor. To ensure that the transistor is off when the Propeller is reset, you should have a 10K resistor between the base and ground.

    Post Edited (Mike Green) : 12/4/2008 6:31:34 PM GMT
  • SiriSiri Posts: 220
    edited 2008-12-04 22:53
    Mike,
    Thank you for your support.
    When you are reffering to the Last page of the Nut&Volts article - It is Figure 6.3 - The Stamp bar code reader circuit,right.

    Mike - I did posted a circuit diagram(the 4th post on this topic) to get some input.

    If I understand you correctly I do not require the MOSFET - just the 2N2222 transistor and the two resistors.
    I will be using PWM generated by the PROP - will this transistor able be fast enough to handle it.
    This is going to be used with a oxygen/air blender - would like this to be very reliable for the job and long hours of continuous usage.

    Thank you again,

    Siri
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-04 23:43
    This is a pretty standard transistor, rated at 800mA and 75V. It certainly should be plenty fast for PWM for a solenoid (maybe 1KHz to 100KHz).
  • SiriSiri Posts: 220
    edited 2008-12-04 23:48
    Mike,

    Thanks for all the great help

    Regards,
    Siri
  • SiriSiri Posts: 220
    edited 2008-12-06 00:07
    Mike,
    I built the circuit as you suggested - the solenoid proportional valve should be here any day.
    I wan't to test the prop code before I connect the valve.Will it be ok just to connect the scope
    across the diode(solenoid terminals) or do I need to place a load if can you suggest a test load(resistor).

    Thanks

    Siri
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-06 00:29
    Some kind of load would be helpful. You could use anything from an 18 Ohm 2 Watt resistor to a 150 Ohm 1/4 Watt resistor (or higher). The first is about the same load as a solenoid while the second is about 1/10th the load.
  • SiriSiri Posts: 220
    edited 2008-12-06 01:59
    Mike,
    Thanks for the quick reply.

    Siri
  • SiriSiri Posts: 220
    edited 2008-12-07 17:52
    Mike,

    I built the circuit as you suggested- I omitted the diode as I was using a LED for testing purposes.
    The LED does light well but I am unable to make it go dim.
    I wan't it to go dim by changing the "fraqa"

    I uploaded the circuit diagram and the code.

    The LED only lights when " frqa := 1" and not to the scale as used in the parallax examples.

    {
      Green LED to light at full brightness.
    
    
    }
    CON
    
      scale = 16_777_216                         ' 2³²÷ 256
    
    PUB TestDuty 
    
      'Configure counter module.
    
      ctra[noparse][[/noparse]30..26] := %00110                     ' Set ctra to DUTY mode
      ctra[noparse][[/noparse]5..0] := 7                            ' Set ctra's APIN
      frqa :=  1                      ' Set frqa register
      'frqa := 255 * scale              'Does not work
    
    
      dira[noparse][[/noparse]7]~~                                  ' Set P7 to output
    
      repeat                                     ' Repeat indefinitely
    
    
    
    2040 x 1540 - 107K
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-07 18:43
    I believe the bitfield notation only applies to OUTx, INx, and DIRx, not the other special locations.
    You need to use "ctra := %00110 << 26 | 7"
  • BradCBradC Posts: 2,601
    edited 2008-12-07 18:57
    Mike Green said...
    I believe the bitfield notation only applies to OUTx, INx, and DIRx, not the other special locations.
    You need to use "ctra := %00110 << 26 | 7"

    Actually, a quick look at the interpreter source seems to indicate that the [noparse][[/noparse] ] notation should work on _any_ special register in the chip.
    My main concern is that doing it the way Siri did
    ctra[noparse][[/noparse]30..26] := %00110                     ' Set ctra to DUTY mode
      ctra[noparse][[/noparse]5..0] := 7                            ' Set ctra's APIN
    



    ..leaves all other register bits indeterminate, whereas doing it the way you suggest properly initialises all register bits to what you really want them to be.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cardinal Fang! Fetch the comfy chair.
  • SiriSiri Posts: 220
    edited 2008-12-07 21:53
    Mike/BradC

    Still it does not work with "frqa:=255*scale but works with "frqa:= 1"

    Thanks for the help,

    Siri
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-07 22:06
    What does it do with the "frqa:=1" case? It should pulse the I/O pin about once every couple of minutes because your program is using the (default) RCFAST internal clock which is maybe 1/6th the speed of the 80MHz clock you get with a 5MHz crystal and a x16 PLL multiplier. Once every clock cycle, FRQA gets added to PHSA. The carry from that addition goes to the output pin. You'll get a brief (< 1us) pulse once about every 6 x 54 seconds as a PHSA value of $FFFFFFFF gets added to the $00000001 from FRQA and the result causes a carry. By default, PHSA will be zero on a reset.

    If the above is not what's happening, then there must be some difference between what you've described and what's actually running in your Propeller.
  • SiriSiri Posts: 220
    edited 2008-12-08 15:48
    Mike,

    I built an identical circuit using P3 - the LED lights up when "frqa := 250 * scale"

    but the same program is changed(P7) ctra[noparse][[/noparse]5..0] :=7 and dira[noparse][[/noparse]7]~~ - the LED does not light at all.

    So I think the problem is either P7 or the 2N2222 transister.

    I will continue to trouble shoot if you have any other iuput - is greatly appreciated.

    Regards,

    Siri
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-08 16:01
    I did notice that you have no current limiting resistor in series with the LED and transistor. You need something. I'd start with 150 Ohms which would limit the LED current to about 16ma. Once you get the circuit and software working, you could use smaller values for larger peak currents. Keep in mind that LEDs also have maximum peak currents as well as maximum average currents. You don't want to exceed either value. The transistor is rated at much higher average and peak currents than the LED, so the LED would have burnt out first.

    A solenoid has a coil resistance that limits the amount of current that can flow through it for a given supply voltage. Not so for LEDs.
  • SiriSiri Posts: 220
    edited 2008-12-08 17:05
    Mike,

    I replaced the transistor and now it works well.

    Thank you so much - you are a man of wisdom.

    Regards,

    Siri

    P.S I will add a current limiting - I am using a 5V LED and when I try to calculate using the little programs in the Net it did not get me a value -0 - so that is why I
    did not place one.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-09 00:06
    Siri,
    If you're using a true 5V LED (with a built-in current regulator or built-in current limiting resistor), then you don't need another one, but these are not commonly used. RadioShack used to carry them (and still might).
Sign In or Register to comment.