Author Topic: arduino to PWM vac solenoid  (Read 4375 times)

0 Members and 1 Guest are viewing this topic.

Offline Jbates58Topic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: au
arduino to PWM vac solenoid
« on: October 13, 2016, 11:28:38 am »
hi all

just a quick question,

i am wanting to use an arduino to control a solenoid through PWM. i have the code and the hardware theory worked out, but just want to check a few things

i will use the arduino to control a transistor for the solenoid

the solenoid coil is about 15ohms and it draws a touch over 1A @12v.

it will be running at a max of 15V and a min of 11V (as its in a car)

i just want to know if there is anything special i need to know, or do i just need to make sure that the transistor i get can support that much current consistantly?

i am at the moment unsure what frequency or duty cycle it will be running at as i need to make the hardware to test it; if that matters.

Jason
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1938
  • Country: us
Re: arduino to PWM vac solenoid
« Reply #1 on: October 13, 2016, 12:59:40 pm »
Keeping things standard, I would use  pins 5 or 6 which are set to 980Hz as the other are 490.  That can be raised in frequency, but I would avoid using 5 & 6 as that changes other parts of the program that use the timing of these counters. Assume you will use a flyback diode on the coil.
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: arduino to PWM vac solenoid
« Reply #2 on: October 14, 2016, 01:06:22 am »
The solenoid is pretty seriously inductive in nature, so PWMing it will
not be a simple Iavg vs DC relationship. Furthermore your swing trans-
istor will have to have robust safe area capability due to transients.


Regards, Dana.


Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline Jbates58Topic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: au
Re: arduino to PWM vac solenoid
« Reply #3 on: October 14, 2016, 05:53:25 am »
Keeping things standard, I would use  pins 5 or 6 which are set to 980Hz as the other are 490.  That can be raised in frequency, but I would avoid using 5 & 6 as that changes other parts of the program that use the timing of these counters. Assume you will use a flyback diode on the coil.

so are you saying that i should or shouldnt use pin 5 or 6? i can use either, i was actualy hoping to down scale it from the arduino uno and hopefully get awat with something like a attiny 85.

and yes, i forgot to mention that i will have a diode across the coil.



The solenoid is pretty seriously inductive in nature, so PWMing it will
not be a simple Iavg vs DC relationship. Furthermore your swing trans-
istor will have to have robust safe area capability due to transients.

Regards, Dana.

sorry, i dont understand what you mean. my plan was to use something like a 3A to220 transistor or something along those lines. am i barking up the wrong tree?



Jason
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: arduino to PWM vac solenoid
« Reply #4 on: October 14, 2016, 10:12:26 am »
You are going to see some large V transients because you are switching off an inductive
load, so a clamp must be employed. And transistor ratings have to handle this the safe
area issues. As well as the current which you are already aware of.

Note this also means you have to protect the UP output from these transients fed back via
stray C coupling, and ground bounce.

Put a scope on it, 10X probe, and look at transients. Also consider a diode clamp across the
solenoid for clamping turnoff transient.

http://www.diva-portal.org/smash/get/diva2:18589/FULLTEXT01.pdf



Regards, Dana.
« Last Edit: October 14, 2016, 10:28:12 am by danadak »
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline Jbates58Topic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: au
Re: arduino to PWM vac solenoid
« Reply #5 on: October 14, 2016, 01:24:36 pm »
You are going to see some large V transients because you are switching off an inductive
load, so a clamp must be employed. And transistor ratings have to handle this the safe
area issues. As well as the current which you are already aware of.

Note this also means you have to protect the UP output from these transients fed back via
stray C coupling, and ground bounce.

Put a scope on it, 10X probe, and look at transients. Also consider a diode clamp across the
solenoid for clamping turnoff transient
.

http://www.diva-portal.org/smash/get/diva2:18589/FULLTEXT01.pdf



Regards, Dana.


that is where i was going to put the diode. would i need more than one?

the transistor i was hoping to use is a TIP32CG, as i have a heap of them lying about in the electronics kit.
Datasheet: http://www.onsemi.com/pub_link/Collateral/TIP31A-D.PDF

it can handle 3A, so i thought it would suffice even with a bit of a spike.

to protect the UC, would i use a diode of some sort on the output pin and then into a resistor to limit the current to the transistor and then to the transistor?

havent done alot with transistors so its a learning curve.


i have made a basic simulation of what i want to do, and coded it in 123circuits.io, in place of the solenoid, i have used an LED to indicate the PWM system. but i am unsure how to share it here.

my theory was to basicly remove the LED, and replace it with the solenoid and a flyback diode to clamp out the spike.

Jason
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: arduino to PWM vac solenoid
« Reply #6 on: October 14, 2016, 01:44:06 pm »
Insufficient gain - the TIP32CG's mimimum HFE is 25, so for 1A Ic, you need a minimum of 40mA Ib which is more than an Arduino can safely provide.  Use a Darlington pair or a MOSFET, but be careful - gate capacitance and I/O current capability will limit how fast an Arduino can switch a MOSFET and a Darlington has far higher voltage drop when on than a single transistor.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19520
  • Country: gb
  • 0999
Re: arduino to PWM vac solenoid
« Reply #7 on: October 14, 2016, 01:53:29 pm »
the solenoid coil is about 15ohms and it draws a touch over 1A @12v.
No it doesn't. Look up Ohm's law.
 

Offline Jbates58Topic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: au
Re: arduino to PWM vac solenoid
« Reply #8 on: October 26, 2016, 10:40:54 am »
ok, so an update.

i purchased some logic level mosfets and had a play and got it all working. i used the arduino pins 5/6 and found that they had a higher PWM frequency (and confirmed that on the arduino site relating to PWM) and then i swapped it to PIN 3 as it had a lower frequency (490HZ)

and i discovered that the solenoid has a working range of aprox 20% - 60%

but from the information i can gather, which is a little ambiguous but they all co-incide with each other, and they all state that the vehicles ECU runs it at 400HZ, so i am wondering if there is any problems with it running faster than it should?

and i know that i can adjust the timers and whatnot to increase or decrease the frequency, but i am lost as to how to do the maths behind it, and then on how to implement it into the code.

from what i have read, it will also effect how the rest of the code is executed by the arduino, but im also trying to gauge to how much it will effect it by.

i hope that makes sense.

Jason
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: arduino to PWM vac solenoid
« Reply #9 on: October 26, 2016, 11:07:36 am »
The only down-side of driving a PWMed inductive component at a higher frequency, is higher switching losses and more EMI.  A lower frequency could be problematic as you might hit a mechanical resonance.  IMHO stay with 490Hz - its not worth changing it and unless you accept loss of resolution you cant get the exact frequency you want anyway.  You should also note that Timer 2 is used for the PWM pin you have connected to, and if you change the frequency, it can mess up any libraries that rely on the 490Hz timer 2 interrupt rate. 
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1938
  • Country: us
Re: arduino to PWM vac solenoid
« Reply #10 on: October 26, 2016, 12:26:59 pm »
I suggested the higher frequency because some solenoids do not have enough inductance.  I drive relays at 980Hz without issue.  Again, avoid  changing frequency of 5 & 6.  For others who my follow this and may not understand the process.

    // This changes the frequency of PWM pins 11 & 3 ONLY
    // Fewer transitions = less heat created
    // Pins 11 and 3 for 16MHz clock
    // Settinng      Divisor    Hz
    // 0x01         1         31250
    // 0x02         8       3906
    // 0x03         32      976
    // 0x04         64      488
    // 0x05         128     244
    // 0x06         256     122
    // 0x07         1024    30
   
    // TCCR2B = TCCR2B & 0b11111000 | <setting>;
   
    TCCR2B = TCCR2B & 0b11111000 | 0x06;
   
    // PWM pins 9 & 10
    // TCCR1B = TCCR1B & 0b11111000 | <setting>;
   
    //TCCR1B = TCCR1B & 0b11111000 | 0x06 ;
   
    //Pins 5 and 6: Standard
    // changing this changes delay times  AVOID
    //Setting    Divisor   Frequency
    // 0x03       64          976
    //TCCR0B = TCCR0B & 0b11111000 | 0x03 ;
 
 

Offline Jbates58Topic starter

  • Regular Contributor
  • *
  • Posts: 68
  • Country: au
Re: arduino to PWM vac solenoid
« Reply #11 on: October 27, 2016, 11:52:19 am »
cheers,

how can i determine wether or not it is been properly switched so as to decide if i need to change the frequency? i have a scope and a meter.

what do i look for or test for?

it seems to be working fine, but this is new ground to me, and im learning as i go.

Jason
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1938
  • Country: us
Re: arduino to PWM vac solenoid
« Reply #12 on: November 02, 2016, 04:53:41 pm »
You can look at the current. Once you see a change in slope the core is saturated.  There will be an initial change in slope as the core pulls in and the inductance changes.  This is a good way to see the speed of a relay or solenoid.  Some good reading material is the app notes on a LM1949.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf