Breaktru Forum

eCigarette Forum => Modding => Topic started by: sterling101 on July 25, 2012, 07:21:24 PM

Title: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on July 25, 2012, 07:21:24 PM
Having seen the post by asnider about using PWM to drive the atomizer and it's associated benefits pn battery life I thought I'd give it a go as part of a tube mod.

I've got a stainless steel cigar holder which is perfect for transforming into a mod and should have just enough room inside to fit a small display, a couple of buttons for settings and a main button for firing the atomizer.

I'll be using the MCU to drive the atomizer in a PWM pattern which should allow for a reasonable level of control over a simulated 3-6v range.  I'll be using two Ultrafire 16350 batteries initially but might move up to some 18350's if it all works out ok for even more capacity.

As yet things are very much in the design stage but I'll upload pictures and info as I progress through and don't be surprised to get the odd dumb question from me from time to time as it will be my first VV mod although I've got a few years MCU design/build experience under my belt :)

Leigh 
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on July 26, 2012, 03:44:35 AM
Should be really interesting.  Look forward to hearing about it.

When I saw the post some time ago using a 555 chip, I thought, "that's kind of weak, should be using an MCU."  Good to see someone is going to have a go doing it the right way.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on July 26, 2012, 06:12:16 PM
Well tonight I successfully made a button turn on a PWM driven light - oh how long it's been and how much stuff that used to be readily to hand has gone missing after a house move!

Still, have got quite a lot on the way from TI including MOSFETs, LDO's and Current Sensors so should have some fun times ahead!
Been measuring up too and think I may have to go with touch switches for the controls and a tactile I've got which is 12mm, but it seems to work well, for the actual main atomizer trigger.  I'm waiting on a 4 digit voltmeter to arrive which supposed to be very small (lavatube small) but that will decide my controls ultimately.  Space wise though I'm going to go with a PIC16F876 @ 20MHz as they're relatively compact, have all the inputs and outputs I need and most importantly I've got a few knocking about so it's a no cost option for me :)

Will try and get all the ideas I've got on paper into some kind of order and make a post up here with a schematic soon so you can get some idea of how it will all tie together.

But for now - light goes on.... light goes off.... light goes on.... light goes off....  :D
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on July 26, 2012, 06:40:52 PM
Just took a few shots of the cigar tube - around 22mm diameter by 160mm long.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Breaktru on July 26, 2012, 07:07:05 PM
Sounds like we have a winner in the mix  ;cheers;
Can't wait to see more photos as it progresses  :yes"
Nice going mate
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on July 26, 2012, 09:19:00 PM
As the atomizer will be driven at battery voltage via the MOSFET I needed a way to compensate for the battery drain.  At full 8.2 volts for both cells it's a nice easy job of setting the PWM duty cycle to match the required voltage eg. 6.15v=8.2v/0.75 so a 0.75 duty cycle.  However at say 7v from the batteries the same equation would give 5.25v so to compensate for the drift a pre-calculation has to be made.
As I'll be using a 256 division duty cycle the formula is relatively straight forward.  As 0.75x256=192 the equation would look like this...
If the battery voltage is at 7v - (7v x 192) ÷ 256 = 5.25v
So to correct the output we take a ratio between the nominal voltage of the fully charge batteries and their current level so 8.2v ÷ 7v = 1.17 now use this ratio to multiply the duty cycle and we get 192x1.17=225.
Apply this in our original formula (7v x 225) ÷ 256 = 6.15v which is what we're after!

This works even at a random value say 6.82v - (6.82 x 192) ÷ 256 = 5.1v
The ratio between 8.2 and 6.82 is 1.2 so the PWM duty cycle needs to be 231.
Which gives us (6.82v x 231) ÷ 256 = 6.15v which is what we're after

There are a few floating point rounding issues that mean the final simulated voltage has about a 0.1v margin of error but that's not a drastic amount and I can definitely live with it.

Obviously if the batteries drop below the voltage out this becomes an issue so the battery range will be between full charge and the 3.7v lower end and the MCU will not fire and show a low battery indicator to prevent it from damaging the cells by running them too low.

Leigh
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on July 27, 2012, 02:28:26 PM
Sounds like you got the math all worked out.  That's sometimes the hardest part.  Once you have a good idea how you want to do something, the rest often just comes together in a more simple way than you initially expected.

Accuracy is always a matter of the overhead you're willing to pay for in terms of expense and simplicity of design.  That's always a tough one to work out.  What you propose sounds resonable.

That's expected that you need to incorporate sanity routines into your program to protect your circuit.  Nothing unusual there.

It's going to be interesting to see a working circuit.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on July 27, 2012, 02:45:15 PM
Well as I'm waiting for components to arrive I started coding the first part today, mainly the battery voltage detection and compensation formula for the PWM outputs.
Next stage is testing the closed loop section.  Still not sure whether to get the values when you press the trigger, or do it say every second or so and process the correction while you're still vaping.
Another first for me as well will be using the MCU's sleep mode and wake up on external trigger - should be nice and easy though all being well :)

I've also been doing a few measurements on the cigar tube and found the 12mm tactile switch that I have which I thought was far too big actually will look ok when mounted.  There should be enough room then to mount the display and switches on one side of the board and have the chips on the other side.  I've decided as well that I should make the longer portion of the tube the main upper body, and the shorter end to house the batteries as it gives me a chance to lop the end off and sleeve it before mounting everything inside and will make the battery negative terminal much easier to mount too.

I'm hoping to get the stuff from TI on Monday so I can get a breadboard set up with the components working, about the only thing I might shout for help on is the MOSFET connections as it's not something I've played with before :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on July 27, 2012, 04:43:19 PM
I think you'll find that waking and sleeping the MCU is not a big deal.  I think you said you're using a PIC?  Just use the "input change notification" module for the button inputs.  Handle waking in an ISR block of code that disables the interrupt.  Put it to sleep checking a timer with a block in normal code that enables the interrupt.  For user input, you can just poll the buttons like you would if the MCU was not waking and sleeping.

You might need to filter your AD inputs.  A simple low pass filter is usually sufficient.  You'll probably want to sample output in sync with the PWM.  Just read the output bit for the MOSFET gate and take the sample with a small delay on each pulse.  Though careful with that, it can be tricky reading output ports.  If there's an MCU register you can query for the PWM state, that would be better.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on July 27, 2012, 05:29:09 PM
I noticed you did a similar thing on your Powerblok 2200 - so it will wake the display for a period while adjustments are made but not when the atomizer is fired.
Do you have a routine in place which actually switches down the MCU into sleep after a period of time or are you running a sleep command as soon as the trigger is released?

I was thinking of having the PIC sleep after 5 seconds if no activity is detected.  Then it could be woken with either the main trigger or voltage adjust buttons.  Or the other option is similar to how you did it with a long press on a button to shut it down.

Do you mean sampling the output from the PWM pin for the closed loop?  I wasn't considering that at all, only reading direct battery voltage at intervals then adjusting the PWM values to suit.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on July 28, 2012, 03:21:07 PM
My device wakes whenever user input is applied, either pushing a button or firing the atomizer.  It logs the event and adjusts the sleep timer accordingly.  For a button push, the sleep timer is set to 10 seconds.  For a trigger push, the sleep timer is set to 1 second.  The delays are fairly arbitray and a matter of preference.  The reason for the short sleep delay after a trigger push is so the charger is not disabled any longer than it has to be.  With my design, the charger goes into standby whenever the MCU is awake.

The rate at which you take your ADC samples is determnined in code.  It's common for MCUs to have max sample rates as high as 500K samples per second.  You'll decide how often to sample in code.  For battery input, you could just sample once before the atomizer is energized.  That might be better since you will have less noise interference when there is no load, no filter required.  Heavy current flow means noise which can interfere with sensitive circuits.

For output, you'll want to monitor current so that's what I was referrring to whan I mentioned taking samples in sync with the PWM.  You'll probably want to filter that AD input since the circuit will be noisy when powering the atomizer.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on July 28, 2012, 03:40:14 PM
Yep, that makes sense to me now.

I have a current sensor on the way from TI to try which hopefully should work ok to interface to the PIC.  I'll test that and see if it's going to need filtering as it may or may not depending on how it's output comes through.

Been scribbling stuff down for the circuit today and think a 50/50 split divider for measuring battery volts should work ok.  I can then keep the range as if for one cell so from 4.2 down to 2.7 in 10bit resolution.
And I came to the same conclusion too - take a sample when pressing the trigger then let the PWM run from that sample.  I'll put a max trigger time of 12 seconds in place too which should prevent over-drain on the cells in one go.

And if I do the next stage of adjustment in a completely separate section there shouldn't be any issues about time slicing to fit it all into the CPU cycles.  So basically if you press the trigger, you can't adjust anything.  Likewise if you're pressing the adjustment buttons you can't fire the trigger.

I've chosen a default of 50us sample time on the ADC which should be enough to get the voltage in from the battery ok.  I just need to have a play to get the right frequency on the PWM output as I've got a range of frequencies I can play with on that side of things.

As far as the sleep timer goes I'm still not sure whether to try and include a cold shutdown mode so it's not possible to fire by accident if in a pocket etc.
I agree with your settings of 10 seconds on adjust and 1 second on trigger then wake on any input.  But would definitely like a hard shutdown system, say press the down adjust button for 3 seconds and it will power the system down until the same button has been pressed again for 3 seconds.

I suppose another method would be to include a system like the 5 click on/off on the ego using the trigger.  Might need a bit more work with that though as it needs to know when it needs to be woken up fully.  My first guess would be to go into sleep if the trigger is pressed 5 times within a 2 second period and have it ignore all other inputs except for the trigger to wake.  Then check for the same sequence to get back into the main program loop.

Need a bit more thought on that though before I can say definitely how I'll be able to do it...

Oh and the last thing I thought of while saving the source code file is the mod's name - I called it the PICVari :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on July 28, 2012, 04:35:20 PM
I can see the gears are turning :)  I know the feeling well.  There's always different ways to do something.  The main thing is that it achieves the end result in an efficient manner.  The only limit is your imagination.  The design is is definitely the most fun part of a project.

A shut down mode is not a hard thing to implement.  I just use a long button press, up button for on, down button for off.  It puts the MCU in a mode where it does not respond to anything but the long button pushes.  It wakes on a button push, sees the off flag, and then rolls over and goes back to sleep without responding.  It's certainly not a master power switch, but it does the same thing in effect.  I'm sure there's other good ways to handle it, but that's how I do it.

Hehe, my files have had different names.  When you settle on a file name, you know you've named your device.  My files are all prefixed with Powerblok.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on July 28, 2012, 05:36:35 PM
Now that's a good idea - + for on and - for off.  And I was thinking of storing the default value in the on chip eeprom on change so if the batteries are removed it will remember the last setting.

Only a small thing, but just means if I've found a sweet spot I don't need to dial it in every time :)

I've been looking for a small display for it too.  I've got one of these on the slow boat from China - http://tinyurl.com/cebbn9y (http://tinyurl.com/cebbn9y) which is quite small but for me not really small enough considering what I've got to fit in.  Ideally I'd want a 2 digit display about 15mm wide by 7-10mm tall.  Can't find one though sadly, so I might have to make do with the larger one from ebay :(

It's a shame nobody's come out with a super-sub-minature 4x1 LCD display that would work.  Got one on my watch, but I kinda need that to tell the time :D
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on July 28, 2012, 07:18:44 PM
Yes, everyone who builds e-cig mods wants a small numeric LED display.  Haven't seen one yet and everybody has been looking.  You can get pretty small numeric SMD LCDs from the usual supects like Digikey and Mouser, but you need to drive them which is more trouble than they are worth.  Best solution is always going to be a text or graphic display with a serial interface like SPI or I2C.  They're bigger, but they're also much more flexible and can display a lot more information.  The trick is figuring out how to fit one in your enclosure.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on July 28, 2012, 07:26:15 PM
Yeah with a tube that's pretty much exactly 20mm diameter it's a tight old squeeze!
Will see what this volt meter looks like when it arrives - might actually fit ok and just need to pop a cover over the hole in the tube.

Found a PIC18F2550 built into a USB stick earlier which I though was a great idea - except it's about 4mm too big for me :(

http://tinyurl.com/c9o2bym

Would make for a great project board though!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on July 28, 2012, 07:59:05 PM
With a 20mm tube mod, you're looking at some serious miniaturization.  Better invest in a good stereo micorscope if you don't have one already :)

Check these (http://www.mouser.com/Kingbright/Optoelectronics/Displays/LED-Displays-Accessories/_/N-6j73bZscv7?P=1z0wul7Z1z0zl4c&Ns=ManufacturerPartNumber%7c0) out.  Many of them will fit with room to spare.  Since you're running an MCU, you're going to want to drive the digits yourself anyway.

I kind of had a brain fart on that.  The first battery mod I did used an LED display and I put a couple of these (http://www.mouser.com/ProductDetail/Kingbright/ACSC03-41SGWA-F01/?qs=f499HRGa1RmbYJjDa9ReCd1HEmQGvjpkdm5%252bNvjDOuhdYDnDFE%2fJIQ%3d%3d) together.  Though, I think I ordered the singles only because they were out of stock on the doubles.  No big deal, just harder to assemble.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on July 28, 2012, 08:09:10 PM
This (http://tinyurl.com/cvby6kx) looks absolutely perfect size wise!

Just been considering the format for lining things up and I think having the main PCB centered in the tube which will at least give me room above and beneath the board to apply wiring and components.
I know it's going to be tight, but I think it should be just about doable - just may have to cut back on features in favour of practicality :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on July 28, 2012, 09:39:05 PM
That should do it.

My suggestion would be to sandwich the boards in there.  If you use SMD components each board will only be 4mm thick.  You could easily stack three of them.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on July 28, 2012, 09:48:55 PM
Even without using SMD components the main board won't be too thick.  I do have the advantage of having about 3 inches of length to play with until it gets too tight at the battery end so I can spread things out a little if needed.
My main thing though is going to be component placement and ensuring there's no chance of shorting against the sides of the tube.
I might give the inside a gentle spray of paint to assist with that part though :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on July 29, 2012, 09:29:51 PM
OK stupid question time...

I bought my LC16340 batteries with a charger that was thrown in for free.  All the info is right and it has charge lights for each battery which are red when charging and green when done.

However, if I take a battery that has been on charge for a while and is green on the charger I only see 3.7v not 4.2v as i'd expect.
This is why my ADC calcs looked so far out lol

So, the question is, should my chargerbe outputting 3.7v which it does or I need one that puts out 4.2v for the extra charge?  I've had a look at my old cig-a-like and SD keyring chargers and they both output 5v so I'm proper confused now lol
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on July 30, 2012, 02:21:12 AM
LiPo, LiCo, and LiMn 3.7V cells all come off the charger at 4.2V.  If you're getting a reading of anything else after a cell of that type comes off the charger, there's something wrong, probably the charger. 

The terminal charging voltage for a 3.7V Li-Ion has to be exact, 4.2 Volts plus or minus 30mV.  The charger controllers I use are never more than 10mV off.

The LiFePO4 Li-Ions are 3.2 Volts nominal and come off the charger at 3.6V.  If you have one of these types of cells, the only good place for it is the trash bin.

If you don't already have one, invest in a good DMM (digital multi-meter).  Cheap ones can go screwy or they can be way off right out of the box.  For someone planning to do anything with electronics, a good DMM with high accuracy and quality is #1 on the equipment list.

http://www.youtube.com/watch?v=A6mKd5_-abk

http://www.youtube.com/watch?v=n3WGaiYF2sk

http://www.youtube.com/watch?v=3-_dUB8vy8U
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on July 30, 2012, 05:17:49 AM
That makes sense then - I've got a couple of the LiFePo4's and they came with the same charger so I guess it's the charger at fault!
I'll get a new one made up from the spares I've got lying around - won't be too hard and as they're protected batts I shouldn't need to do too much with them unless I want to build a current sensor in but I don't think I need it off the bat as some of the spare charger's  I've got have a bi-colour LED showing charge status anyway so can just butcher one of those and put it into an enclosure.

Had a load more stuff come from TI this morning too - damn their SMD current sensor's are small!!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on July 31, 2012, 01:29:17 PM
Well the voltage display arrived and it might just work being the size it is - win!

Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Breaktru on July 31, 2012, 03:21:59 PM
nice and slim  :yes"
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on July 31, 2012, 03:31:41 PM
It'll actually fit inside the tube dead central and the display then will be just the right distance from the outer edge where the aperture will be cut out.

Looks pretty good too in blue even though it's the brightest thing in the room when it's on :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: banshee on July 31, 2012, 03:38:30 PM
That's a nice looking small meter. I see 3-wires. I assume it needs it's own power source?
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on July 31, 2012, 03:57:14 PM
Yep, positive feed 4.5-17v then a feed for the meter input.

Should work ok as it's got a nice low drain on it of around 5ma :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 10, 2012, 05:18:55 PM
So after much messing around and killing drill bits I'm just going to use the cigar tube as a basic VV mod - possibly with the PTR08100W and a trimmer.  It's just too damn hard to work with and it's also rather cramped in there for trying to fit everything in :(

I'm still going to do the MCU mod though once I get hold of the right MOSFETs I can use and a decent display to go with it (why can't you find watch style displays anyway these days????).  I'm on the look out for something like a 1" tube which gives me enough room to fit everything in including the buttons, MCU board and have enough room for a display too.

I've been mulling over my MCU options too as using the PWM and needing to monitor and adjust the voltage out based on battery drain means I have to use a PIC with a built in ADC which limits things slightly on the form factor front.
I'm looking at using a PIC16F876A which is a 28 pin DIP configuration as I have those readily available from previous projects.
But I've also noticed some rather handy looking boards with built in regulators on eBay (http://tinyurl.com/cfrr3mv), so I might end up using a smaller set up but that's yet to be decided as I'm keeping my options open on that depending on whether the display ends up driven by the PIC directly or not.

After much thinking and thinking again, my ideal set up would be using a boost board from a single battery to ramp up to 6v.  Then use that 6v driven though the MOSFET to fire the atty.  But again then we come up against the old favourite of space as I don't want a box mod, but something similar in size to a Lavatube or Provari.  I suppose using something like the PTN04050C I could try and squeeze it all in place using an 8 pin PIC to generate the PWM and not worry about the ADC side of things.

See, I'm getting lost in my own thoughts and can't make my mind up where to take it :D

I suppose the first question would be.... Does the output drop as the battery voltage drops on the PTN04050C or does it remain stable until cut off?  I could use an on-chip comparator to shut everything down on low battery voltage so that shouldn't cause too much of an issue all being well.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: DRA on August 10, 2012, 06:28:03 PM
Have you seen Raidy's Cigar tube mod?

http://goo.gl/Dcx8s (http://goo.gl/Dcx8s)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 10, 2012, 06:32:52 PM
Yeah it was that I saw that originally made the decision for me to buy one to give it a try.

Sadly though I just don't have the metalwork tools to work it properly.  If I had my own machine shop so I could easily cut and drill 1mm thick stainless I'd get it done on the spot lol

Might try a copper pipe for ease of working though and increase the internal diameter from 18mm to 22mm/24mm to help with finding space.  Also means I can use the nice carbon fibre weave fabric I've got to wrap it in to make it look extra sexy :D
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Breaktru on August 10, 2012, 06:35:58 PM
How about in leather: Cigar Tube (http://www.alibaba.com/product-gs/228018076/cigar_tube_big_size_aluminium_leather.html)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 10, 2012, 06:40:20 PM
Well in my box of bits I've got leather, carbon fibre weave vinyl, actual carbon fibre, carbon kevlar, alcantara and general leatherette bits - can you tell I used to trim Miata's for a living?? lol

Just spotted a possible useful MOSFET too - http://tinyurl.com/br5kvlm
Hopefully it should hit the switching levels without generating too much heat... hopefully!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 10, 2012, 06:42:02 PM
Also found this display which should fit nicely into a tube mod - http://tinyurl.com/c3ovesp
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 10, 2012, 09:24:07 PM
Looks like a good one.  The reason you don't see a lot of really small displays is they're usually custom made for products with orders in the thousands.  For example, I could go to Newhaven Display (http://www.newhavendisplay.com/) and have them make me an LCD any size I want with any character set I want, but I would have to order 1000 of them.  Only recently have I seen really small ones available off-the-shelf in small quantities, which is good for us.

As far as architecture, you're not going to want to involve PWM externally with a DC-DC converter.  It's no help.  Any DC-DC coverter already comprises a PWM controller.  It would be like running two regulators in series, there's just no sense in it.

If you're thinking in terms of bulding your own PWM controller for a DC-DC converter using an MCU, it's not going to be practical.  The switching frequencies required are too high for the PWM module most MCU's provide.  Then there's the coding which would be be quite a challenge to tune since LC circuits are naturally unstable.  That's why a controller chip is normally used in the first place.  As far as converters go, you'll want to use either a module or build one yourself utilizing a PWM controller chip designed for that purpose.

A boost converter is your only option when limited to a single cell.  PWM is limited to battery voltage which is too low.  When considering a device that utilizes series cells, you have the option.  You'll want to use a either a buck converter or a PWM regulator.  The PWM regulator has some big advantages, but since output is pulsed rather than DC, it can make things a bit convoluted.  However, a PWM regulator is considerably more efficient and has a much lower part count.

With a DC-DC converter, output voltage is not dependant on input voltage.  In other words, even with a low battery, output voltage will be maintained.  There are some caveats with that.  For a boost converter, low input voltage can cause input current demand to exceed the limit for the converter or battery.  In that case, output voltage will fall off.  For a buck converter, if output voltage demand exceeds that of the battery plus droput then output voltage will fall off.  A properly designed system accounts for all conditions and maintains output voltage througout the normal input voltage operating range.

Another consideration is that buck can only reduce voltage and boost can only increase voltage.  Most production VV mods utilize a buck-boost converter to provide a range of voltages above and below the voltage of a single cell.


Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 10, 2012, 10:00:28 PM
I was thinking of using the 7 segment meter style but if I'm trying to shrink the whole footprint down it's kinda counter productive due to the amount of signal pins I'd have to use to drive it.
Using an 8x2 lcd should mean I can use a simple pic with 8 pins for the main control and still have enough room to squeeze an lcd driver in too and pass info via a single data line.
Tomorrows task though will be trying to get a lead on some tube that's about an inch which should give me enough room to fit it all in with room to mount everything neatly.
And I might take the angle grinder to this cigar tube to open up the window for this existing voltmeter I've got.  Might try and build a quick mod out of it just for fun too :)

Just read through all 35 pages of Alan's pwm thread on ECF - interesting conclusions there and makes me want to get this sorted even sooner lol
Title: Re: PICVari MCU with PWM - WORKING!!
Post by: sterling101 on August 11, 2012, 10:58:37 AM
Well after lifting one of the nice n-channel MOSFETs from the old motherboard I had lying around and popped some tails on it I managed to get a fully working VV breadboard set up today!

Had a small issue at first where it wasn't reading the battery voltage, but it turns out my breadboard has seen many better days and the divider hadn't quite seated right in its hole.  Once that was sorted and the frequency adjusted it's running like a champ!

Next step I suppose is sort out a display of some sort as this volt meter I've got doesn't do rms so you only see a nice battery voltage jumping about a bit and I really want to show the battery voltage and the output simulated voltage which would be a real pain to sort only having a 5v reference and going up to 6v on the VV.

Plenty to think about anyway but for now we're cooking on gas :)

Edit:  Now working with timers in place to cut the atty trigger at 12 seconds and does a forced sleep after 5 seconds of inactivity which is only woken up by the main trigger.  Also does a forced sleep if the battery voltage drops too low.
Still need to work out the cold shutdown, but that's a minor issue considering how well this bloody thing vapes!!!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 12, 2012, 07:12:33 PM
Ok, for those who might want to see how it all connects up here's a couple of images.

The Schematic has the LCD module on it just so I could work out all the connecting links etc and the PCB has the actual copper traces and also the silkscreen on but that won't go onto the finished board, it's just to help me out when I'm putting it together.
The yellow lines between pads are wire links so I can keep things single sided as I've not actually etched a PCB for something like 18 years - too damn easy outsourcing stuff when you've got the cash, which sadly I no longer have lol

So, if anyone can read all the mess that is the PCB, shout if you see any glaringly bad errors cropping up :D

Edit: Just found one and corrected so I'll set the challenge again - can you see anything wrong with the PCB layout?
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Breaktru on August 12, 2012, 07:57:19 PM
Nice going.. Not knowing much about the PIC and checking the correctness of schematic to PCB, I would like to make only one comment:
Do you think maybe it would be wise to increase the weight of the trace lines for the atty to mosfet to battery do to heavier current? What weight did you use because it looks the same weight as the signal trace lines.
Been there, I have once blown a trace line and fixed it with a jumper wire.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 12, 2012, 08:00:25 PM
Good thinking Dave - I'm using the same weight for all traces so boosting those up will probably be a very good idea if I can fit it all in :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Breaktru on August 12, 2012, 08:04:22 PM
Good thinking Dave - I'm using the same weight for all traces so boosting those up will probably be a very good idea if I can fit it all in :)

If widening the trace lines are not possible do to space, perhaps you can parallel some wire over the the trace lines and tact them to the components.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 12, 2012, 08:10:20 PM
Managed to shuffle the trace a little by the ICSP header so should now be better.  Just loses visibility on a trace under a wire link line but I know it's there so not a problem.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Breaktru on August 12, 2012, 08:45:44 PM
Managed to shuffle the trace a little by the ICSP header so should now be better.  Just loses visibility on a trace under a wire link line but I know it's there so not a problem.

Good fix.
Just as a heads up, I have the trace size current relation here: http://breaktru.com/smf/index.php/topic,543.msg3462.html#msg3462 (http://breaktru.com/smf/index.php/topic,543.msg3462.html#msg3462)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 12, 2012, 08:49:52 PM
Great info there!

Looks like a wire link of suitably heavy wire may be in order as using a 6A trip PTC I'd need a 3.5mm trace - about 10% of the board width lol
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: timesarerough on August 13, 2012, 12:40:27 AM
If widening the trace lines are not possible do to space, perhaps you can parallel some wire over the the trace lines and tact them to the components.

This is probably a really dumb question considering that I have VERY little knowledge....but, why not just do a double sided board with a paralleled secondary trace on the reverse side?
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 13, 2012, 01:20:00 AM
Not a dumb suggestion at all.  I use a 4 layer board and use wide traces in all 4 layers to carry current to and from the atomizer.

Using the trace width calculator (http://circuitcalculator.com/wordpress/2006/01/31/pcb-trace-width-calculator/), you can find the heating and the resistance of whatever trace widths you choose.  I can tell you already, they are not nearly wide enough.  You may have to increase the size of your board or use a multi-layer board with traces on both sides.  A 3.5mm width would probably be about the minimum you want for currents up to 5A.  If the traces are a problem, use wires instead.  A 24 AWG copper wire is equal to a 6mm trace width using standard 1 oz copper.

Typically, you want to avoid angles other than 45 and 90 degrees when laying out traces.  You don't *have* to do that, but it's considered proper design etiquette.

Avoid right angles and pockets with traces.  You want to round them with a short 45 degree span.  The reason has to do with the manufacturing process.  Sharp angles and pockets can cause the etchant to over-shoot the corner.  Some board houses will do it automatically as required for the etching process, but that's not guaranteed.

1.5mA is high for a pull-down circuit.  I'd use at 10k pull downs at the minimum.

You can use pull-downs on your tactiles like that and software debounce them if you really want to, but I normally hardware debounce my tactiles with pull-ups (switch on the low side).  Hardware debouncing is better since it also affords some ESD protection.

Dedicate your ICSP clock and data connections.  You'll have trouble if you try to share them.  You have the spare pins for it.  You can run 10k pull-downs on clock and data if you like so they are not floating inputs.  You can also set them as outputs in code if you want to float them.  It will not affect programming.

The LCD and the voltage divider for the ADC are drawing power full time.  If you don't plan to use a master switch to shut the device off when you're not using it, you can use small signal MOSFETs controlled by the MCU to switch them off and on as required.  There's probably no point in putting the MCU to sleep if the hardware still consumes a good amount of power.

There sould be .1uF decoupling capacitors (nothing special, just an MLCC type) as close as possible to the power and ground pins for the LCD and for all VDD-VSS pairs on the MCU.  Some of the PICs have AVDD and AVSS pins as well.  Those should be connected to power and ground unconditionally and also decoupled.

If you are going to submit your board for fabrication, it will be a two layer board by default.  Use a ground plane on the bottom layer.  In other words, a copper fill connected to ground should cover the whole bottom layer.   Ground planes greatly reduce electrical noise which can cause spurious resets or failures in code execution for the MCU.  Run as few traces as possible in the ground plane.  You want to make it as contiguous as you can to optimize its effectiveness.


Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 13, 2012, 05:02:32 AM
Cheers for the input Craig - really appreciate it - got to keep reading it now so it all goes in :)

Might go double sided but as this is a play thing really I'm doing it in house as the missus would most likely kill me if I spent the money required to get it made up externally, I'm getting ready for some silent running over the component costs :D
I've just got to get some etching crystals and I've got the rest here to make it up (laser printer, copper cad board etc).  If I do go double sided the wire links will disappear anyway in favour of some through hole links.

Resistor values are something I was going to question anyway - I just popped in a default resistor from the list which just happened to be 3K3 but I've got 10K's in the basket ready for when I place the order.

Was thinking about the LCD and voltage divider last night and came to the same conclusion.  I'm going to have a look at whether there's enough current in this MCU to drive it directly as the LCD I've chosen is incredibly light on power requirements.  Then again it's about half inch by three quarters and I can't tell yet if it has a backlight as the data sheet's a little generic it seems.
The MCU is a fairly new one and has only been released about two months but it has some great internal clock speeds from it's own oscillator and good I/O too while keeping the pin count right down.  That was my main reason for choosing it - multiple A/D channels and lots of CCP modules that can be re-mapped around the chip at will.


Also reading on the current draw I think the battery in and atty out are going to need to be fairly beefy connectors, or just go for through hole wiring which given the tight space may be the best option.

I've upped the board width to 24mm as I now know it won't fit at all into the cigar tube without being far too long or far too fiddly for my dodgy hands lol - am looking at another nice tube here that has an ID of 25mm.  Switches and LCD will sit on a second board that will sit on top of this main one (or below, depending on which way around you're looking at it) I've just got to get this one right and then I can look at that board then.

Have got a few more changes to make then will post a pic up of the current stage - hopefully it'll be getting nearer...
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 13, 2012, 11:08:46 AM
OK, here's the latest PCB layout.  Have increased dimensions to 24mm x 67mm and increased the trace size for the atty and also shortened the runs quite a lot.
The green traces are wire links - large green=high load wire.  Hopefully with the addition of two transistors, one for the voltage divider and one for the earth for the LCD it should mean I can control the external drains fairly well by switching them on and off as necessary.

Will upload the schematic once I've finished messing with it as I seem to have cocked up and got my pins back to front on a few things - guess that's what happens on 2 hours sleep....
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 13, 2012, 03:30:54 PM
Well here's the new schematic - hopefully it all matches up ok to the PCB.

Forgot to mention I've put a 6 way jumper header in place for the ICSP control so you have the jumpers on pins 1-2 and 5-6 to program and 2-3 and 4-5 for normal operations.  Saves trying to re-arrange the tracks even more and should work fine as it won't be often it'll need to be re-programmed :)

The new wider traces are 3.81mm or 0.150" so should be good for 6A all being well.  Just wondered if anyone else is using PTC fuses and if so what values you've gone for?  I'm looking at using a Multicomp MC36202 which is a 3A hold 6A trip (Info here - http://tinyurl.com/cyo3rt9) which I think should be ok but I'm open to suggestions of better ones if you know of any!

Edit: Forgot to attach the file!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Breaktru on August 13, 2012, 04:12:03 PM
I use this PTC: http://goo.gl/KeVPw (http://goo.gl/KeVPw) Your 3a / 6a looks fine to me. My PTC has less internal resistance and use two in parallel for even less resistance. Also mine is a lot smaller.
Once you have your mod hard wired, expect to tweak the code a bit. At least that is what I have experienced.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 13, 2012, 04:17:07 PM
Use the SMD PTC fuses.  They're a lot smaller and they have lower resistance.  Littelfuse makes a line with ultra-low resistance.  I use a 1210L350SLWR.  The other option would be to just use protected cells.  That would make the fuse redundant, unless of course, you want the fuse there as a backup, nothing wrong with that.

Having your PCBs made should not be an issue for cost, maybe for time, but it's usually not a problem for me.  I use these guys;

http://dorkbotpdx.org/wiki/pcb_order

It will cost you about $10 for three 2 layer boards that size.   You would have to use different software though.  He takes raw EAGLE files and Gerber plot files.  You can use the free version of EAGLE.  It's limited to 4 inches in board size and 2 layers, but your board is within those limits.

I would recommend against using jumpers.  For one, they take up some space and you'll probably forget about them.  You may be surprised how often you will re-program your board when developing your project.  If you use a 2 layer board, trace routing will be less of an issue.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 13, 2012, 04:28:14 PM
Now that's an incredibly cheap price for those PCB's - just installed Eagle so going to have a play and see how I get on with it.
Wanted to pop a fuse in place as although I'll be using protected 16340's at first I'll probably get some higher capacity IMR 18350's to run with if I feel the need for a spare set.  Seemed like a bit of forward planning could save a few batteries in the long run should any problems occur on the atty end!
Looking at the SMD fuses I might grab a few on the order (which is steadily growing as I'm working things out) so I have the option then for on other projects I can use either.

I only went for jumpers as it meant I could align them in a place where clearance wouldn't be an issue and when I'm testing I'll be using the DIP version of the chip on the breadboard anyway so it'll only be on rare occasions after the first few trials that I'll be updating.  The other reason is I've got so many headers and jumpers I might as well find a home for them somewhere :D

Right, time to learn Eagle....
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 13, 2012, 05:54:10 PM
I think that PCB fab charges $5 for international shipping.

Sorry to say that EAGLE is a real PITA to learn, but, it's going to be a lot more flexible than the software you're using now.  It's designed to build PCBs from schematics, but you can design your boards directly in the board editor by manually placing "routes" before laying out traces (routes is the EAGLE term for an electrical connection) .  It's weird, but that's how it works.

Just saw your schematic, missed that before.

You're missing the bias resistors on the base connection for your bipolar junction transistors.  You can can use bipolar transistors if you really want, but MOSFETs are generally considered a better solution.  MOSFETs do not need to be biased like bipolar transistors.  Eliminates the need for a resistor that way.

That switch on the LCD is not going to work.  You'll get current bleed from the other connections and the LCD will do screwy things.  You need to switch the high side on the LCD.  You should use a P-channel MOSFET or a complimentary pair of MOSFETs for that (a complimentary pair reverses the logic so low is off and high is on).

Once you have a switch on the high side, you have to be careful not to leave any of the control and data pins in a high state when the LCD is shut down.  You'll get current bleed (within the LCD's logic chip) if any of the pins are in a high state.  Again, it will cause the LCD to do screwy things.  You can either ensure all MCU outputs to the LCD are low before you shut down the LCD or add 47k resistors in series with those data and control connections.

You need to switch the high side on the ADC voltage divider.  Otherwise, when the transistor is off, full battery voltage will be present on the MCU's analog input which will fry the chip.  You'll need a complimentary MOSFET pair.  It will isolate the MCU from battery voltage.  You can get cheap and small complimenatry pair MOSFETs on a single chip.  It's something commonly used.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 13, 2012, 06:06:16 PM
Sir you are an absolute wizard :)

Will have a dig through and see what parts are available - sounds like the complimentary pair is the only real way to go so might as well get it sorted :)

Just seeing if I can do any conversions into Eagle from the Express software and I'm just running through a script that might just work for the PCB itself so fingers crossed...

Update:  Yes I can convert the PCB files, but the clearances are too fine for the PCB fab - concentrate on the components and schematic for now I think although Eagle doesn't have half the parts I'll be using so need to build a custom library I think.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 13, 2012, 06:35:30 PM
I usually finish with the breadboarding before actually getting to a PCB design.  Chances are, things will change some amount after you have things breadboarded and working.  You can make little proto boards to breadboard your SMD components.  Looks like this;

http://s1232.photobucket.com/albums/ff380/chblock/?action=view&current=breadboard.jpg

BTW, I don't use any of the canned parts in EAGLE.  I build my own libraries.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 13, 2012, 06:46:28 PM
Does this look ok for a complimentary MOSFET?  Think it has the right specs but want to be 101% before ordering :)
PMDT290UCE (http://"http://www.nxp.com/documents/data_sheet/PMDT290UCE.pdf")
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 13, 2012, 07:16:43 PM
I couldn't get a link on that.

Here's the one I use in my latest mod;

http://www.fairchildsemi.com/pf/FD/FDG6332C.html

If it compares well to that one, it will work good.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 13, 2012, 07:33:54 PM
Even better, Farnell stock that one so have put a few on the order sheet.

Will dig out a few circuits to see how to configure them.  Definitely feel a change coming on though as space is my greatest enemy on this (well, and the lack of money lol) so thinking  of a main pcb for the mcu and major components, switches and lcd on another daughterboard and perhaps shift other stuff like the battery and atty connections/components on another.  I've not got a set size on the tube I'll be using yet to house it all but I want to make it nice to hold in the hand so probably a diameter of about  an inch would be perfect, but I'll probably take a trip to the local hardware store to check sizes/materials etc this week but won't buy anything until I'm happy it's ready to go.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 13, 2012, 07:50:13 PM
Hehe, space is always the enemy.  I've reduced the PCB area by a third for the mod I'm working on now, talk about cramming 10lbs of crap in a 5lb bag.  At one point I thought about stacking PCBs, but then decided it was just easier to place components on both sides.  That's something you normally want to avoid since it makes assembly more difficult, but it was best way I could think of.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 13, 2012, 08:17:29 PM
Have just read an article about liquid epoxy solder - apparently it's getting better now and losing more of it's resistance characteristics.
Still not sure of the best method to do the attaching/soldering as I've never worked with surface mount components before but if it's still available I remember a solder "paste" which was like flux and ground solder/tin which you painted on and then heated to about 220C and it formed a proper solder joint.  That was way back in the 80's though and all I can find now is flux being called solder paste.
Think my 12W super mini iron might not be up to the job though somehow :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 13, 2012, 08:59:39 PM
You have two ways to go with SMD as a hobbyist.  You can do your own reflow or you can solder by hand.  I solder by hand myself, but that's from decades of doing stuff with electronics way before surface mount and reflow soldering was invented.  I just haven't motivated on messing with reflow at all.

For hand soldering SMD components, you need a good variable temperature soldering station with a very fine tip.  I use a .015" tip.  You need very fine rosin core solder.  I use Kester 24-6337-0007 which is .015" in thickness.   You need 10x magnification minimum.  I use a stereo microscope, but you can use a jewelers headset or any other magnifier that works well for you.  You need a pair of very fine tweezers to handle the small parts.  I use a flux pen to lay down a layer on component pads.  It dries and gets gooey pretty quick so it does a good job of holding chips in place for soldering.

Once you have all the tools and equipment, you'll find hand soldering SMD not all that different from the old thru-hole stuff, just the scale is smaller.

Reflow is a bit of an art.  I haven't tried it so I can't say much about it except you need a good solder paste, a variable temperature hot plate or toaster oven, and a good temperature probe to get the heating and cooling profile right.  I've read of lots of people doing their own reflow and it comes out just as nice as the factory.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 14, 2012, 09:34:20 AM
Hmmm, tempted to see if I can get some solder paste and have a go at the re-flow method.  If I can get it right I might go crazy and fix my x-box too :)

Just mocked up some bits using a cardboard tube that some tin foil came with and some strip-board random pieces I've got lying around and I should, with an I/D of 1" be able to fit 3 boards, one main board with the logic controls on it, one upper board with the LCD and switches and a lower board to handle the high amps.  If I use pin and receptacle headers I should be able to assemble the three boards as one and slide it in the tube nice and easily and fill in any gaps there might be with an insulating sleeve.

Just thought of something else too - I was going to add some current measurement device too which will probably need to be on the high current board and the data sent up through a pin to the PIC.

Dave, what was the current sensing chip you used?  I can't remember or find the reference to it at the minute :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Breaktru on August 14, 2012, 10:01:24 AM
For 3.3v
ACS711/ (http://uk.rs-online.com/web/p/hall-effect-sensor-ics/7532062/)

For 5v
ACS712/ (http://uk.rs-online.com/web/p/hall-effect-sensor-ics/6807131/)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 14, 2012, 10:28:22 AM
Cheers Dave - have popped one on the order :)

Still trying to get my head around Eagle - not the easiest in the world I must admit!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Breaktru on August 14, 2012, 10:32:54 AM
Cheers Dave - have popped one on the order :)

Still trying to get my head around Eagle - not the easiest in the world I must admit!

I know it's a real pain. Craig turned me on to it. It takes a long time to make a PCB. Having to make your own library components. Express PCB is so fast in comparison but you're obligated to use their service if you intend to job out the board.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 14, 2012, 10:55:51 AM
Tempted to fudge it together in Express PCB to do a home made board first then get it all done properly in Eagle for a full version afterwards if I decide to job out the board and make more up.  Been on it half an hour now and I've almost got the PIC made into a device - gonna take a long time this one!

Edit:  What's Eagle's problem with connecting VDD to +5v and VSS to Gnd?  Keeps having a fit about it when I do the checks on the schematic????
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 14, 2012, 04:15:01 PM
Yes, it takes a while, but once you have things set up, it goes pretty quick.

Can't help you on EAGLE's schematic editor, I dont' use it.  I use another CAD program for my schematics and build my boards directly in EAGLE's board editor creating my net list on the fly (EAGLE can do that).  The main reason I use EAGLE is because the fab I use takes the raw board files and I happen to have a full professional copy I got for free.  Saves me exporting Gerbers which isn't a huge ordeal, but it's one less chore.  In any case, it's probably the most widely used program for hobbyists because it has a free version and can do everything that needs to be done.

I've used the ExpressPCB software before and it's pretty limited even for making your own PCBs.  You'll want to mirror your prints and IIRC, it can't do that.  You have to design everything mirrored which is really screwy.  EAGLE can mirror prints simply by selecting a printing option.  ExpressPCB has other limitations that are a problem for me even when using their fab service.  I used their service once some time ago, but have since found a couple cheaper sources.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 14, 2012, 04:17:24 PM
I'm working through it bit by bit - turns out if you connect a net that has a different label to the pin it will throw a warning up.

Kinda makes sense now but by god is it annoying lol
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 14, 2012, 04:35:35 PM
Yes it is.  EAGLE is highly structured like any PCB software suite.  However, things that are fairly intuitive for other programs tend to be convoluted in EAGLE.  More than once, it's made me want to throw my monitor through the window.  Though, it can do everything you need to do and once you get used to its quirks, it's not so bad once you get to know it.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 14, 2012, 04:44:02 PM
It's the lack of information that I found tough - I haven't found anywhere that tells you how to modify an existing part for your own library.  Finally figured it out by messing and copying pasting and managed to get the 16F1847 with all pins correct in a library.
Other than using nets and not wires for connecting the parts it's not too bad on the schematic side of things - just hope there's nothing just around the corner to beat me back again now I've said that :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 14, 2012, 04:49:26 PM
Hopefully.  I'd have to say the Library system is the weakest point for EAGLE.  They do not make it convenient to build your own parts.  It's like they assumed no one would ever want to use anything other than the pre-built models.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 14, 2012, 04:51:43 PM
I got that impression too - great if all you wanted to use were static items and nothing that has recently been released (like the 16F1847 at under 2 months).

Still, I'll keep at it and see how I get on.

Just been wondering about a diode for the battery too - just in case I have a brain fart moment at some point and reverse the polarity.  I'd guess a regular 10v would do the trick ok for that?
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 14, 2012, 05:08:33 PM
You want to avoid diodes in line with your power supply.  They are very lossy.  A standard diode has a 1V drop around 1A.  With an atomizer current tof 2A, that's a 2W loss!!!  That's huge considering atomizer consumption is around 10W.  That can be cut that in half with a good Schottky diode, but that's still 10% and higher.  The exception is when used as a rectifier in a switching regulator, but synchronous converters that use MOSFET rectifiers instead of diodes are much better.  They're becoming the rule more than the exception anymore.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Breaktru on August 14, 2012, 05:09:28 PM
If you Google around you can find the PIC library for Eagle that someone else has made. When I sometimes get lazy I search for libraries.
Be fore warned that they are from users and may not be perfect. That's when it's time to roll up your sleeves and get to making your own.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 14, 2012, 06:08:17 PM
I tried the PIC library Dave but the 16F1847 is so new it's not in any of the ones I downloaded.

Managed to get it in right though - just need to get making the schematic up and running with all the components in place now.  Had to make one for the vreg I've selected too as it wasn't around in any library I could see anywhere.

On a side note - here's my current order list ready to hit the buy button but want to be sure I've got all the parts ready as I'll be out of cash very soon and it's pay day tomorrow (yes I did mean that right) :(

Edit just read what you said about the loss from adding a diode - I wasn't considering that much of a loss.  I think I'll do without or come up with a better method for making sure reverse current isn't possible I think!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 15, 2012, 06:06:48 PM
OK, on the topic of reverse voltage protection how do these two quickly knocked up ideas look?

I'm erring more on the positive side one for ease of protection but just want to see if I've got the idea right really.  Still not sure whether it will be a good idea anyway without a mechanical off switch as the MOSFET will be drawing current at all times if I'm right but I suppose it depends on the characteristics of the MOSFET to how much of an impact that will have?

Also wondering on detecting a short or too low a resistance coil - I'm guessing I just look at a certain value from the current sensor to work that out but I can't seem to find an actual look up to tell me what current is what Vout from the ACS712 unless I'm being quite blind and the formula for working it out is in the datasheet somewhere??

Been looking at debouncing the switches too - still undecided if I should just write a little bit of code to hold a delay on the button input for say 30ms to get over the debounce or to try the hardware method.  However, I have ordered quite a few bits today, just need to get the main order from Farnell sorted now :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 15, 2012, 09:50:54 PM
You're on the right track, but I have to think about it to say exactly and I dont' have the energy right now.  You want to consider the MOSFET's body diode.  A MOSFET can only block current in one direction.  You'll want to set it up so the reverse polarity condition gets blocked by the MOSFET's body diode.  The MOSFET has to be off for reverse polarity and on for normal polarity.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 17, 2012, 04:41:12 AM
Been doing some more coding in the bit of spare time I've had over the past couple of days and now have a 5 click on/5 click off system working well for sending the thing to sleep and preventing false firing in a pocket etc.

Had a chat with a few guys who've used the display I'm using too and using the chip I am I can drive the power directly from the PIC's output pin without any issues at all.  I just need to pull the data lines low before switching off so there's no current leakage but other than that it's good to go!

So I suppose the only need for the complimentary pair will be the voltage divider so need to get that sorted out.  I'm assuming I drive the gate of the N-channel from the pic and have the g/s feeding 0v to the P-channel's gate which can switch the current through the voltage divider on the high side?  So basically we're using the n-channel as a logic inverter?

Right - hospital appt so better run :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 17, 2012, 07:22:37 AM
Here's what mine looks like;
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 17, 2012, 07:40:18 AM
Re. the LCD, you might be able power it with the PIC, but there's a couple issues.  For one, the LCD display itself is driven at higher voltage using a charge pump.  That means there is some amount of capacitive loading so there's some inrush current when the LCD starts up.  There's also the LCD backlight which typically draws a minimum of 10mA.  When the LCD starts up, it will easily surpass the sink limit for a PIC port pin, usually 25mA.  That could cause a brownout for the MCU processor core.  Powering the LCD with the PIC will also cause a slow ramp-up in voltage for the LCD which can be a problem.  It may work, it may give you trouble.  I suppose you can always try it and see.  If it works okay, it will save you some PCB real estate and some parts, but I wouldn't borrow the trouble myself.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 17, 2012, 08:27:39 AM
Excellent - I figured that was the way it would work.  Have got 10x FDG6332C on the way now so might as well use it for the LCD as well.

Once the last bit of the order turns up I'll have everything to hand and can start the prototyping.  I think I've got most bases covered though, and every pin on the PIC used too!
Hopefully I've got enough components from the order that arrived this morning to start mocking most of it up on the breadboard.
For ease of use I've got a selection of through hole components that pretty much match the SMD ones so I can prototype and move things around without having to build the breakout boards etc. so I should have a working prototype fully set up in no time all being well :)

Can't thank you enough for your help though - I knew I was rusty on a lot of things but didn't realise I was quite that bad lol
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 17, 2012, 02:28:58 PM
Welcome, best of luck with it.  It's definitely a worthwhile project.  May have a go at a PWM regulated mod myself some day.

I'm using a 28 pin PIC.  I have zero unused pins.  Lucked out on that or would have had to move to a 44 pin PIC consuming a lot more space.

BTW, have you seen the PBusardo review on the Gripper?  What a weird duck that is.  Based on what he shows in the review, it looks like it's boosted to 6.2V then PWM regulated for a range from 3 to 6V equivalent.  Man those Chinese engineers are whacked.  Anybody else would have just used series cells with PWM or a single cell with a variable booster, not both.

I have to give them credit though, it's a novel way to get around the limitations of a booster (can't go below input voltage), but it's really convoluted.  There's no reason to do that just to run a single cell.  It doesn't have USB charging.


http://www.youtube.com/watch?v=TCS1WbsjJOs
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 17, 2012, 02:53:56 PM
I love the start of that one - classic blooper material but left in :)

I did think maybe use a boost to upper voltage then regulate down with the PWM but like you pointed out the booster normally uses PWM then smoothed out to generate the boosted voltage then you're re-running PWM again so it's kinda like doing the same again, again :)

Just been trying to find a decent cheap usb pic programmer to replace the one I've got that now isn't being updated to support the new chips (kitsrus kit 149).  I've got a generic JDM programmer too which is fine, but none of my PC's have serial ports these days and the USB->Serial lead doesn't cut it.  My other one is the flashlab 77 that I use for prototype staging as I can do ICD with it but that needs a bootloader to work, which means I need another programmer to do the bootloader first.  Can you see the catch 22 I'm in here? lol

Might consider building a pickit2 clone if I can find the parts out or maybe a version of the usbpicprog.org programmer as that is quite a nice set up.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 17, 2012, 03:10:23 PM
I know lots of people build their own PIC programmers.  It's an interesting project in of itself.  In my case, I'm just using an old PICkit2 with an older chip it supports.  Until I use a newer chip, I'm not going to get another programmer.  When I do, it will be another PICkit or whatever else it's been superseded with.  They are cheap enough.  With what i spend on electronics and e-cig mods, spending $50 on a programmer/debugger is pretty much a non-issue in comparison.  Though, it's probably more expensive for you with international shipping and VAT.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 17, 2012, 03:14:46 PM
Just been looking at the PICkit2 clones and they seem to offer good compatibility with the latest firmware - in fact it seems it uses Microchip's own firmware by the looks of things!
Only problem I do have like you say is it's the slow boat from china for 3 weeks or another $40 on top for shipping over the atlantic.

I've got a PIC18F452 here that supports direct usb interfacing so maybe the info on usbpicprog.org might be worth a punt??
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 17, 2012, 03:21:22 PM
A lot of people use the bootloader.  There's one that comes with MPLab, but I haven't used it.  Though, like you said, it's a catch22.  You need the programmer to install the bootloader.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 17, 2012, 03:36:34 PM
I thought these were quite interesting too though...

http://simon.derr.free.fr/site/spip/spip.php?article11

http://electronicsadvices.blogspot.co.uk/2009/04/full-featured-pickit2-clone.html

And very much last...

http://www.embedinc.com/products/lprog/index.htm

As it's more of a buy from Microchip at a cost than a potential DIY jobber.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 17, 2012, 03:52:33 PM
That' really cool.  Looks pretty easy to make.

I don't think clones can hardware debug so that might be a consideration.  You can probably get by without the hardware debugging aspect, but the few times I've needed it, there would have been no other way to troubleshoot my problem. 

The problem with the PICkit2 is it's all but obsolete now.  If you want to use an older chip it supports, no problem, but if you want to use any of the newer chips, you need the newer programmer/debugger.

The latest inexpensive one is the PICkit3, but I think they may have killed the potential for cloning since the device has to download device specific firmware from Microchip for every differernt PIC you want to work with.   If you switch PICs, you have to reload firmware.   A lot of people thought that was really lame and complaned a lot.  Others don't seem to have a problem with it.  I think it was their way of dealing with how big the product line is getting.  To manage a monolithic version of firmware to support every chip would be too unruly.  Even the PICKit3 is starting to get some mileage on it now and I don't know what's coming down the line to replace it.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 17, 2012, 04:03:30 PM
I'm really thinking of the usbpicprog one - it's cheap, open source and very well respected.
It's pretty much future proof as far as the firmware goes as they also release the source code so for a geek like me it's perfect :D

Edit: bugger it - just ordered one so I can get going with it :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 17, 2012, 04:09:16 PM
That's the problem with building your own programmer, if you need it, it's because you need it now.  Sort of like making your own hammer to build a house.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 17, 2012, 04:19:41 PM
Yep - good analogy ;)

Still, only coming from The Netherlands so it should be here by midweek all being well.

Shame about the old K149 I've got though - when I bought it in 2002 it was cutting edge being serial AND USB together and it was being updated monthly with new MCU's but it seems they weren't making enough from it so it's pretty much completely dead and buried.

The JDM, well they just work - on a hardware serial port that is!

Great thing is I can do all the ICD stuff on pretty much any chip with the FlashLab board so I'll still develop on that then use the new programmer for the main burning/ICSP work.
Just don't tell the missus I've just spent another £20 :D
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 17, 2012, 06:46:51 PM
The newer PICs can optionally program via JTAG which allows a larger option for 3rd party programmers. 

I've had several programmers that have ended up just getting thrown away.  It's kind of racket with those I think.  You have to get a new one every few years.  I'm sure it's not on purpose, it's just the way things go as chips evolve.  There was a time not too long ago where you couldn't even get a programmer on the cheap.  It seems they've been around forever, but they haven't.  It wasn't until after EEPROM programmable MCUs came out around the mid 1990's that you could get one.  It certainly was a boon for hobbyists.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 17, 2012, 06:58:03 PM
I remember at college the programmer was locked away and only brought out for very special occasions when a chip needed burning and you had to make sure nobody turned on the lights in case it messed with the program before you could cover the EPROM window.

Thankfully things are now more abundant - and an awful lot easier for the hobbyists like you say.

Been mulling over whether I can use this old JDM board for the socket but link the ICSP port up to the new programmer when it arrives.  Not sure if it will work but if not I'll throw a quick one together on some strip board with the same links so I can program anything from an 8 pin up to a 40 pin MCU.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 18, 2012, 05:05:50 PM
Well today I mocked the entire circuit up on two breadboards and the flashlab (second breadboard just had the LCD on to keep it out of the way).

Managed to alter a bit of the code around and managed to get it working pretty much spot on.  I've not included the MOSFET pairs as I'm still waiting for those so I have just linked the voltage divider control pin to an LED so I can see that working and the LCD power pin to the LCD backlight on the one I've already got (16x2 but the proper one has no back light).

Everything seems to be working as expected.  Voltage  controls work well and with no real issues, same with the main trigger.  Sleep modes and power up/down works perfectly and I've included a feature that if you press the Vup and Vdown buttons together it settles at 3.5v which is the default at power up after dropping the batteries in.  Decided that if the display is off then the first press of either the up or down button will do nothing at all to the adjustment but just trigger the display to turn on, then after that the buttons work as normal.

Only had one strange occurrence where it went on a 50% cycle at about Hz for no reason at all after firing, it only lasted a few seconds but I've got an inkling that was due to the switches not seating 100% in the breadboard as after re-seating them it's not happened again.

So all in all - yes, I'm impressed - 4.2v on a vivi-nova is absolutely lovely with the 2.4ohm coil head!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 20, 2012, 08:17:25 PM
Just a quick one guys - does the ACS712 allow current to flow between pins IP- & IP+ at all times or only when the sensor is powered via VCC?

Just working on the schematic again and as I'm still waiting on components I wondered if Dave or Craig you know off the topof your head as I can't see any reference to it in the datasheet at all.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Breaktru on August 20, 2012, 08:38:39 PM
Just a quick one guys - does the ACS712 allow current to flow between pins IP- & IP+ at all times or only when the sensor is powered via VCC?

Just working on the schematic again and as I'm still waiting on components I wondered if Dave or Craig you know off the topof your head as I can't see any reference to it in the datasheet at all.

All the time
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 20, 2012, 08:45:47 PM
Cheers Dave. Should make my life a little easier then :)

Can't wait to get all the bits in and start testing for real - even with the parts I'm running now it makes for a great vape.  Now I've got to decide what I can fit where and get it down in size enough to fit into a tube.

I guess the Provari uses some seriously small smd components to fit everything into an only 0.9" diameter tube!  Not sure I'll manage that myself, but it won't hurt to try :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 21, 2012, 04:15:36 AM
Well another part of the order arrived today - and here's exactly how small that 8x2 LCD really is!

I think I might need to do a bit of wizardry with the wiring to get that fitted right - my first idea of through hole mounting pins really won't work :D
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 21, 2012, 06:04:28 AM
And here's the latest schematic with the parts split over 3 boards.  I've gone for a power control board that can be made nice and beefy to handle current, a middle board to house the MCU and associated parts and a top board that contains the LCD display and buttons.

Might move a few things around to perhaps reduce the 3 boards to 2 but I'll know that more once I've had a go at laying out the PCB's to see what sort of room I'm likely to have.  The ACS712T module is an all in one pre-set one I picked up cheap off eBay on it's own breakout board so that will be connected using the header pins directly to the bottom board.

If I can get it right I'm hoping to achieve a maximum height of the PCB of 19mm (¾" roughly) by 50mm wide (2" roughly) and about 13mm tall (½" roughly).  This should then mean I can get away with a sub 1" tube to mount it all in.

So I think that should just about complete the schematic unless there's something glaringly obvious I've set out wrong - always possible :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 21, 2012, 12:23:38 PM
Just before I dive in and try and do a layout of the power board PCB, I have a question for Craig really.

The N-Channel MOSFET's I've had delivered are SOT-23 and are rated at 5.4A constant load.  Only thing that's baffling me slighly is how the heck to get a 3.81mm (0.150") trace to the pins as it's so damn small?

Any pointers greatly appreciated :)

Failing that I might go back to the old faithful TO-252 as that's a much larger footprint to be working with!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 21, 2012, 02:36:50 PM
You'll get some additional resistance at the joint of the pin with a package that small.  Another consideration is that you'll want the MOSFET to be able to withstand the current pulse if a short occurs so you might want to use a bigger one anyway.  I use the SOIC-8 packages myself.  Atomizer shorts are not uncomon, usually a connector failure, but you'll want your mod to be able to deal with it when it happens.

When fitting small parts on larger traces, you can offset pads on the traces so they clear the space between the pins.  You can use a little copper fill to square off the end of the trace or use copper fills to run the heavy traces to begin with.   You'll want copper fill around those drain and source pins for heat sinking anyway.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 21, 2012, 06:04:10 PM
I think I'll go with the larger one - completely my fault as I was looking at the SOT-223 packaged ones then managed to click the order line for the SOT-23.

I've just finished the first draft of the PCB based on the schematic and I've dropped the fuse and polarity protection MOSFET - just for the sake of saving space.
So the bottom board is mostly very large traces with the main atomizer MOSFET, LDO and one of the MOSFET pairs along with the voltage divider.
Middle board is the MCU and the second of the MOSFET pairs to control the power to the LCD and the top is just the LCD, 3 switches and associated hardware.

Spent all day on it so kinda snow blind with it now so will go over it all piece by piece in the morning - hopefully it'll be right and I can get a print out done to see if it's play time :D
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 21, 2012, 10:04:01 PM
Just had a failure moment while trying to find a translucent cap to stick on the trigger button - it seems they're just not available for the 6mm x 6mm tact switches.
So I have the choice of sticking a normal LED in place or my new idea of side lighting the lcd and use those LED's as the trigger indicator and to flash the on/off/low batt shutdown sequences.  Not sure it will look ok though, suppose it's personal preference really.  I personally don't like plain LED's on a tube mod but like the illuminated switches like on the ego batteries.  The idea of flashing the screen came to me after trying to work out how to illuminate the screen  without drawing too much current or taking up loads of space.  Then I thought of a digital lcd watch and remembered the side illumination technique so will try wiring up the new screen tomorrow and do a few tests to see what will work best.
Just figured after remembering the old style backlight there's probably no need to duplicate the LED signal if it's bright  enoughand the screen and switches are all together so should look ok.

Any thoughts on whether a flashing screen would capture your attention enough to check it?
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 22, 2012, 04:56:20 PM
On mine, the screen is normally dark and only lights up when it needs to.  When there's a fault, it lights up to display the fault including a low battery, over-current, and atomizer short.  I've had lots of faults monkeying around with these rebuildable atomizers.

I ran into the same issue with my own mods.  You just don't notice the screen light up when holding it in your hand.  In my case, I added a tri-color LED above the trigger sensor in front to provide various indications.  It flashes red toward my line of sight to tell me to look at the screen.  That works out well with a box so I don't know how you'd do something similar with a tube.

You're out of pins on the MCU so that's going to be a problem to add any more indicators.  Maybe you can drive an indicator toward line of sight off the LCD power switch.  It will show you obvioulsy when the screen lights up. 
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 22, 2012, 05:05:23 PM
Exactly my thoughts too - need something that will grab your attention and an LED isn't a problem to drive off the LCD power line.
I've managed to condense a couple of outputs into one so I've got a free one I'm going to use purely for indication purposes which was going to be just for the LCD backlighting.

Maybe stick something around the actual 510 connector that will illuminate through a lens?  Plenty of options I suppose but if I start with the  LCD backlight then move on toward adding a little more then it should be relatively simple.

Now I've gone and jinxed it haven't I? :D
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 22, 2012, 05:15:20 PM
I use light pipes for my charging indicators.  Nothing fancy, just some clear acrylic 1/8" rod cut to size.  Works quite well.  You could possibly do something like that off the LCD backlight.  If it were me, I'd go ahead and use the extra pin for an indicator.  That way you can flash it.  Nothing better than a red flashing light to tell you when there's a fault.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 22, 2012, 05:32:21 PM
Well the backlight being at the top of the unit should make it nice and easy to add a lightpipe in place.  The other idea I had was to mount the connector in an acrylic tube (I've got the connector from an SD Keyring that fits perfectly in some acryilic tube I've got) so it would be a lovely ring of light if I use a nice high power led.

Plenty of options though.  Could even try using a voltage controlled LED and have different colours if I can get it right :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 22, 2012, 09:04:58 PM
Well I've just finished wiring up the tiny 8x2 display and it works lovely!
However I'm considering not using through wiring as it was a real ball ache to get it right as the pins are so close to the display itself so had to be very careful about heat transfer to the plastic.

Think I might go with tinned contacts and tinned pads on the board to almost smd it in place - there will be about half a mm gap but I think it should be possible by pushing a wire through the hole and heating that to form the link.   Clip it off and move on to the next one.  These 10 pins have caused me a little trouble but the result it fantastic :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 23, 2012, 07:28:06 PM
Just been messing with switching power on and off to the screen and I can see a few problems there with it not recovering fast enough to receive the data intact.
When you're running your display Craig, do you actually pull the power from it or just leave it on but with no activity being sent through to the display?
I've had this test rig running for 3 days now and I've still only used a third of the battery up - so I'm wondering if it might not be too much of an issue leaving it on?
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 24, 2012, 02:56:16 AM
You could leave it on I suppose.  It's up to you what you want your idle power consumption to be like.  In my case, it's minimized absolutely so the device does not require a power switch.  Also, I use a non-removable cell so idle power consumption is more of an issue.  My idle current draw is 7.5uA and drops to 250nA when battery voltage falls below 3.0 Volts.

I've run into problems like that with LCDs myself.  Normally, you should not have any issue cycling power on the LCD.  If you are, it's likely a timing problem.

Try adding a small delay before taking the LCD out of reset after power on.

Make sure all data and control lines are low prior to putting the LCD into reset and powering it down.  Make sure no data or control line is brought high until after LCD power on and taken out of reset.

Try increasing delays between initialization commands.

Verify you are not exceeding the LCD's data bus speed or switching from data to instruction to data too fast.  You can easily do that even with an MCU at 4 MHz.  I typically need to add delays for parallel buses.  For the serial ones, I usually need to run down the bus speed some amount and put delays between send commands in code.

Well, hope that helps.  LCDs can be tricky sometimes.  The vast majority of the the time, issues are just due to incorrect timing.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 24, 2012, 08:53:23 AM
Well I managed to stumble over a similar problem on one of the PIC forums and they fixed it by sending a clear to system bit BPF.1 which basically deep resets the LCD it seems.
So I do that once the LCD has been powered, wait for 10ms and then start sending data to the display.  All now seems to work fantastically.  I think, seeing as the power consumption on this LCD is so low (max 1ma), I'll probably only use the one MOSFET pair for the voltage divider.
That way it resembles my test bed how it is now with the LCD power being driven by a pin on the MCU.
Still doesn't give me any more pins to play with, but at least it's a little more room on the PCB to play with :)

Still find it funny that even though I've had the voltage divider powered up using the 2x 3k3 ohm resistors I'd got knocking about it's now into it's 4th day of the battery not needing charging - and that's with giving it some hammer at 4.2v last night too!

Here's a pic of the display hung off the breadboard.  Excuse the soldering, but I'm struggling with my hands atm so fine work is being a tad difficult (hence going for reflow for the main project!).
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Breaktru on August 24, 2012, 09:17:26 AM
Nice looking display  :rockin smiley:
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 24, 2012, 09:24:51 AM
Handy thing is, that battery display is wrong on that picture.  Only just noticed but doing the reset on the LCD wipes my custom characters so have just fixed that bit :)
The lines for the battery level should be vertical not horizontal, it's about right on the battery level though - it's hardly moving at all on these two 16340's!
As soon as the ACS712 turns up I can plug it in and show the ohms too - code's in place, just have the ADC input tied to ground to show unknown resistance for now :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 24, 2012, 03:53:32 PM
Well having stumbled upon this little image of the internals of a Provari.....

(http://img71.xooimage.com/files/3/1/a/provari---2-----4432-2edba40.jpg)

I thought it was quite a good idea using the positive input as a battery contact so have added that to the lower board.
I should be able to knock up a nice slab of metal to drop down after being soldered onto the PCB and work as a stable battery contact along the edge of the three boards.  Then I can use a similar sort of thing to push onto the interior of the tube to pick up the negative supply similar to the kick.

Here's the not very complete PCB layout anyway - have done it in ExpressPCB for ease as I'm messing around with layout etc and I've got the import into eagle pretty much sorted too.

I still have a bit of work to sort out the LCD connection as having routed the traces to the contact points I then realised I wanted the display the other way around!  Pretty simple job, just a bit of re-tracing required.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Topper on August 24, 2012, 04:08:22 PM
Amazing job till now  :rockin smiley:
I'm reading every one post of your guys and feel like in lesson "How to build perfect AVP"  :popcorn: ;cheers;

PS:When opening a Wish list
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 24, 2012, 04:20:55 PM
Well I wouldn't call myself an expert by any stretch of the imagination - it's been a couple of decades since I did any real electronics at Uni so I'm having to re-learn quite a bit as I go :)

Certainly though if I can get all this compacted down enough and farm the fabrication out I'd probably do similar to the Nivel chip and do short runs for people as once I get the reflow plate sorted I'll be cooking on gas, well electricity at least :)

I'm still looking at the cigar tube though and wondering if I can make this fit.  It's certainly short enough and at 19mm gives me about 1.5mm to spare width wise it's just whether I can work the stainless to make it all look ok as when I was trying to drill a hole to mark out the display outline I went through 3 drill bits without making so much as a scratch on the tube!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Topper on August 24, 2012, 04:37:51 PM
I'd made some homebrew VV with electronics from TI and KIS in tubes of flashlights  :wave:
So you have and end caps, springs and so on. You should make only the top cap with 510 treat (Craig have very slick by him own design and made in China)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 24, 2012, 05:05:19 PM
Craig is a Mod God - absolutely the person I aspire to when building this up.

If I can make this half as good as his I'll be over the moon :)

Tempting on the flashlight though - if I can get one that has the right dimensions at the right price I'd definitely take it.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Topper on August 24, 2012, 05:12:26 PM
Look @e-bay for 18650 flashlights and take some nice looking and cheap  8)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 24, 2012, 05:14:28 PM
I'm actually just browsing right now - just looking at some that might be ok, but need to get some listings with measurements to be sure :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Topper on August 24, 2012, 05:16:43 PM
dx.com also good source and free delivery
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 24, 2012, 05:29:19 PM
I'm thinking either a couple of these (http://"http://www.dealextreme.com/p/9-led-1-mode-white-flashlight-silver-3-x-aaa-131126") or perhaps a couple of these (http://"http://www.dealextreme.com/p/compact-9-leds-flashlight-2-packs-1099") might do the trick.  Just depends on what the shipping time is like from DX to the UK really.

Should be able to join the two together to get the right height and being aluminium bodied they should be easy enough to cut with the Dremel.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 24, 2012, 06:17:51 PM
Oh dear - I think I might just have found the perfect housing, as long as I can work out how to strip it all down that is!

http://www.dealextreme.com/p/g720-cree-q5-6800k-120lm-1-mode-white-led-flashlight-1-x-18650-110263?item=32
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 24, 2012, 06:55:13 PM
The enclosure (or tube) is always the hardest part for me.  I pay through the nose to have them fabbed out on an SLS machine.  Tubes are probably a lot easier, but I haven't done one.  Just boxes for me.  And thanks for the compliment, BTW.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 25, 2012, 08:04:06 AM
And I *think* that concludes the PCB designs.
Won't know 100% until the rest of the components arrive though and I can get it fully set up and tested on the breadboards but if the theory matches the practice this should be good to go as far as running across 3 boards goes!

Ended up ordering two of these (http://www.dealextreme.com/p/9-led-8000mcd-white-light-flashlight-with-dx-logo-black-3-aaa-47821) last night too - will see how they look when they arrive  :popcorn:

Anyway, here's the new PCB layout with single MOSFET pair driving the voltage divider and LCD panel the right way around so it's viewed with the atty to your left and the buttons to your right.

Still unsure whether to do something different with the main button, but will see what it looks like as I'm going to mock up the boards using some card and see how it looks and if there's anything else that needs moving around at all.

And here's a shot of the display with the correct battery level indicator this time :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Topper on August 25, 2012, 09:00:19 AM
Yes, I'v also ordered some of this flashlights, but I'm afraid that will be a little shorter for your design and 18650 batt. But maybe with 18500 or 16400... Anyway the best try will be at place to put your PCB in the flashes. And think about supporting saddle from some acrylic tube cut off in half (so outside dia of acrylic tube must be 18mm around)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 25, 2012, 09:46:27 AM
I've got some acrylic tube that will fit perfectly into an 18mm enclosure.  My plan is to house the PCB wedged between a lower portion and then use the upper portion as a light guide for the LED to illuminate the screen and also provide a visual indicator in the form of a ring around the atomizer connection.
The basic tests I've been doing should work fine as long as the LED is bright enough, but I'll have a few spare from the flashlights :)

I'm also running 16340 batteries as that's what I've got lying around, and the fact I got two free with a battery holder last week too kind of makes me want to stick with those ones.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Topper on August 25, 2012, 12:31:37 PM
So far so good :)
Keep going right way pal and we waiting for this amazing going mod!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 25, 2012, 12:39:38 PM
Can't wait to get all the components in now - have been vaping with it all day and it's fantastic although being tied to breadboards makes it a little tough to carry around :D

Using two high bright white leds illuminates the screen and gives enough light to illuminate the end cap too - tested using some cardboard tube with the acrylic poking out of the end.  Very effective, but not very pretty!  Has given the theory a good run and it works well in practice.  Now why is our postal service being so slow.... :(
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 26, 2012, 10:27:36 AM
Just having a quick think about the readings from the ACS712 current sensor.
I'll do a few tests when it arrives but I'm wondering about using it to detect a short circuit or an atomizer that's got too low a resistance.

What I'll need to do is output a low voltage of about 1V through the atty using the PWM driver (not a problem at all) then check the reading of the current sensor.  If my theory is right, if the VOut from the ACS712 goes above the norm for say 3A then trigger an error and don't allow for the full output of the trigger voltage.
I'm just wondering if Dave or Craig has done anything similar?  Certainly would prevent damage if there's a dead short as the lower voltage probably wouldn't even drive the coil at all.
I'm thinking I may have to send the sensing voltage out via an LPF to ensure it's not pushing battery voltage for however long it takes to sample the current, but I might get away with a short pulse that won't have much of an effect on the battery should a short occur.

So anyone got any views on that theory?
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 26, 2012, 05:28:56 PM
You probably don't need to do that.  You should be checking current while the atomizer is energized.  Ideally, you should sample current within a short delay (a hundred or two micro-seconds) after each PWM pulse is applied.  Just flag an error and shut down if the current signal is above a threshold.

To check for a short, you would need to use the ADC or a voltage detector to sample the rise time in output voltage, but it's somewhat redundant to current sensing.  If you're sensing current, you can tell if there's something wrong anyway.  It just depends on if you want to tell the difference between an over-current and short.

Another option would be to check resistance smilar to what you've mentioned, but the additional overhead makes it a more expensive, less efficient solution, especially considering you already have current sensing in place.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 26, 2012, 05:41:37 PM
It dawned on me if I use a 1V pulse I won't "in theory" get the right current reading back from the current sensor.  So it would mess up the resistance calculation for the screen.
So I tried it with a pulse of the selected voltage running long enough to sample a few times and get an average from the current sensor.  Basically anything below a set level of ohms and it throws an error and breaks out without firing the atomizer.

Also started measuring up for fitting things and have had to lengthen the PCB's a touch so I can get enough room to get it all in place without looking silly with the buttons all on top of each other.

Also had an idea about the reverse polarity protection - cut a small notch in the PCB where the positive pickup pin goes and mount the pin back just far enough so it connects to a positive tip nipple but not to a flat negative side.

Can't wait for the current sensor and MOSFET pairs to turn up now - want to get playing with it!!!

Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 26, 2012, 06:02:40 PM
One problem with that approach to output sensing is you can only detect a problem once prior to energizing the atomizer.  Once the atomizer is energized, you're no longer checking for a problem.  You may or may not have the time to sense resistance between pulses depending on your PWM frequency and duty cycle.  So, if an atomizer powers up okay, then shorts after the check, you won't detect it.  Circumstance can be a bitch :)

You shouldn't need to average readings for the purpose of detection (though you do for data display).  You should get a good reading from a single sample unless there's some design issue that prevents it.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 26, 2012, 06:42:29 PM
I've popped a marker in that re-checks every couple of seconds so hopefully should be enough to prevent anything nasty from occuring.

Also means it can keep an eye on the battery voltage too :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: synchro on August 27, 2012, 05:08:49 PM
One problem with that approach to output sensing is you can only detect a problem once prior to energizing the atomizer.  Once the atomizer is energized, you're no longer checking for a problem.  You may or may not have the time to sense resistance between pulses depending on your PWM frequency and duty cycle.  So, if an atomizer powers up okay, then shorts after the check, you won't detect it.  Circumstance can be a bitch :)

I know this design is space constrained, but if you're not already it would be a good idea to include resettable fuses.  Backup to what the software should detect but we all know how that goes sometimes. :D

I'm really interested in how this mod turns out, think its going to be fantastic. 
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 27, 2012, 05:17:47 PM
I'm going to see if I can get hold of an SMD fuse and stick it in on the bottom board.  Just wish I could buy stuff in lots of 5 or 10 instead of 100 like I'm having to at the minute!

Guess I'll have a few spare parts at this rate that's for sure :)

Just doing *another* re-design.  Trying to get it all together on two boards.  One lower board with the power control etc on it, and the other with the MCU, buttons and LCD.  It's tight but I think I might just be able to do it and it will save a lot of hassle trying to fit it all into a tube in the long run.
I'm finding I'm going to have to flip the upper board around so that the MCU and other components point down to the bottom board and the switches and LCD mount up above.
Really want to make the module around 19mm x 40mm if I can squeeze it all on.  Going to be a tough one though that's for sure!!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 27, 2012, 05:51:01 PM
Yes, you do end up with a lot of extra parts the way you have to order in batches.  I have a large dresser drawer full of extra parts from past projects.  On the plus side, you do sometimes need them for redesigns which happen more often that you'd like.  You're finding that out.  I've probably built at least 3 or 4 interations for every one that I've actually finalized.  Though, I'm really bad about changing stuff without regard for the cost.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 27, 2012, 06:20:06 PM
The problem I'm having is getting hold of 0805 10uF caps in numbers under 1000 units.
Don't know if it's a conspiracy but I'm sure the batches of 100 are disappearing as I click add to basket!

I'm going through the 'is this going to work' stage at tthe minute trying to condense it all down.  I'm sure it will but when you're trying to get rid of as many via's and links as possible and all that seems to happen is another one crops up it can be a bit soul destroying :(

Been laying out buttons too and I think the main trigger wil be better on the opposite face to the lcd.  Just makes packaging easier as it won't be on top of the voltage adjust buttons and it means I can use a larger button cap too.

Also means less footprint on the PCB which I'm all in favour of :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 27, 2012, 08:41:49 PM
Hehe, soul destroying.  I've run into that before.  I start thinking, "I'm trying to do the impossible here."

I can spend hours waffling on things.  I don't think there's any way around it.  There's usually more than one good way to do something.

Getting 10uF 0805 caps in small numbers is not a problem on this side.  I have a bag of a hundred sitting on the workbench next to me, think I paid 10 cents each for them.  Surprised you're having that much trouble in small quantities with such a common part.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 28, 2012, 03:26:09 AM
Just seems they're not too available over here at the minute.  Might be a rush on regulator caps for mod building :D

Just been mulling over the circuit too and was wondering - do I need two decoupling caps on the MCU or just one on the vdd side?

I added two as before I've used the chips with dual power inputs - a vdd and vss on both sides of the chip but having only a single vdd I'm wondering if I really need the extra on the vss side?  It would certainly mean it being easier to package if it weren't required that's for sure!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on August 28, 2012, 12:45:33 PM
You normally use a decoupler on each VDD - VSS pair.  They're most effective when close as possible to the two pins.  I'd say you could probably get away with using just one for both pairs, but you probably can not.  Your circuit is going to be very noisey switching those high currents to the atomizer.  It would likely play hell with the MCU without them.  You may even run into issues without a ground plane for the MCU.  Ideally it should be isolated from atomizer currents as well.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 28, 2012, 01:00:18 PM
I could get a ground tap directly from the battery negative no problems - that way only the atomizer and associated parts will be running from that ground plane.
I'm thinking using a copper contact or similar to the case housing for the negative tap.  I should be able to fit a liner in there for a wire directly from the bottom cap area into the MCU board then to keep the two separate.  Also means it's one less wire to connect between the boards which is always handy.
I'll try and fit a second cap in place between vss and vdd on the vss side of the chip.  The one on the vdd side is situated nice and close to the MCU.
So far though I've got it down to two boards at 45mm x 19mm each so it's looking promising!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 28, 2012, 01:32:40 PM
Quick screen grab - I've managed to squeeze it in and moved a few bits around slightly - it's tight but I think it should be solderable as the LED will be on fly leads to raise it up level with the LCD.

Still lots to do but it's getting there now.  SW1 is a fly lead off to the trigger switch itself with the return from the switch elsewhere on the board.  Should make packaging it easier at least - can be mounted in the lower housing then the boards slid into place above.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on August 29, 2012, 04:42:08 AM
Yay!  New programmer arrived this morning and so did the MOSFET pairs - just the ACS712 to arrive now, order a couple more bits and another lcd module (just for laying down and soldering through jumpers to the board - don't think this test one will survive a de-soldering session!) and I think I'll have all the parts in and ready to go :)

On a side note I found a great way around the ICSP stuff.  A block of FIMO with the shape of the MCU and pins pressed into it, baked to harden then drilled out for the ICSP pins and solid cores stuck through connecting to a header on the back.  Simply hold it down onto the chip and program away!  Works better than I expected - and made another one up out of a PCI socket - just happens to be the right pitch for the SOIC chips :)

Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on September 01, 2012, 10:15:09 AM
Well everything except for the ACS712 has arrived.  I've programmed up one of the DIP18 MCU's to build the whole lot up on the breadboard to make sure everything is definitely going to work ok but it looks promising for now.

Keep thinking about switching the positive supply to the atomizer instead of the negative.  I've got a few P-Channel MOSFETS but I don't know if they'll do the job or not as I'm feeling a bit slow today :P
Here's the datasheet to the one I've got anyway - http://tinyurl.com/c2t5s3a

I'm guessing I would just drive it as per the MOSFET pair but using the individual components to get the high current switching side done.

I'm not sure it would really give me any great advantage though as the connector will be isolated away from the main body of the mod so all the change would do is enable me to use a direct connection through the body for the negative to the connector.

Might leave it for now, but alter it in a future revision, which at my current rate might be done before the weekend's out :D

New PCB layout attached anyway.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on September 12, 2012, 01:06:20 PM
Just a quick update really.  Things have had to be changed around a little with the pin-outs due to limitations in the target MCU but it's not a big deal really.
To accommodate all the changes though it's taken quite a bit of re-coding so I've made the decision to re-do the whole lot of the code from the ground up utilising the new MCU's enhanced functions which should make things quite a bit more reliable too (hopefully ;) ).

So, in time honoured fashion the code currently is sitting flashing the back light on and off every second - the beginning of the LBL technology portion (little blinky lights) :D
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Breaktru on September 12, 2012, 01:32:26 PM
I'm glad that you are a proficient programmer and are able to over come obstacles like this  :applaude:
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on September 12, 2012, 01:42:12 PM
It's all about the logic with programming - me though, I tend to play it like pick-up-sticks - throw the code in the air and see where it lands :)

Seriously though, for what we need in a PV it's an easy job with very little complicated bits and even then they're just a simple interrupt to sort out (mostly time related things).
Here's a link to one of my other things that's on the boil at the minute - will eventually be a full blown game tied into the Zombie Fallout novels by Mark Tufo but in it's current guise you get to wander around the housing complex in the book dodging zombies that have full AI and reasoning built into their path finding and attack algorithms.  Now that took some real programming :D

http://host-a.net/u/lwindridge/ZombieFallout.exe

Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB on September 12, 2012, 05:07:09 PM
Yes, MCU programming is a lot different than computer programming.  I've done a little of that, but only what I learned in college.  With MCU's it's more about dealing with electronics rather than dealing with user input and output.  With MCUs you can actually program in assembly if you want to.  There's no way you can do that with a computer program.  Well, I suppose you could, but it would be quite a chore.  MCU programs are usually pretty small.  The one I'm running is in my mod is about 8kB.  You can't do much with a computer program that size.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: wwwest on September 12, 2012, 05:09:49 PM
My hats off to you programmers. Simply amazing  :beer-toast:
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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 :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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 :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Breaktru 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.

http://www.youtube.com/watch?v=zDH2xuXuiYk (http://www.youtube.com/watch?v=zDH2xuXuiYk)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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...
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: Breaktru on September 16, 2012, 06:45:01 PM
Cool, sounds like your getting closer to a finished product   :thumbsup:
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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....
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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?
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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 (http://uk.farnell.com/bourns/pwr263s-35-1002j/resistor-power-10k-0-05-35w/dp/2101656?in_merch=New%20Products) 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?
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB 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.



Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB 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. 
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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...
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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 :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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 :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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 :)
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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?
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB 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.


Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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 (http://gb.mouser.com/Search/ProductDetail.aspx?qs=XUn5UU0K/hfJri4z2rD6Tg==).

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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: CraigHB 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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.
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 on September 30, 2012, 05:56:34 PM
Have just ordered some samples of these (http://www.maximintegrated.com/datasheet/index.mvp/id/3597)

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!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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???
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: sterling101 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!
Title: Re: Beginnings of another MCU mod - but using PWM
Post by: audiophile_user 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 :)