gfxgfx
 
Please login or register.

Login with username, password and session length
logo
 
gfx gfx
gfx
19707 Posts in 1262 Topics by 5041 Members - Latest Member: jorand December 16, 2017, 04:23:07 AM
*
gfx* Home | Help | Login | Register | gfx
gfx
Breaktru Forum  |  eCigarette Forum  |  Modding  |  Topic: Beginnings of another MCU mod - but using PWM
gfx
gfxgfx
 

Author Topic: Beginnings of another MCU mod - but using PWM  (Read 64311 times)

0 Members and 4 Guests are viewing this topic.

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #150 on: September 12, 2012, 05:15:15 PM »
Size of code is the great thing with the MCU's - it's a real bonus having the RISC architecture too as it's so much easier to work with than something like the x86 instruction set.

Thankfully there's some nice interpreters/compilers for programming the PC side of things although it is much much harder to get the program tight and efficient.  Sure you can do it the way most developers do these days - just bloat it out and not care - but I prefer the old methods of keeping it tightly constructed to keep the overheads down and allow for a wider user base.
That Zombie Fallout game is still nice and tiny even though it's got over 12MB of actual source code with the extra DLL's I've written to work out the pathfinding etc.  All depends on how it's coded to how it pops out the end of the compiler routine :)

Offline CraigHB

  • PV Master
  • *******
  • Joined: Nov 2011
  • Location: Reno, Nevada
  • Posts: 2023
  • Karma: +243/-1
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #151 on: September 13, 2012, 05:23:04 AM »
That's what's good about assembly, no overhead.  My 8kB of machine code would probably be at least double the size if I used a compiler, just from standard libraries that get tacked on.  Though, it can get to a point with assembly where it gets unruly, usually when you get into graphic displays.  Though I've coded a graphic display driver in assembly.  It was long and tedious.  I use a text mode display in my current mod.  Sending ascii characters is worlds easier than sending pixels.  In fact, it couldn't be easier, just a few instructions.  Text mode displays are great for this kind of stuff, super easy to code.

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #152 on: September 13, 2012, 06:20:18 AM »
I did think about trying one of those super mini oled displays but I really didn't see much point when a cheaper, smaller text display is readily available and easy to code.
I've not done any assembly stuff since about 1988 but I do remember it being a pain doing the heavier graphical stuff.  Mind you, that was on a Motorola 68000 so not got much to compare it against :)

Offline CraigHB

  • PV Master
  • *******
  • Joined: Nov 2011
  • Location: Reno, Nevada
  • Posts: 2023
  • Karma: +243/-1
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #153 on: September 13, 2012, 02:12:10 PM »
I learned assembly on an Intel 8008 so long ago I can't remember when it was, early 80's maybe.  That was when there was little distinction between CPUs and MCUs.  It was actually the first programming I ever did.  Back then, the chips didn't have built-in memory.  EPROM was expensive and write once so you had to simulate your code on a computing machine to debug it.  I used this weird looking desktop contraption that used a little cassette tape for memory.  It had a keyboard and a little monochrome CRT.  Archaic stuff.  I still like assembly though.  I've always liked working at the machine level.

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #154 on: September 13, 2012, 02:15:39 PM »
I started a little easier - home build ZX81 with 1K of onboard ram :)

First ever program was a golf sim which was a case of punch in the angle, punch in the power and it would launch a dot using those factors.  Had things like bunkers and water too but was all along the bottom of the screen so kind of side on but hey - it fitted into 1K :)

That was back in 1982 and I've not looked back since really!

Offline CraigHB

  • PV Master
  • *******
  • Joined: Nov 2011
  • Location: Reno, Nevada
  • Posts: 2023
  • Karma: +243/-1
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #155 on: September 13, 2012, 02:29:19 PM »
I don't look back much either, but nostalgia with electronics and programming can be pretty amusing.  Technology has advanced leaps and bounds.  30 years ago, I would have never guessed I could do the stuff I do now on my desktop so cheaply and conveniently.

Online Breaktru

  • Administrator
  • PV Master
  • *****
  • Joined: Nov 2008
  • Location: NY
  • Posts: 3305
  • Karma: +784/-4
  • Gender: Male
  • PLEASE participate in this forum
Re: Beginnings of another MCU mod - but using PWM
« Reply #156 on: September 13, 2012, 07:01:26 PM »
Those were the Dinosaur days for sure.
My brother-in law had given me a Texas Instrument TI-99. Had a 16-bit processor w/ a cassette recorder. All I could do was "BASIC" and had a few game cartridges.
It had an RF modulator to hook up to a TV, I had no monitor.


Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #157 on: September 13, 2012, 07:18:09 PM »
Can't beat the old days of RF modulators and dodgy TV tuners :)

I still remember the old black and white set I used to run.  Turn dial tuning that used to drift as the set heated up - always a challenge!

And tape was great, when it worked right - I've still got a mother load of tapes in the attic for the Spectrum and Acorn.  I managed to transfer most of them over years back into the PC for the emulators but can't bring my self to ditch the masters...

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #158 on: September 16, 2012, 06:29:41 PM »
Quick update - new code is working ok so far with a fairly accurate timer using a 250ns timer interrupt to ensure the time related items are running correctly (trigger timeout, display timeout and sleep timer).
Sleep mode has been a pain as the new MCU has completely different wake on interrupt handing routines that need a secondary layer to control the individual ports.
My current stage is enabling the display and making sure that's being updated as required then once I'm happy with that I'll be moving onto the PWM stage which again is different on the new MCU as it has an Enhanced CCP controller (capture compare module) which means a little more work setting up the pulse train.

All in all though - going pretty well considering it's a total re-write and I'm learning this new MCU as I'm going along.  I've had to move a few ports around though to handle the new CCP/PWM controller as I can't force the output to specific pins but I've been able to shuffle a few things about to make it close enough to still keep the same form factor.

Online Breaktru

  • Administrator
  • PV Master
  • *****
  • Joined: Nov 2008
  • Location: NY
  • Posts: 3305
  • Karma: +784/-4
  • Gender: Male
  • PLEASE participate in this forum
Re: Beginnings of another MCU mod - but using PWM
« Reply #159 on: September 16, 2012, 06:45:01 PM »
Cool, sounds like your getting closer to a finished product   :thumbsup:

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #160 on: September 16, 2012, 06:55:48 PM »
Yep, won't be long now and I'll have a box mod made up as a prototype to give it a real world test.  Once I'm happy with that the tube mod will get its innards and I'll be all set to make more if needed.
Hoping the prototype won't be long though as I shorted out one of my LEA batteries this week and now it's on all the time so not got a backup!

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #161 on: September 18, 2012, 06:34:33 AM »
I know it's lethal and tends to cost more money but I've been browsing and came across this - http://sabernetics.com/store/0-84-oled-display-96x16/

Might grab one to take a look - just waiting for them to come back to me about international shipping though....

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #162 on: September 20, 2012, 11:36:29 AM »
Latest update - code is complete and working fine with the new MCU.

However, I'm now trying to track down a hardware bug where if I screw in an atty it sets the MCU into a constant reset when I hit the trigger and won't stabilise until the atty is removed.
Not sure why as I can't find any shorts anywhere, but I'll start pulling things out one by one until I find the culprit.  Hoping it's not the current sensor, but as yet I've not been able to get any more than 2v out of it which is strange as I'd expect 2.5v at no load???

More testing required but hopefully the light is at the end of the tunnel and it's not a train coming to mow me down :)

Edit:  Found the problem with the current sensor - it draws too much load for the MCU to drive directly so have now got it running through a MOSFET and all is well.  Readings work well, with (so far) no obvious failures in the circuit.  Resetting issue was a bad cap on the output of the LDO - replaced this and no more resets while firing the atty.
« Last Edit: September 20, 2012, 05:27:44 PM by sterling101 »

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #163 on: September 21, 2012, 09:49:45 AM »
Now running the current sensor through a MOSFET to switch the unit on and off and the circuit at idle draws under 500uA so I'm pretty pleased with that.

Only thing I am seeing is the readings from the current sensor are very very noisy which can give some very random results when calculating the resistance from the current.
Even with no atty connected the readings jump around something rotten and I've even seen it read 160ohm!
I'm taking multiple samples and averaging out the values but I'm getting slightly worried about the noise to say the least.  I'm running a 1nF filter cap on the ACS712 and I'm guessing I'm going to need to increase that to smooth it some more and then allow more time for it to stabilise before reading the value.  At the minute I'm holding 100ms before taking 3 samples 50us apart which should allow plenty of time to stabilise so I feel a lot more testing is going to be required before I can sign off on using the ACS712-5 in the production version.

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #164 on: September 21, 2012, 07:24:46 PM »
Well, after much fudging, fiddling and faffing I still can't get the output from the current sensor to read accurately enough.

It's close, but sometimes it's a mile out picking up the current values.  Using my test atty which is 1.5ohm at 3.5v I should be seeing around 2.3A but I'm seeing a variation of anywhere between 1.8A and 3A.  It seems to be purely random and to rule it out I've re-wired the whole thing with new fly leads but still not having much luck.

Next stop will be to manually test the current sensor on its own with my multi-meter checking the voltage out then simulating that into the MCU to rule out any potential issues with the onboard conversion.

Can't believe how noisy it is though - I was expecting maybe a couple of points difference on the A/D readings but not the 20-30 points I'm actually seeing.

Offline CraigHB

  • PV Master
  • *******
  • Joined: Nov 2011
  • Location: Reno, Nevada
  • Posts: 2023
  • Karma: +243/-1
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #165 on: September 21, 2012, 10:39:04 PM »
Try filtering the input in hardware.  Put a .1uF cap at the MCU pin and connect the current sense output to the MCU through a 1k resistor. 

AD inputs are highly sensitive to noise.  It can be hard to get readings perfectly stable.  You're probably getting a lot of coupling with those high pulse currents. The issue may be exacerbated by the hall effect sensor used in that chip.  Hall effect sensors have a lot of hysteresis. 

Another option would be to go with a current sense resistor and op-amp.  That would be much less sensitive to mutual induction since sensing can be isolated to some extent from the main current path.  Also, that type of sensing circuit reacts and stabilizes much faster.

I assume you are synchronizing the AD sample with the PWM pulse?  You'd want to do that.  If you take the sample after the current pulse has stabilized, it will minimize any coupling.  Noise happens when currents are changing in magnitude.  When they've stabilized to a constant level after a small fraction of a second, things are quiet.  The other option would be to sample continuously, but throw away any samples except those taken toward the end of the pulse.

Well, hope that helps and you resolve your issue easily.

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #166 on: September 22, 2012, 07:17:54 AM »
Well I had a thought this morning and decided to see if it was the PWM going through the ACS712 rather than a constant current that was causing the problem with the readings.
With a solid 7.7v run through direct from the battery it reads perfectly, albeit at over 5A!

So it would seem the PWM over excites the hall sensor and throws the readings out.  The meter on the output doesn't show this due to the slow update on the voltage but as the A2D is a hell of a lot faster it picks up the fluctuation.

So, I'd guess my best bet would be to come up with a low pass filter on the output to smooth it out and convert it to DC.  The question is, if I'm switching the ground will that actually work or should I move on to switching the positive supply instead by adding a P-channel mosfet into the circuit?

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #167 on: September 23, 2012, 03:45:43 PM »
OK, plenty more information running through the old head and I think changing to a positive switch for the PWM then using a low pass filter should work fine.
However, I'm very aware of the high currents that will be passing through the filter's resistor.  I'm guessing, as I've set a hard limit of 3.5A at 6V on the code I'll need at least a 21W resistor so I've got a limited amount of options available due to the space constraints.  I've seen an SMD 35W resistor in a TO-263 package here which could be an option I suppose.

Craig, is there anything you've come across during your mod building that will handle those sort of loads and still retain the size it needs to be mounted onto a small board?

Offline CraigHB

  • PV Master
  • *******
  • Joined: Nov 2011
  • Location: Reno, Nevada
  • Posts: 2023
  • Karma: +243/-1
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #168 on: September 23, 2012, 05:10:09 PM »
You need to get your thinking inside the box there sterling101.  You should not have to use a resistor carrying high currents in a filter configuration.  The only type of resistor that you could practically use is a current sense resistor and those have very low resistance, like in the milli-ohms.  You'd need a very large capacitor to obtain a time constant large enough to do anything. 

There are several solutions readily at hand for the issues you are having with current sensing.  It's going to be a matter of filtering the signal to the MCU from the current sense chip, a matter of timing, a matter of using a different sensor, or some combination thereof.  I've already explained this.  There isn't any more I can tell you.

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #169 on: September 23, 2012, 06:16:41 PM »
Ahh yes, I've just re-read your post and it's sinking in a little more and I've now got a bit more of an idea of where to point.  I blame the pain meds and lack of sleep :)

If I can get my scope down out of the attic I can do some checks on the current sensor to get it's exact stabilisation time and then hopefully I can pull the ADC conversion into the right point in time to pick up the reading correctly.
According to the datasheet it's stabilisation time in it's current configuration *should* be 5us and the power on time is typically 35us so if I can hold the ADC off for 40us after power up it should allow for an accurate reading as long as I sample the the output for at least 31us each pulse (at 32khz PWM frequency).

Will do some more math and work out if there's a was to reliably attach the PWM to the timings as I'm using the onboard hardware PWM for the normal trigger pulses.

Offline CraigHB

  • PV Master
  • *******
  • Joined: Nov 2011
  • Location: Reno, Nevada
  • Posts: 2023
  • Karma: +243/-1
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #170 on: September 24, 2012, 01:25:12 AM »
You could also slow down the PWM frequency to give the current more time to stabilize before you measure it.  Keep in mind the higher the PWM frequency the more electrical noise it generates.  You're also getting greater reactive losses with the higher frequency.  I don't know if it's significant in your case, but switching losses can cause a lot of heating for the MOSFET if it's not a particularly fast one.  I've run into that before with slower MOSFETs.  A lower frequency mitigates that issue.

5uS is actually quite fast for a hall effect sensor.  The op-amp I use for current sensing has a .6V/uS slew rate so depending on the input, response time ranges from 1 to 3 uS.  Since it measures a strictly DC output, response time is not an issue.  That just happens to be the response time for the inexpensive op-amp I'm using.  Much faster ones are available.  Still, it's orders of magnitude faster than the ramp-up for the controller.  Specifically, the controller takes 3mS to ramp up so the sensor tracks it pretty much exactly.  Ramp-up is going to be a lot faster for a PWM driver, probably less than a uS.  It's more likely the ringing that plays hell with the sensor.



« Last Edit: September 24, 2012, 02:15:18 AM by CraigHB »

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #171 on: September 24, 2012, 04:38:21 AM »
OK, bit more work on it this morning and using a 145Hz pulse train which is the lowest I can get at 4Mhz clock I get reliable readings about 90% of the time.  I've also tried to time the ADC so it takes it's reading at around 5uS after the PWM train has started up.  At 145Hz the pulse width should be around 6.8mS so it gives a lot more time to take the readings.
However it seems the first check on hitting the trigger gives a low reading, then subsequent checks which happen once every 2 seconds pick the readings up perfectly.  I'm wondering if it's the time taken to heat the atty that's having an effect on the earlier results?

Am just going to try some extra filtering though on the output of the current sensor to the MCU - might need a smaller resistor or even larger capacitor to smooth out the signal a little more.  Just to see if it will help and will be playing with the delay portion of the ADC reads to see if there's a sweet spot I can hit with that too.

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #172 on: September 24, 2012, 07:47:25 PM »
Well we now have a reasonably reliable sytem running!
I've managed to time the ADC reads pretty well with the PWM and it now seems to get the resistances pretty close.  I did wonder why I was getting about half an ohm high for a while then I metered the wire up to the atty connector and there and back is just over half an ohm so I'll need to do a check on the final build's wiring and add a correction factor in for that.
I'm having a few doubts over running up to 8.4v through the atty though as on my vivi nova with 2.8ohm head at 3.5v it burns really bad.  It's not much better at 3.0v either and 6v is like inhaling a burnt innertube!
So, I'm considering the possibility of adding a buck converter stage and using the PWM to drive that.  Not 100% set on it yet, but the thought is there as it shouldn't need much additional hardware to incorporate it all being well.

Offline CraigHB

  • PV Master
  • *******
  • Joined: Nov 2011
  • Location: Reno, Nevada
  • Posts: 2023
  • Karma: +243/-1
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #173 on: September 25, 2012, 04:10:16 AM »
I haven't used a PWM device other than an eGo so I wouldn't know by experience, but it should work.  3.5V (equiv) using PWM should seem pretty much the same as 3.5V DC.  You should check your output on a scope.  Could be something wrong with the way the duty cycle is processing.

I suppose you could run another regulator in series, but then why use PWM, just use the first regulator.  It's the same thing with Chinese VV devices like the Gripper and a few others.  They're running a booster then a PWM regulator.  All that to run a single cell and garner the small number of useful steps under battery voltage.  Just a bad design in my opinion.  You get the disadvantages of both regulators and none of the advantages.  If you really want the wider range, better to use series cells with a PWM or buck regulator.  Or for a single cell, use a buck-boost regulator.

One thing that does make things tricky with PWM is the high currents.  For example, if you want to run an atomizer as low as 1.2 Ohms, you're pulsing as much as 7 Amps.  That's a lot of current.  The booster I use in my own mods has to handle input currents as high 12 Amps.  I have to jump through all kinds of hoops to accommodate those high currents.

A few comments on atomizers, the rebuildable dripping atomizers I'm using can handle a lot more power than anything else I've used.  With a 1.8 Ohm 32 AWG coil, I can run them up to 6V (20 Watts) and they still taste good, no problem.  If I do a 30 AWG coil around 1.5 Ohms they work well as high as 25 Watts, but that's way too much power, makes too much vapor and uses too much juice.  I've been running the 1.8 Ohm coils mostly around 17 Watts.  The filler type 510 cartomizers I was using before couldn't run above 12 Watts. 

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #174 on: September 25, 2012, 05:24:35 AM »
I agree using a regulator then modulating it is a complete waste of time as you don't gain a thing by doing it.  I just can't get why it seems to hit so hard at supposed normal voltage (about 3.5v) which my LEA puts out and tastes fine.
I know the VMAX had a problem where if you set it to 3v it was actually running 4.5v and that was down to the PWM being too high so through a standard DC meter it would read 3v as the average but if you checked it with an RMS meter it showed the true voltage.

Might be worth me trying to knock up a simple RMS meter on my Flashlab board and see if I can use that for testing - I can push the data out through the serial line with that really easily.

The high current issue is the main thing I'm thinking of though as I've got a soft limit of 3.5A at the minute but will probably go up to 5A now I've got the sensing sorted out.  The buck converter on the output may help that out as I'll be able to drive the voltage down to a DC value and get past that problem.  If I've been reading correctly I should only need a diode, inductor and capacitor to get the existing system running in buck mode so it's something I'm tempted to try.  I think that's how the Provari does it too but adds a feedback into an ADC line to run closed loop voltage control.  PID system's aren't too hard to work out, but there's the space issue again and extra cost of parts to consider too...

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #175 on: September 25, 2012, 05:06:38 PM »
Had a bit of an idea earlier and had a quick google to get some info.

I'm noticing how even using the multimeter to get the average voltage of say 3.5v it's hitting really hard - probably about what I'd expect at about 5v.

So, instead of working on the assumption that the pulse train is producing the average voltage, consider the possibility that it's more likely the RMS voltage that's doing the heating of the coil.

So, for a set voltage output of say 3.5v I'd be using 106/255 duty cycle or 41.5% which based on my average formula should be about 3.5v at the atty.
However, using a formula to calculate VRMS :-

VRMS=BATTV * SQRT(DUTY%)

I get 5.41v (8.4 * SQRT(0.41) = 5.41v) - pretty much as I'd expect for the hit/flavour I'm getting.
And checking the output using the AC volts on my multimeter I see 5.4-5.5 volts too.

So, I think I might have found the reason I'm getting burnt taste on the vivi nova fairly quickly.  I'll have to re-do the spreadsheet with the voltage calculation to re-calibrate and see how that works out - hopefully not so harsh and more like the actual selected voltage :)

Offline CraigHB

  • PV Master
  • *******
  • Joined: Nov 2011
  • Location: Reno, Nevada
  • Posts: 2023
  • Karma: +243/-1
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #176 on: September 25, 2012, 05:45:13 PM »
So, instead of working on the assumption that the pulse train is producing the average voltage, consider the possibility that it's more likely the RMS voltage that's doing the heating of the coil.

That's something normally taken for granted.  Your voltage indication and duty cycle calculations should be based on RMS voltage.  What you see in comparing a PWM output to a purely DC output is in terms of power.  Since apparent power is propotional to duty cycle, RMS voltage is proportional to the square root of duty cycle.

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #177 on: September 25, 2012, 05:48:34 PM »
Yep, and reading around the interwebs it seems most PWM mods coming out of China are making that very same assumption too!

Glad I'm slightly more with it today, despite only having two hours sleep :)

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #178 on: September 26, 2012, 10:49:31 AM »
Well after punching all the values into the spreadsheet and calculating the RMS values from the duty cycle and altering the correction for current battery voltage vs. max battery voltage I think I've got it right.
No more burning but a definite improvement in flavour and vapour all the way through the voltage range as it increases.

Just need to get a proper RMS meter built up I think to make sure my math is 100% but here's the general calculation:-

The duty cycle for 3.0v is 33 or 12.8% of the 255 step PWM scale so I work out that 8.4*(sqrt(0.128))=3.0v.

If the battery voltage drops to say 7v I work out the ratio which is 8.4/7=1.2 then multiply the duty cycle by 1.2 squared.
So the math is 33*(1.2*1.2)=48 or 19% which works out as 7*(sqrt(0.19))=3.0v

So, I think that bit is sound at least!

The current sensing doesn't work using the RMS voltage in the ohms calculation but seems to settle ok on the average voltage which is kind of what I'd expect to see as it's not the heating power but the actual throughput that translates into the current.  At least I think that's right :)

Now that brain drain is sorted I guess I'll take some time to vape on it a while and see how it runs :)

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #179 on: September 27, 2012, 11:11:00 AM »
Well after a day of vaping using the VRMS voltages I can say it feels too *low*.
On my LEA battery which is regulated at 3.4v I get a reasonable amount of VTF and the closest approximation using the VRMS setting is about 4.2v, anything below that seems a bit flat and lacking.

I think I'm seeing why the Chinese PWM mods selected VAvg for their voltage settings as the low voltage settings seem far too muted but the higher voltages above 4.2v work great.

I had a thought though.  A resistive load, say an incandescent bulb will alter it's light output given a DC voltage.  If I use a sealed compartment and add an Light Dependant Resistor (LDR) opposite the bulb and take resistance measurements at DC voltages I should have a DC baseline which I can then use to *tune* the PWM so it gives the equivalent output.
I suppose it should be possible using a fixed resistor to measure the current at the various voltages, but I'm still seeing drift using the ACS712 when running at PWM voltages so without a definite reliable method of measuring the PWM currents I don't think it'll be quite as accurate.

So, does the idea sound like it would work to tune the output so it gets to a better approximation of the equivalent DC voltage or am I running up the wrong branch of the tree?

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #180 on: September 29, 2012, 04:55:02 AM »
I do believe I've found the issue with the ACS712 and PWM.

The logical thing is to filter the output into the ADC to smooth out the signal to the ADC to get a relatively flat reading of the voltage.
However, as the wave coming out of the current sensor is using a 2.5v offset this changes the dynamic of the filter requirements as a normal filter will just smooth it down to around 2.5v instead of the higher range.
If the PWM train was actual AC it wouldn't be so much of an issue as there would be a positive to negative swing around the 2.5v offset, but being essentially a DC switched signal it means it always moves like a half rectified AC pulse which is where the ACS712 falls down.

One solution is to use an op amp to remove the 2.5v offset, but if I'm doing that I might as well just put in a shunt resistor and not use the ACS712.

Another thought I did have is to use a regulated voltage to do the sensing with.  If I use say a 1V feed switched via a MOSFET (to isolate from the main voltage out) into the load and then try and use the current sensor it should give a more reliable reading.  Certainly it would allow for a much higher accuracy than the PWM supply is offering.  Obviously this would cause issues checking the current while the atty is being fired, but the pre-check would make things a lot easier to detect over current/short conditions before the main voltage is applied.

I did try switching the MOSFET up at full voltage for a period but the stabilisation and reading time means I have to hold the full battery voltage to the atty for around 250ms for total stabilisation - which is far too long if there's a short circuit for my liking.  It also means it messes with the  normal operation when it periodically checks the current while the trigger is pressed.

So, still not much further along with the current sensing, but a few ideas are coming up.

Offline CraigHB

  • PV Master
  • *******
  • Joined: Nov 2011
  • Location: Reno, Nevada
  • Posts: 2023
  • Karma: +243/-1
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #181 on: September 29, 2012, 03:14:38 PM »
I'm sorry, but I just don't understand why you're having so much trouble with this.  I can't say for sure since I've never actually used a current sensor with a PWM driver, but the current sense chip you're using should be plenty fast enough based on the 5uS specification you quoted.  Is it not possible to synchronize your samples with the PWM pulse?  Once you have peak current and peak voltage, the rest is math.  You already know the duty cycle.  Trying to obtain an accurate reading by averaging a random current reading either in hardware or software is going to be very difficult if not impossible.


« Last Edit: September 29, 2012, 03:23:56 PM by CraigHB »

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #182 on: September 29, 2012, 04:37:33 PM »
I don't understand it either - even using the special event trigger to synchronize the sampling with the pulse train it's not stable at all.
I've done a fair amount of searching and I've not found a single success story trying to use these current sensors with a dc pulse train.   Plenty of problems, but never any solutions found.
I'm going to knock up a test circuit to try some different waveforms but I'm not holding out much hope.
I'm tempted to try the op amp to remove the offset and see what that does. But using a shunt resistor may be quicker and easier - only testing will tell I guess.

Offline CraigHB

  • PV Master
  • *******
  • Joined: Nov 2011
  • Location: Reno, Nevada
  • Posts: 2023
  • Karma: +243/-1
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #183 on: September 30, 2012, 12:57:17 PM »
Yes, try the op amp circuit.  It may be more stable.  A 10 milli-Ohm current sense resistor offers a reasonable trade-off for sensitivity and gain.

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #184 on: September 30, 2012, 02:41:06 PM »
I wonder how they do it in things like the Provari?  I'd guess it was an op-amp/shunt design.
In fact I've just had a look at the Provari PCB and they use one of these.

Will see if I can get a through hole one for testing and a suitable op-amp.  Hopefully I will get the stability I need to get the project finished with it.

Looking at the one on mouser it's only a 2 watt resistor so I'm guessing they don't do live sensing anyway as at the Provari limit it would be having to deal with about 20 watts.

I've attached the pic of the PCB where you can see it mounted below the positive out anyway.
« Last Edit: September 30, 2012, 02:45:13 PM by sterling101 »

Offline CraigHB

  • PV Master
  • *******
  • Joined: Nov 2011
  • Location: Reno, Nevada
  • Posts: 2023
  • Karma: +243/-1
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #185 on: September 30, 2012, 04:49:42 PM »
The one you linked to can handle about 15 Amps, no limitation there.

The one on that PCB may be used only to monitor an output over-current.  In that case, you wouldn't need an op amp, just use the MCU's comparator to trigger a cutoff level.  Can't say for sure, no way to tell how they do things just by looking at the PCB.

The Pro-Vari is buck-boost so it's going to be quite a bit different electronically than a PWM driven device.  There's going to be a lot fewer parts for a PWM device running series cells.  That's one of the big advantages of what you're trying to accomplish.  Much lower part count and much higher efficiency.

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #186 on: September 30, 2012, 04:58:35 PM »
Yep, sadly they don't tend to be very forthcoming in giving away their trade secrets and allowing access to the schematics :)

As long as I can get it working I'll be happy - this is the last part before I sign off and build the board diagrams up properly.  Yes I could probably do without it, but I'd rather have it for safety and completeness.

Still not sure how long the 16340's will last in the fully configured system though - I'm seeing at least a day while testing though and that's getting a lot of hammering at high voltages so once I've got it all set I can do some real world tests.  Hopefully I won't need to switch to another format but I could get away with 18350's easily enough I think.

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #187 on: September 30, 2012, 05:56:34 PM »
Have just ordered some samples of these

Hopefully should work ok as they've been used before in PWM environments.  So I just need to find a supplier for the shunt resistor that doesn't want over $20 for shipping!

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #188 on: October 01, 2012, 07:44:40 AM »
Have just been doing a little bit of thinking about calibrating the heating ability of the PWM to match an equivalent DC voltage.
I was considering using a bulb and LDR to compare the two, but I've just been wondering about using my de-bridged and de-wicked 306 atty with an NTC thermistor pressed against the coil.

The only thing I don't have the info on though is how hot the coil is likely to get.  I don't know, maybe it's a silly idea and I should just use the bulb method but it might just work as it will be a real atty coil so stands a chance of being more accurate???

Offline sterling101

  • Super Member
  • *****
  • Joined: Jul 2012
  • Location: UK
  • Posts: 180
  • Karma: +16/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #189 on: October 02, 2012, 01:26:25 PM »
Well, today I managed to dig up some LM35 linear temp sensors that I had lying around and managed to get a test rig set up with the sensor mounted about 1mm from a 2ohm coil I made up out of kanthal.
I decided not to use the batteries due to voltage dropping over the tests so used a 3A regulated PSU instead.

Did an initial test at 6v DC to make sure everything was ok and nothing was going to burst into flames (well, only melted the connector block slightly  :facepalm:) and went ahead and tested the entire range from 3v to 6v in 0.1v steps using my trusty LM2596 eBay special.
It gave up driving the coil at about 5.6v but gave me a decent range to play with.

I stored the temperature reading in a spreadsheet and then went to the PWM circuit and set that up on the test rig and performed the same test, storing the values in the spreadsheet for comparison.
I found, using the VRMS values the coil was about 20% below the heat that the DC had put out at the same voltage.  It varied very slightly over the full range but the mean average was 20% too low using the VRMS calculated values.

It would seem that adding the 20% to the existing VRMS values is giving me the right level of heat control over the coil.  As a test I used my LEA battery on a fresh coil head in the vivi nova and there was reasonable flavour, vapour and throat hit.
I then compared using the old PWM values at 3.4v indicated voltage and it was very light on the vapour and throat hit although the flavour was still cutting through.
As a final comparison I used the new PWM values calculated using the 20% correction value and the difference between the straight regulated 3.4v from the LEA and the 3.4v on the PWM output is very very minimal.  There's maybe a touch more throat hit with the DC, but that's all.

So, my findings with the PWM setups so far...

Voltages that are calculated as an average using the  V=BatV/DutyCycle% are way higher than their DC equivalent.
Voltages that are calcualted as an RMS voltage using the V=BatV x Sqrt(DutyCycle%) as lower than their DC equivalent.

So hopefully running at VRMS+20% is giving an equivalent to a straight DC voltage or as close as can be achieved without some additional filtering going on and doing a fully active feedback loop to constantly adjust the voltage accordingly.  As I'm adjusting for battery drop out every second I don't think I'll go the route of all the extra components needed to improve it's accuracy as it's not too noticeable on decent batteries.  Even on the set of batteries I've got that are beginning to age it's a relatively smooth output with only a small change in voltage noticeable as it does it's correction.

From what I'm reading about the latest PWM driven mods that are coming out, the Chinese could have done with doing something like this before releasing the VV Gripper, VMax and ZMax!
« Last Edit: October 03, 2012, 06:41:13 AM by sterling101 »

Offline audiophile_user

  • Jr. Member
  • **
  • Joined: Jan 2013
  • Location: Philippines
  • Posts: 10
  • Karma: +1/-0
  • Gender: Male
Re: Beginnings of another MCU mod - but using PWM
« Reply #190 on: April 09, 2013, 10:32:54 PM »
hopefully there is a complete guide of this mod for an experiment. :) pushing myself to the limits :)

Breaktru Forum  |  eCigarette Forum  |  Modding  |  Topic: Beginnings of another MCU mod - but using PWM
 

gfxgfx
gfx gfx
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!