Breaktru Forum
eCigarette Forum => Modding => Topic started by: Zanderist on April 29, 2015, 09:32:24 PM
-
Seeing someone's interest in using an Arduino, I quickly pieced this together using the examples the IDE came with and added in some extra bits. I made assumptions that a person reading this can already piece together a basic Mosfet box mod.
Here is the Code, remove that Serial.print stuff if you don't need to troubleshoot. Feel free to edit this code and adapt it to your needs. This is extremely basic coding.
Just Copy and paste and upload
const int analogInPin = A3; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 3; // Analog output pin that the LED is attached to
const int RedLED=8;
const int YellowLED=9;
const int BlueLED=10;
const int switchpin=7;
int switchstate=0;
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
switchstate=digitalRead(switchpin);
if(switchstate==1){
analogWrite(analogOutPin, outputValue);
}
if(switchstate==0){
analogWrite(analogOutPin, 0);
}
if(outputValue>=180){
digitalWrite(RedLED,HIGH);
digitalWrite(YellowLED,LOW);
digitalWrite(BlueLED,LOW);
}
if(160<outputValue&&outputValue<180){
digitalWrite(RedLED,LOW);
digitalWrite(YellowLED,HIGH);
digitalWrite(BlueLED,LOW);
}
if(160>=outputValue){
digitalWrite(RedLED,LOW);
digitalWrite(YellowLED,LOW);
digitalWrite(BlueLED,HIGH);
}
// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.print(outputValue);
Serial.print("\t switch = ");
Serial.println(switchstate);
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(2);
}
Here is a picture of the wiring set up. The pot is 5k in my case though I do feel you could using any pot vaule.
(http://i.imgur.com/Aev3szq.jpg)
Video of it in Action
https://www.youtube.com/watch?v=XVngNyIpv2M
What's supposed to happen in this set up is you adjust the pot and an individual LED will light up to give an idea of what temperature the vape will be, Red is HOT, Yellow is WARM, blue is COOL. The push button is to turn on the analogue write function.
A challenge to offer is to incorporate a 5 button press hibernate.
-
excellent, that helps me a lot. the last time i programmed was when i had an amiga 500 and that was basic. i'll certainly give that a shot. With arduino would i be able to measure the voltage or would i need to use an rc filter first.
-
I would lower the frequency if you're only using a current limiting resistor on the gate. :)
@shandy27 Using an RC filter/software filter will give you the mean. If you want it to read the output voltage accurately you need to calculate RMS voltage.
-
am i right in saying to get the rms i multiply the peak by duty cycle squared.
-
Vrms = sqrt((duty cycle/255) * Vbat^2)
-
thanks for that, i'll start on it tonight when the wee man is in bed.
-
I've done another code that is the next level up, in this verison the battery voltage is sampled while it is not under load. I learned something important from this to, that you cannot read a voltage while it it is under load due to the voltage drop. I don't know what to do go into detail on so just ask me to explain something. The code I've posted is not final production level code, this is still a work in progress. The main goal I have in mind is to use every pin on the arduino so I can maximize its use when I go to build a final copy.
This version offers voltage level LEDS , as well as three different modes that are set by voltage.
bathighvoltage()-runs the device with out change turns on green high voltage LED
batmediumvoltage()-fades the PWM signal over time to conserve power(maybe?), turns on Red LED, lowvoltage one
batlowvoltage()-blinks the low voltage LED(RED)
To read the battery voltage you need to set up a voltage divider circuit, refer to a google search on how to do this in great detail
http://www.electroschematics.com/9351/arduino-digital-voltmeter/
Any one finding this thread for the first time...
DO NOT DIRECTLY CONNECT THE BATTERY INTO THE ANALOG PIN UNLESS THE VOLTAGE IS LESS THAN SUPPLY VOLTAGE.
//pieced together and coded by the Zanderist(AWA)
int analogInPin = A3; // Analog input pin that the potentiometer is attached to
int analogOutPin = 3; // Analog output pin that the LED is attached to
int analougePin=A2;//battery level read point
int hvoltage=5;//pin for high voltage LED
int lvoltage=4;//pin for low voltage LED
int RedLED=8;//pin for red level LED
int YellowLED=9;//pin for yellow level LED
int BlueLED=10;//pin for blue level LED
int switchpin=7;//pin for switch
int switchstate=0;//state of the switch
int mode=0;//sets which voltage mode to run
int levelshutdown=0;//int used as boolean to conserve power
int fadedone=0;//int used as boolean to stop fadding
int readenable=1;//int used as boolean to enable battery voltage sample.
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
int heatpwm=0;//new pwm value for batmedium.
int heatpwminc=-5;
int samplepwm=0; //take a reading of the PWM
int outputPWM=0;
int voltageValue=0;//for voltage reading
int VoutputValue=0;//for voltage computation
float Rratio=0.4;//divider ratio
float vout=0;//voltage out of the divider
float vin=0;//approx voltage at battery
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
pinMode(RedLED, OUTPUT);
pinMode(YellowLED, OUTPUT);
pinMode(BlueLED, OUTPUT);
pinMode(hvoltage, OUTPUT);
pinMode(lvoltage, OUTPUT);
pinMode(switchpin, INPUT);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
// check the battery voltage
voltageValue=analogRead(analougePin);
vout=(voltageValue*4.68)/1024.0;
vin = vout/Rratio;
//read switch
switchstate=digitalRead(switchpin);
//////
if(readenable==1){
outputPWM=outputValue;
if(vin>7.51){mode=2;}
if(6.99<=vin&&vin<=7.50){mode=1;}
if(vin<6.98){mode=0;}
}
if(switchstate==1){
readenable=0;
if(mode==2){
LEDS();
bathighvoltage();}
if(mode==1){
if(fadedone==0){
LEDS();}
batmediumvoltage();}
if(mode==0) {
batlowvoltage(); }
}
if(switchstate==0){
readenable=1;
samplepwm=1;
analogWrite(analogOutPin, 0);
turnoffLEDS();
fadedone=0;
}
// print the results to the serial monitor:
Serial.print("heatpwm= \t" );
Serial.print(outputPWM);
Serial.print("enable= \t" );
Serial.print(readenable);
Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.print(outputValue);
Serial.print("Voltage=\t");
Serial.print(vin);
Serial.print("\t switch = ");
Serial.println(switchstate);
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(2);
}
/////////////////////////////\
void bathighvoltage(){
digitalWrite(hvoltage,HIGH);
analogWrite(analogOutPin, outputPWM);
}
/////////////////////////////\
void batmediumvoltage(){
if(samplepwm==1){heatpwm=outputValue;samplepwm=0;}
if(fadedone==0){
digitalWrite(lvoltage,HIGH);
if(heatpwm>0){
heatpwm=heatpwm+heatpwminc;
analogWrite(analogOutPin,heatpwm);
}
if(heatpwm<=0){fadedone=1;turnoffLEDS();analogWrite(analogOutPin,0);}
}
}
/////////////////////////////\
void batlowvoltage(){
digitalWrite(lvoltage,HIGH);
delay(250);
digitalWrite(lvoltage,LOW);
delay(250);}
/////////////////////////////
void LEDS(){
if(outputValue>=180){
digitalWrite(RedLED,1);
digitalWrite(YellowLED,0);
digitalWrite(BlueLED,0);
}
if(160<outputValue&&outputValue<180){
digitalWrite(RedLED,0);
digitalWrite(YellowLED,1);
digitalWrite(BlueLED,0);
}
if(160>=outputValue){
digitalWrite(RedLED,LOW);
digitalWrite(YellowLED,LOW);
digitalWrite(BlueLED,HIGH);
}
}
/////////////////////////////
void turnoffLEDS()
{
digitalWrite(RedLED,0);
digitalWrite(YellowLED,0);
digitalWrite(BlueLED,0);
digitalWrite(hvoltage,LOW);
digitalWrite(lvoltage,LOW);
}
(http://i.imgur.com/PWYA6pe.jpg?1)
-
Zanderist, thanks for the tutorial. Seems easy enough to follow along with. I've only been learning for a couple weeks and haven't messed with much sensor input stuff besides the brief IDE example about serial printing input value from a potentiometer so this looks helpful for me.
Really awesome forum here
-
You should check voltage both open circuit and under load. The reason is that you don't want cell voltage to drop below a certain voltage at any time. Minimal voltage is 3V per cell for LiPos, but high drain 18650s can go lower. The HE2s can actually go down to 2.5V, but the rest are 2.7V. Though you shouldn't take them down that low since it increases wear and does not garner much extra run time. 3V for 18650s and 3.2V for LiPos is ideal.
Minimal voltage specification is for voltage under load, not open circuit. You'll find that when you take a cell down to the minimum under load, it will climb back up in voltage an amount after it's been sitting idle. It can be as much as a half volt depending on how heavy the load.
What you can do is curve the battery yourself which sounds difficult but it's not. Discharge graphs only show voltage under load and you need open circuit battery voltages for your fuel gauge. Just charge up the battery fully then discharge it in precise 15 to 30 second intervals with a known current. Take a reading after the load is removed and you'll get a set of plot points for open circuit voltage versus battery capacity.
It would be possible to gauge a battery under load if you know the battery's DC resistance and the load's amperage draw. In that case you can add current times DCR to the voltage reading then index it to your graph for open circuit voltage versus charge capacity. You can find a battery's DCR on the bench pretty simply by measuring voltage drop with a known current. You should measure it at about 50% capacity since it goes down somewhat with a full charge and goes up somewhat as the battery approaches discharged.
Curving a battery yourself can yield a very accurate fuel gauge. On my own mods, it's pretty darn close. Checking against a hit counter I get a pretty consistent number of hits for every 10% drop in capacity shown by the fuel gauge.
Oh, I should point out that your circuit is not actually going to measure true open circuit voltage since your electronics are going to draw some current. However a properly designed MCU system should not draw much so it's in effect open circuit. On my own mods, the circuit is drawing less than 10mA when taking an open circuit battery measurement, not enough to make any measurable difference. If for some reason your circuit draws a lot of current when taking a battery measurement you would have to take that into account.
-
You should check voltage both open circuit and under load. The reason is that you don't want cell voltage to drop below a certain voltage at any time. Minimal voltage is 3V per cell for LiPos, but high drain 18650s can go lower. The HE2s can actually go down to 2.5V, but the rest are 2.7V. Though you shouldn't take them down that low since it increases wear and does not garner much extra run time. 3V for 18650s and 3.2V for LiPos is ideal.
Minimal voltage specification is for voltage under load, not open circuit. You'll find that when you take a cell down to the minimum under load, it will climb back up in voltage an amount after it's been sitting idle. It can be as much as a half volt depending on how heavy the load.
What you can do is curve the battery yourself which sounds difficult but it's not. Discharge graphs only show voltage under load and you need open circuit battery voltages for your fuel gauge. Just charge up the battery fully then discharge it in precise 15 to 30 second intervals with a known current. Take a reading after the load is removed and you'll get a set of plot points for open circuit voltage versus battery capacity.
It would be possible to gauge a battery under load if you know the battery's DC resistance and the load's amperage draw. In that case you can add current times DCR to the voltage reading then index it to your graph for open circuit voltage versus charge capacity. You can find a battery's DCR on the bench pretty simply by measuring voltage drop with a known current. You should measure it at about 50% capacity since it goes down somewhat with a full charge and goes up somewhat as the battery approaches discharged.
Curving a battery yourself can yield a very accurate fuel gauge. On my own mods, it's pretty darn close. Checking against a hit counter I get a pretty consistent number of hits for every 10% drop in capacity shown by the fuel gauge.
Oh, I should point out that your circuit is not actually going to measure true open circuit voltage since your electronics are going to draw some current. However a properly designed MCU system should not draw much so it's in effect open circuit. On my own mods, the circuit is drawing less than 10mA when taking an open circuit battery measurement, not enough to make any measurable difference. If for some reason your circuit draws a lot of current when taking a battery measurement you would have to take that into account.
The curve idea you bring up sounds like it can be an easy experiment to set up with an arduino.
I'm looking for a one size fits all with the voltage part.
This mod I have set up is set so you can remove the batteries, I haven't yet figured out how to incorporate a charging circuit just yet.
Problem I had though was when I went to fire the coil with this build, the voltage went from 8 volts to 5 volts and since I had tied functions to battery voltage level it went haywire. This led to me sampling voltage during open circuit conditions.
What I've done for any issue with the voltage reading (not posted as of yet) was I added an offset to make it equal to my mutlimeter, so far so good with it.
What trying to do at the moment is remove any square waves with bumps or spikes, so far high value capacitors seem to be doing the trick. Its sad to say though that I don't have any proper training in the subject so I'm just guessing values of capacitance.
-
If you have room on the screen you can just display the battery voltage. But I'm lazy like that :p
(http://i860.photobucket.com/albums/ab167/doobedoobedo2/Aduino%20Raptor/blue_7pin_oled_zpsafgyopdp.jpg)
-
i was going to ask you earlier how your project was coming on.
-
It's coming along a lot better now I've done what I should have done in the first place. I've got breakout boards for all the SMD components so I can breadboard it properly and debug the hardware.
I've now got the current sensor and it's amplifier working well enough together. I've been through half a dozen of those .96" OLEDs which all seem to have their quirks, but I've got some I'm happy with. I just need to hook up the digipot and raptor to the breadboard and current sensor and I'll be ready to order another set of boards from OSHPark :).
I'm going to do a PWM next I think, the arduino and raptor are just too big together and PWM will cut the size down by quite a bit. I can re-use a huge amount of my code for it too.
-
yeah pwm seems to be the way to go. It's funny though a few months ago people were saying how crap pwm mods are now everyone wants one lol.
-
Small and cheap way of buck regulating and at high enough frequency not to get the rattlesnake. A decent 3S LiPo will do it all from low to high power :).
-
If you have room on the screen you can just display the battery voltage. But I'm lazy like that :p
(http://i860.photobucket.com/albums/ab167/doobedoobedo2/Aduino%20Raptor/blue_7pin_oled_zpsafgyopdp.jpg)
Do you need to add additional programming for that?
I see it reads ohms, do you need extra hardware or does the display do it all for you?
-
It all has to be coded. The screen is just that - a screen. It's an SPI SSD1306 .96" OLED. I'm using the U8glib library which is excellent (https://code.google.com/p/u8glib/)
To measure ohms I'm using a current sensor then doing the maths with the output voltage. I'm considering using a constant current source for my next project though, unless anyone knows a better way ;).
-
If you have room on the screen you can just display the battery voltage.
Yeah you can, but then you only know when you need to charge, pretty hard to tell how much run time you have left based on voltage since it's not really a linear relationship. It's kind of linear but not on either end of the curve.
I'm considering using a constant current source for my next project though, unless anyone knows a better way.
The problem with regulating current the analog way is you need to maintain some reference voltage which means wasted power. To convert any voltage regulator to a current regulator requires you maintain a voltage reference typically between .8 and 1.2V. For high currents it results in a lot of wasted power.
You can regulate current digitally in lieu of voltage or wattage. I've thought about coding a current regulated mod. There are some benefits to maintaining a constant current over a constant wattage or voltage. I haven't seen anyone do it yet and there are no mods off the shelf that can do it either. To regulate current digitally is only a matter of coding which is no more or less efficient, assuming you are giving up the power to monitor current dynamically already (using a current sense resistor or hall effect sensor)
-
Fair comment about the battery monitor, but as I say I'm lazy and tend to keep my batteries fairly well topped up anyway so voltage is a good enough indicator for me.
I think you misunderstood what I was going to use the constant current for. As you guessed I'm using a hall effect sensor (ACS710 although I probably should have used an ACS712 for size, or suggestions for alternatives welcome) to monitor the current and I'm measuring the voltage, with these I can calculate the resistance. I was thinking that another way to calculate resistance would be to use a constant current IC to send maybe 200mA through the coil and measure the voltage drop across it. Any other ideas for measuring coil resistance would of course be welcome.
-
Oh okay, I thought I may have missed the mark with that last reply.
In electronics there's always at least three different ways to do the same thing, usually more. You're basically describing an Ohmmeter which is a perfectly legitimate way to check resistance. Using a MOSFET inline you can drop in a voltage divider for a few milli-seconds and use voltage across a reference resistance to find atomizer resistance. That's how Ohmmeters generally work. The down side is you can't check current dynamically which is okay I suppose, but personally I prefer to keep tabs on current demand. It's just safer to insure you never try to provide more current than the circuit can handle.
In terms of complexity, the Hall effect chip you're using is going to be the most simple way to find resistance (in terms of part count). There's a proper name for calculating resistance with a current and voltage measurement (4 wire or Kelvin measurement), but it's a highly accurate way to do it and you get the benefit of dynamic current monitoring as well.
-
probably a stupid question but can hall effect sensors be used to measure the load of a pwm mod like this.
-
can hall effect sensors be used to measure the load of a pwm mod like this.
Have a look here:
http://breaktru.com/smf/index.php/topic,1385.msg17524.html#msg17524
-
Sensing for PWM is essentially the same as sensing for DC. The primary difference is you need to add your RMS calculations after you take a sample. PWM does add a level of complexity as I stated in the post linked above. The main problem being the need to filter noise, but not so heavily you introduce a lot of error.
-
I need to upload a video I recorded. My setup was a mess and I got it soooo close to the target voltage in my tests. :) It doesn't rattlesnake even at 122hz, btw. I'm using a shunt monitor in my project.
EDIT: https://www.youtube.com/watch?v=EZLUMTNEzQg&feature=youtu.be
This was my first test, so be gentle... I'm working on a custom PCB now. :)
-
thanks for the links and help everyone it's much appreciated, my original plan was to use a shunt resistor and an ad623 instrumentation amp to measure the current. i don't plan on doing anything fancy just something to display voltage, wattage, resistance and current.
-
That's all I use, just a current sense resistor and standard op-amp. Though because I use an inexpensive general purpose op-amp I have to calibrate each build. Using an instrumentation amp or other precision op-amp can eliminate that need, but if you want accuracy to two decimal places, you'll probably still need to calibrate. You'll probably get accuracy out of the box down to one decimal place, but doubtful you can get it to two without some calibration.
The Hall effect sensors are really nice, very low insertion loss and simple to interface. However, they are not a widely available part. There's only one maker I know of. Also they are not programmable. You're limited to a set of offerings like 5A, 10A, 20A etc and then the signal range is not adjustable. You can potentially lose a lot of ADC resolution. Other than that it's a simple and elegant solution.
-
am i right in thinking that i would insert an rc filter between the current shunt and the op amp.
-
Yes you always need to filter ADC inputs, either hardware or software. I use a 3k resistor and a 1u capacitor, but that's for DC. With PWM you need a lower time constant, probably like 1k and 100n. Depends on PWM frequency and minimal duty cycle. Or you can do it in software, sample at maximal rate (usually 100 to 500ksps) during the pulse and average.
If you don't understand what I mean by "time constant" read the replies after the one linked to a few replies earlier.
For a hardware filter, you only need to filter output from your current sensor at the ADC input for your MCU. You don't need to filter anywhere else and you don't want to since it will likely cause problems with your sensor. It's tricky to filter inputs on op-amps, it tends to throw them out of spec.
-
That ends up giving you the mean, though.
-
One annoying thing I have encountered is that the voltage at the Vin pin of the Arduino turns into a square wave when firing, the closest I have come to filtering is was with use of a 7805 regulator but that causes different issues altogether.
-
The input voltage will be pulsing as well since the battery is going from heavy load to light load over and over again. I have a completely different idea that worked great! The only drawback is I can't continuously read resistance/current.
I went through the whole hardware/software filter thing. It takes way too long to get a nice flat signal and gives you bogus results either way. Waste of time..... It may say 3v and read ok, but the actual heating effect is much higher than that. The lower you go with the duty cycle the worse it is. RMS voltage seems spot on with the heating effect.. If you watch that video I linked, check the difference between RMS and mean voltage at low duty cycle.
On a side note, I've been watching all of pbusardo's videos where he's testing mods with a scope. Not any of them get within the range that I got from the first test in that video. It's pretty friggin' decent. I hit it all the way up to 10v RMS with a 0.33 ohm build on it. It was intesnse. :P
EDIT:If you calculate it, 25% duty cycle will actually be 50% of RMS voltage(heating effect). With 10v peak(loaded battery voltage) 25% duty cycle would give you 2.5v mean, when it's actually heating the coil(s) like 5v. Make sense? I don't know how else to explain it. Hope you get it. :)
-
Did you try timing the adc sample so it happens during one of the pulses, then convert to rms knowing the pulse width? I'm doing a project
at the moment that uses sampled voltage on the fly to calculate the pulse width, but I don't have a display so that is one less thing to
worry about. I'm using an Atmel ATtiny13, same family I think as the Arduino, but with only 5 in/outs and 1K of flash memory.
Sheesh 10V rms and a 0.33 ohm coil, are we talking 300W here? I'm way down at the exact opposite end of the scale, around 10W with a
single battery :laughing:
-
You can always convert mean to RMS from the duty cycle.
-
I'm honestly new to electronics, hence trying to over explain stuff... My first go around with the PWM mod was filtering with hardware, software and a combination of both. I posted about it here. It also shows how I'm doing it now. Not the best solution, but it's easy to do and it works. In short, I'm firing the atty at 100% like an unregulated mod for just long enough to get current and loaded battery voltage. After that I calculate everything I need and pulse the atty. I'm going to get it going faster now, but even 35ms isn't too long.
http://breaktru.com/smf/index.php/topic,1474.0.html
There is one guy I know that's basically turning the arduino into a scope to sample the wave directly and calculating everything from that. Pretty sweet idea. IMHO filtering for the mean then calculating RMS from that will simply take too long. It's easy to test for yourself, though.
Yes, 300w. I wanted to see what this thing could do. It wasn't even maxed out. :)
-
It's all useful stuff. I've not tried PWM yet as I'm currently working with a raptor, so I'll defer to your experience :).
I am slightly surprised that it takes as long as 35ms to settle down though. What batteries are you using?
-
This was due to how I'm reading the current. Zero filtering. It'll be faster on the next one. If you think that's bad, try filtering the output. It's much worse than that, haha! Good luck on your project!
-
That ends up giving you the mean, though.
No, it's not mean. You put a hook in the code so you sample only during the pulse at max sampling rate, than average. When you have a good read on peak voltage and peak current you can accurately calculate everything in terms of RMS values with duty cycle known. Otherwise for a hardware filter, you use a time constant low enough so that voltage settles adequately before taking a "single" sample toward the end of the pulse. Either way should yield stable and accurate readings. If not there's a timing issue somewhere.
-
That makes sense. :)
-
Rather than switching the gate directly from the pwm pin (max 40mA), wouldn't it make more sense to use a gate driver? And what are the main things to look for in one?
-
On all the MCU mods I've read about the output limit is dependent on the atomizer coil like an OKR or raptor mod. What is the best way to make it so the set power is the same no matter the atomizer resistance, like in a sigelei,etc box?
Way more power than you need in the first place, and just some fancy math to read the atomizer resistance and adjust settings around it? What am I missing here?
-
You can lower the frequency and use a current limiting resistor. My tests have been at 122hz and limiting the current to about 20ma. I was going to go with a gate driver at first, but with such a low frequency it's not needed, IMO. The MOSFET is fully saturating with the current limited to 20ma at that frequency, so it should be all good. I saw someone suggest a PNP & NPN transistor array so the gate gets battery voltage VS 3.3 or 5v to reduce Rds(on).
@Mayor After getting proper readings you can regulate the output in software.
-
Did you do some fancy register manipulation to get the frequency that low?
-
Generally it's not a good idea to drive capacitive loads directly off an MCU I/O pin, it can lead to MCU problems like brownouts and spurious resets. It can be resolved by adding a resistor inline as mentioned, but it also slows down the transition time of the MOSFET. They are not very efficient during on/off transitions so the faster they are the better. There is a big dependence on switching frequency, the lower it is the less heating occurs in the MOSFET. It's not uncommon to hear of overheating issues with MOSFETs due to lack of switching speed for high frequency stuff like power supplies.
There's also gate charge. That can make a big difference since the higher the gate charge, the greater the drive current and the slower the MOSFET turns on and off. There can be a pretty wide range there, but typically when minimizing on-state resistance you're maximizing gate charge. That's how it works with MOSFETs, the bigger the gate junction the lower the on-state resistance but that maximizes gate charge.
Personally I would use a gate driver, but putting a resistor inline is good way to drop the part count and it probably does not have a big impact for typical PWM frequencies under 100Hz. Though if you want to run frequencies a lot higher than that a gate driver might be necessary.
-
Cheers Craig :).
This is the gate driver I'm looking at. It's small and cheap. http://www.farnell.com/datasheets/1383716.pdf
I've got VW running pretty well with my test setup. I've re-used loads of code which helps. At the moment I'm driving a 3034 direct from the PWM pin at 980Hz, just for initial testing. I'm not bothered about burning $3 arduino out at the moment, I've got loads. It makes a noise when it's firing so I'm either going to have to go up in frequency out of hearing range (32kHz) or down to 122Hz and it sounds like down is the way to go.
-
Driver is the proper way for sure. Luckily I haven't had an issue with this yet at such a low frequency. I could probably even lower it more. I just switched to a 3.3v setup. I'm going to use that transistor array to get battery voltage to the gate to reduce drain to source resistance. Going to be working with some high current.
You can change the frequency in one line of code. Everyone else I know uses that pwm frequency library with arduino.
-
Ah OK is that with the PWM library? I can't seem to get it to work in the 1.6.3 IDE.
-
I've never used it. Refer to this link.
http://letsmakerobots.com/content/changing-pwm-frequencies-arduino-controllers
-
That's the register manipulation I was talking about. You have to be careful with that as it can affect other things. I'll have a play.
Which PWM pin are you using?
-
Sorry for shirt messages... Two job status over here. I'm using timer 2. Timer 0 will affect millis() and delay()
-
Nice to see some activity,regardless. Particularly mcu/arduino/avr and pwm.
Hopefully we'll see some schematics and code?
-
I had a quick look at the driver datasheet. I understand it now. I didn't think about the issue of switching from a 5v setup to 3.3v until today after sending off a board revision.. . My only concern is Rds(on) with 3.3v..
I don't want to give you guys schematics and stuff if I don't know how well everything will work before real life stress testing.
-
Totally understandable.
I'll keep poking at code and jumpers ;-)
-
The single most important thing for coding is clarity and organisation. Break what you're doing down into individual steps and write functions. Sprawling spaghetti code may appear to be faster to do initially but you'll soon get lost.
The vast majority of my code is for the interface on the OLED. Because my code is modular I was able to switch from controlling a raptor to controlling PWM in under an hour.
-
It's not particularly beautiful yet.
(http://i860.photobucket.com/albums/ab167/doobedoobedo2/PWM/20150506_220119_zpsgtfmf4qq.jpg)
-
Thanks for posting your projects and asking and answering all these questions. I'm an electronics noob and have learned a lot.
This is a really great thread because it contains everything you need to make a basic PWM arduino mod with resistance measuring for variable watt.
Could you do temperature control with this type of resistance measuring as well (voltage divider)
At the moment I'm driving a 3034 direct from the PWM pin at 980Hz, just for initial testing. I'm not bothered about burning $3 arduino out at the moment, I've got loads. It makes a noise when it's firing so I'm either going to have to go up in frequency out of hearing range (32kHz) or down to 122Hz and it sounds like down is the way to go.
Is that a logic level mosfet? I've bought some IR IRLB3034PBF to play around with. From what I've learned it's essential to use a logic level mosfet.
My other question is if the coil has to be considered an inductor? Is the effect neglectible or should you take this into consideration somehow? Can there be voltage spikes from this? Should I use a "freewheeling diode" across the load?
I've tried to use online inductor calculators and it said 0.18uH for a 14 wrap coil and did a simulation with LTSpice and it showed some largish voltage spikes. A schottky diode would improve efficiency, yes?
-
What MCU would you guys recommend to use to convert this into a single, simple and minimalist PCB as possible? I have a similar setup except I'm using a display and two buttons to control the analog output. right now I'm considering the attiny85 since it has just as many pins as I need but it doesn't leave any room for expanding then and I don't want to jump on that one simply because its one of the few MCU's I'm aware of when there probably is something as good if not better in a tiny package.
-
have you thought about same mcu the arduino uses but in surface mount package its a good bit smaller than the dip and you will still be able to expand in future if you want.
-
http://www.gearbest.com/boards-shields/pp_227556.html?currency=AUD&gclid=CIqbjrKul8kCFQQrvQodVCkCSA
Looks great for experimenting.
-
Those are basically clones of the boards I have now. I only have one other board to compare them to (a v3 nano) but they're very good for small projects with few wires and drastically reduce the size, plus I got a handful of them for under $10.
I have considered using the ATMEGA or yesterday I came across the attint84 I think it was called. The only thing in worried about in using a SMD one is if the timers fail like they do in normal PWM boxes I'd want to have it socketed so I don't need to scrap the entire board every time one dies. Though I'm not really sure this is an issue