AVR ATTiny25 microprocessor control mod

Status
Not open for further replies.

Akya2120

Ultra Member
ECF Veteran
Verified Member
Feb 20, 2011
1,720
1,309
Olympia, Washington
I have been digging through raidy's posts on the E-rauchen-forum.de, as well as PMed him. He linked me to one of his catch all threads for his mods. Very good work, I asked him what he recommends for a microprocessor control mod and he recommend the ATTiny25. After hours of reading through the forum(with google translator) I eventually came across his circuit design and programing for the module. Problem is, I'm not a programmer, and the translation is rough. Maybe someone who knows more about programming could figure it out. Maybe Raidy will help me translate it to english. Maybe we can just have german speaking microprocessors :D? When I get approval from raidy I will post circuit diagrams and his code. I would rather be on his good side :p

Anyone can do what I did and go to the e rauchen forum with google translate, sign up and read all about it. Google chrome made it easier because translate is built in. Really really cool mods. Way more detail even though it is a little hard to understand at times. I will post links if you want but you can't look at posts if you are not signed up.

If I can get everything in order and buy the pieces and parts I will probably still need help understanding the code and the circuit diagram. Fortunately the free version for writing the code will allow for the amount of info we need to run an atty. Raidy said it was limited to 4Kb. All help is appreciated! Tomorrow after I finish my responsibilities I will try to get a parts list in order. Hopefully I will have time as I am also trying to make a genesis and need to have my drawings in order for the machinist Wednesday.


It is getting early, time to rest.
 

AttyPops

Vaping Master
ECF Veteran
Jul 8, 2010
8,708
132,177
Hc Svnt Dracones - USA EST
IDK. I program PIC devices tho. If you are interested in using Microchip's MCUs.

IDK about AVR, but generally 4KB is a ton of space for an e-cig. You'll have more issues with the circuit design and device specs than you will with code space. There are some discussions about using MCUs. I've shot my mouth off a few times myself. Search "MCU". Not very compelling for the extra work involved.

What feature set are you looking for? What motivates you to use an MCU in the 1st place? Why select a German site that you can't read, and his schematics? FYI there's a ton of English AVR sites if you want to learn about them. And e-cigs aren't that mysterious, basically the MCU needs it's own stable power supply and can operate a MOSFET. Buttons, speakers, LEDs, pots, etc can be wired to them. Some have built in PWM and capacitive-touch circuits too. You have to decide on the feature set 1st.
 
Last edited:

AttyPops

Vaping Master
ECF Veteran
Jul 8, 2010
8,708
132,177
Hc Svnt Dracones - USA EST
Atty, he's looking to make his version of the ProVari/Darwin

OK. Sounds good. He should still do a requirements definition tho. He understands that he wants schematics for the hardware. The requirements/feature list is the "schematic" for the software....OK, not exactly, but it's part of it. Since he's using a programmable MCU, he should probably have both. I think he'll find that writing them down is a real beneficial exercise.

Just 2 cents.
 
Last edited:

Akya2120

Ultra Member
ECF Veteran
Verified Member
Feb 20, 2011
1,720
1,309
Olympia, Washington
I have both the code and the witing diagran. All translated by google. I will pm him again to confirm if he is ok with it. As I said last night I have some responsibilities to take care of but after that I will get a hardware list in order. The software raidy said was BASCOM I believe. I am kind of hoping to integrate the FSR as well but not sure if the circuit is setup that way. I'll do some more research later. This is my first time stting up a circuit. Seems pretty self explanitory. The coding seems a little harder but atty says it's not to hard. Thanks for the info!
 

AttyPops

Vaping Master
ECF Veteran
Jul 8, 2010
8,708
132,177
Hc Svnt Dracones - USA EST
I have both the code and the witing diagran. All translated by google. I will pm him again to confirm if he is ok with it. As I said last night I have some responsibilities to take care of but after that I will get a hardware list in order. The software raidy said was BASCOM I believe. I am kind of hoping to integrate the FSR as well but not sure if the circuit is setup that way. I'll do some more research later. This is my first time stting up a circuit. Seems pretty self explanitory. The coding seems a little harder but atty says it's not to hard. Thanks for the info!

Atty who? It's probably not too bad if you have coding experience...I was talking about e-cigs being simple, not necessarily coding MCUs.... But if you already have the code (with permission as you said).....go for it!

FSR... Force Sensing Resistor? What fer?
 
Last edited:

CraigHB

Ultra Member
ECF Veteran
Jul 31, 2010
1,249
314
Reno, Nevada
I use Microchip PIC µcontrollers. They offer a free development suite (MPLab) and they sell an inexpensive programmer/debugger (PICkit 2 and PICkit 3). You can write your code in C using a free student version of the C compiler they offer, but you can also use assembly which is native to MPLab. I tend to use assembly on the mods because it's pretty basic stuff. My current mod uses 2k of program memory so you don't need much. The coding isn't the hard part, it's the analog stuff that will give you trouble.

Oh, on the VV part, I use a digital pot that interfaces with the µcontroller via SPI. User input is handled with tactile switches.
 
Last edited:

CraigHB

Ultra Member
ECF Veteran
Jul 31, 2010
1,249
314
Reno, Nevada
I really like those PICs. Great documentation, well engineered. I use the PIC24 series a lot, nice 32-16 bit hardware divider. That comes in really handy especially since I like to code in assembly a lot. The PIC32 series are a bit unwieldy for most of the stuff I do (I've done a number of projects before I knew about vaping). I won't use the PIC18, 16, or 12 series for anything but the most simple tasks, don't like the 8 bit ones nearly as much.

Well, good to see another PIC user on the board. Hopefully we'll have the opportunity to talk more about PIC applications.
 

Akya2120

Ultra Member
ECF Veteran
Verified Member
Feb 20, 2011
1,720
1,309
Olympia, Washington
This is info written by raidy and translated by google. He is allowing me to do this but he wants it to remain private use only.

This is the circuit design for the attiny.
ATTiny25.jpg

Here is the program for an E pipe he made called pipe dream(that could be dream pipe because of the translation). It uses a touch switch and a FSR. It also charges from a rock he carved out and installed terminals into.

"So, after some optimization, the program is now less than 1k and can be used by you in the BASCOM-Demo. The time now but no more emergency stop there.
As always, it looks here very verissen.

'Stroke-fsr-finger.bas
'Raidy 05/23/2010
'V0-beta no release
'All rights reserved.

$ Regfile = "attiny25.dat" 'We have a soldered ATtiny25, the compiler must know
$ Crystal = 1000000 'runs at 1MHz, and requires only 400uA. But the entire circuit takes about 900uA.
'$ Frame size = 32' stack instructions that only reserved for larger programs
'$ Swstack = 32' are really necessary
'$ Hwstack = 32

'Jetzt gehts los

Config PORTB = Output 'principle, all ports are only a starting time
Pinb.3 config = Input 'is not only who is an input for the ADC3
Pinb.4 config = Input 'is not only who is an input for the ADC 2

'Configure and start the analog converter, which evaluates the fsr and Fingersesor ..
Config Adc = Single, Prescaler = Auto, Reference = AVCC

Declare Sub Fsr 'FSR control function
Declare Sub Fingers' finger control


As Word Dim Anprozent
As Word Dim Ausprozent
As Word Dim finger
As Word Dim Fingeraus
As Word Dim Maxan
As Word Dim Maxaus
Maxan = 99
Maxaus = 1
From Alias ​​0 'easier to understand.
An alias 1
Clock transistor Portb.1 alias "that is the clock output
Start Adc
'Main loop
Do 'the eternal loop
Finger = GetADC (2)
Anprozent = GetADC (3)
Waitms 200
If finger> 100 Then Gosub finger
If Anprozent> 200 Then
Reset Maxan = 10 'Memory to 10%, is still the same set again.
Gosub Fsr
End If
Loop 'End outer loop of the Eternal

Sub Fsr
Thu
'
Anprozent = GetADC (3)
If Anprozent <200 Then Exit Do 'no more pressure on sensor


Anprozent = Anprozent / 10
Ausprozent = 103 - Anprozent 'so now we know what we do
Clock transistor = On
Waitms Anprozent
If Anprozent> Maxan Then Maxan Anprozent = 'This is the memory, a row is enough for this feature.
Transistor clock = off
Waitms Ausprozent

Loop
Maxaus = 103 - Maxan
Return
End Sub

Sub finger

Thu

Finger = GetADC (2)
If finger <50 Then Exit Do 'finger is gone

Clock transistor = On
Waitms Maxan 'our memory value
Transistor clock = off
Waitms Maxaus

Loop
Return
End Sub
"


I believe this is the FSR he used
Force Sensitive Resistor 0.5" - SparkFun Electronics

"The steamer without buttons, without the pot and still be regulated.
This part right is called FSR (Force agreement we Resistor).
If you do not touch it, it has about 1M, 100gr in print only 10k. That is, the more you push, the more low-it will be. It is like a pot, which responds to pressure.

If we take now the diagram of the clock, throw out the pot, use this FSR and a resistor, and change the program a bit, then you have a steamer, which can only be switched on by pressure on the FSR and regulated in the steam power. The FSR is flat as 4 Papierund sheet is glued just outside of the steamer. rewrite treasures times as 2-3 hours for all inclusive program.

Or in simpler terms:
Top press - steam, more you push - more steam, little press - mild evaporate. This has something!"

This is his parts list

"IC_Fassung an 8-pole
an ATtiny25
a resistance 1Kohm
a resistance 120KOhm
Elko a 470-1000uF
A capacitor 100nF
a MOSFET IRL3102
a perforated board
some silver-plated wire switching
the pressure sensor FSR (8 €!) Is there at conrad."

I believe the IC Fassung 8 pin is a 8 pin IC breakout so you can program the processor.


He has many vary cool mods. I'd like to change this setup to a tactile switch rather than touch switch which shouldn't be hard.
 

CraigHB

Ultra Member
ECF Veteran
Jul 31, 2010
1,249
314
Reno, Nevada
Nice, very simple.

To use a tactile switch, just change R4 to a 10k resistor and replace the littley touchy symbol with a tactile switch.

What kind of software do you need to program the ATTiny? I assume is uses a JTAG interface so you can program it off a USB port with an inexpensive adapter. However, sometimes these controllers use proprietary programming protocols. For some, the software is expensive.

Oh, nevermind, just looked it up, it's an Amtel AVR chip. Inexpensive programmer/debuggers are available and Amtel's IDE can be downloaded for free. Actually, an economical one to use.
 
Last edited:

Akya2120

Ultra Member
ECF Veteran
Verified Member
Feb 20, 2011
1,720
1,309
Olympia, Washington
Resistors, capacitors, and pcbs I can find locally. I was having trouble finding the IRL3102 until I came across a company who has the lead free ones in stock, that also has a branch within 30 miles of my house. I don't know what silver plated wire switching is, any clues?

I think this is the ATTINY25 I want. Though I am not sure if I want the 20MHz, 16MHz, or 10MHz.
Digi-Key - ATTINY25-20SU-ND (Manufacturer - ATTINY25-20SU)
After some more reading, it seems they run it in low power mode at 1MHz so any should work?

I found the break out board on amazon.

Amazon.com: USB ISP Programmer for ATMEL AVR ATMega ATTiny 51 Board: Toys & Games

I found another thread about optimizing the code for the ATTiny. I don't really know the difference in the code other than what I can read from the change log but some people were impressed with it on the german forum. There were also version between raidy's and this. The one prior to this had a longer changelog which I guess got removed. There is also someone else who changed the diagram to work with a switch and a pot which might be nice. I prefer tube mods and I don't really know how I would put a FSR into a tube mod.
If anyone can help me figure out a couple of the parts google translate didn't put in english that would be awesome. Here's the code.

'Author: raidy
'Date: 05/07/2010
'Version: V1.2
'Functions:
'Clocking 1 -100%
'A maximum of 5 seconds at a steaming
'Protection period before switching
'200ms Schnellanheizung
'Status: raidy, tests ok
'Mod by menthol 3/1/2011 tested by cheerydeb, no status Version 1.3
'On and off over switch, 3 times within 1 1 / 2 seconds
'LED flashes at the evaporator
'LED flashes when the power box every 6 seconds (can be changed)

"That must be so dependent that wants to know the compiler dependent
'We have a ATTiny45 soldered, the compiler must know
$ Regfile = "attiny25.dat"
'Runs at 1MHz, and requires only 400uA
$ Crystal = 1000000
'Stack instructions only reserved for larger programs
$ Frame size = 32
'Are really necessary
$ Swstack = 32
$ Hwstack = 32

'Jetzt gehts los

'In principle, all ports are only a starting time
Config PORTB = output

'Just does not, which is an input for the ADC
Pinb.3 config = Input

'Also is a key input for the
Pinb.4 config = Input

'Saves us a pull-up resistor
Portb.4 = 1

'Configure and start the analog converter, which reads the potentiometer
Config Adc = Single, Prescaler = Auto, Reference = AVCC

'Variable for Schutzscheife. When you push too long, turns off the FET
As Byte Dim Maxloop
As Word Dim Anprozent
As Word Dim Ausprozent
Dim x As Integer
'This is our flag if we have turned
As Bit Dim Ist_an
Dim Count As Byte
As Byte Dim Countan
As Byte Dim Countaus
As Byte Dim Blinkan
As Byte Dim Maxan
00:00 From Alias
An alias 1
"That is the clock output
Clock transistor Alias ​​Portb.1
Switch alias Pinb.4

'Is not the first part in
Ist_an = 0
'NOTE: set this to the steam duration 100 are 10 seconds (100 * 100 ms)
Maxan = 70
Blinkan = 0
'The status LED

Led Alias ​​Portb.2


'First make

Reset LED

'The eternal external loop
Thu

Gosub Checkisan

If Ist_an = 1 Then
Incr Blinkan
'Here, the time can be set how often the status LED will blink
'The value of Blinkan time high set or down
If Blinkan> = 4 Then
Set Led
Waitms 200
Reset LED
Blinkan = 0
End If
If Button = 0 Then
Blinkan = 0
'Start ADC (analog-Digtal Converter)
Start Adc
Anprozent = GetADC (3)
stop 'ADC (analog-Digtal Converter), saves power
Stop Adc
'This is a round thing
If Anprozent> = 1000 Then Anprozent = 1000
'Thus, 1% -100% adjustable
If Anprozent = 0 Then Anprozent = 10
Anprozent = Anprozent / 10
'So now we know what we do
Ausprozent = 100 - Anprozent

'Basic heat here 200ms, but can be changed at will
Clock transistor = On
'From now evaporated
Waitms 200
'The timing loop steam
'Maximum MaxDampf * 100ms then emergency
While switch = 0
Set Led
Clock transistor = On
Waitms Anprozent
Transistor clock = off
Reset LED
Waitms Ausprozent
Incr Count
If Count = Maxan Then Exit While
Wend
Reset LED
If Count = Maxan Then
While switch = 0
Waitms 50
Wend
End If
End If
End If
Loop
'End outer loop of the Eternal

Checkisan:
Count = 0
Countan = 0
Countaus = 0
Thu
Incr Count
'Switch on?
If Button = 0 Then
Set Led
Incr Countan
'More than half a second?
If Countan = 13 Then
Countaus = 0
Exit Do
End If
End If
'Switch is released?
If Button = 1 Then
Reset LED
'Countaus only count if previously was at
If Countan> 0 Then Incr Countaus
If Countaus> = 3 Then
Ist_an = Not Ist_an
Exit Do
End If
Countan = 0
End If
Waitms 30
Loop Until count> = 50
Reset LED
Count = 0
Countan = 0
Return
 

CraigHB

Ultra Member
ECF Veteran
Jul 31, 2010
1,249
314
Reno, Nevada
Can't help you with the German translation, but don't cheap out and get just a programmer. I can pretty much guarantee you'll want a debugger at some point. Amtel sells the AVR Dragon for $50 and it does both debugging and programming. It's also available through online electronics outlets like Digikey. Spark Fun sells an AVR programmer/debugger made by Olimex. I've used Olimex programmer/debuggers and they've always worked well.

As far as µcontroller speed, it's not going to be an issue for you. You don't need a high speed controller for this application. Just use the the cheapest one. The higher speeds are only required for applications that require it like digital signal processing. It's not like a computer where faster is better. In fact, in some applications, you need to throttle down instruction execution speed.
 

Akya2120

Ultra Member
ECF Veteran
Verified Member
Feb 20, 2011
1,720
1,309
Olympia, Washington
Yeah raidy said to use the trial version of BASCOM not that I know what that is. I found a web page hosted by mcs electronics for BASCOM AVR. I believe this is what I am looking for to program it right? BASCOM-AVR - MCS Electronics

To change the FSR to a potentiometer would be pretty much just that right? Or is there something else I would have to do like put another resistor in before the pot?

I think the silver plated wire switching is for the touch switch. Funky translation.
 

Akya2120

Ultra Member
ECF Veteran
Verified Member
Feb 20, 2011
1,720
1,309
Olympia, Washington
This is my first experience with programming a circuit. Also the less money I spend on this the better, but if I have to buy something to get it running I will do it. How hard is writting code for something like this?

EDIT: The BASCOM application says it has a integrated stk200 and stk300 programmer. I don't know about a debugger but it says it has a simulator for testing.
 
Last edited:

CraigHB

Ultra Member
ECF Veteran
Jul 31, 2010
1,249
314
Reno, Nevada
Oh yea, that's a basic program, geez, basic, haven't used that since 1985, but the BASCOM software looks like it will do the job for you. Personally, I would stick with assembly and C/C++ using the AVR IDE. That stuff is industry standard. Though, if basic does the job and you like it, then great, use it. Just make sure your programmer is compatible with the software.

Programming µcontrollers is actually pretty easy and fun too, not like general purpose computing where it can get unwieldy pretty fast. Since you're only doing simple tasks most of the time, programming is pretty simple most of the time. Though µcontroller programming can get involved, especially when you're working with things like TFT displays which are graphic and require lots of driver code. I've written a few drivers and they're usually long and tedious to compose. I just recently wrote a real simple one for the two digit LED display I use in my current mod. Next mod is going to have a chip-on-glass text mode display though. That's going to be a bit more complicated.

If you are on a tight budget and can only afford only a programmer, then so be it. That BASCOM software page does not indicate it supports hardware debugging so it wouldn't matter anyway. Personally, my debugger has saved me from hours of frustration many times. However, you need software that supports it. The BASCOM software does have a simulator and that's the next best thing. You can use it to eliminate the vast majority of your code issues. I use a simulator to debug my code most of the time as well, but sometimes there's no substitute for a debugger. That's like the big hammer in your toolbox.

In any case, if you are serious about doing this stuff, you probably want to do some reading/tutorials. Not hard to find resources on the net, especially for AVR stuff. It probably rates right up there with the PIC stuff for availability.
 

Jensb

Senior Member
ECF Veteran
Jul 17, 2010
193
14
42
Stockholm/Sweden
Hi Guys.
i also use attiny25 in my mods and there are many great developers on the german forum.
in my last mod that "ichbines" created i´m finally finished with modding and dont want any other mod.
Simple and easy mod with a printed circuit.
He wrote a code with a real PWM and some other nice features.
The led is flashing in the speed (voltage) that you use and for changing i just have to hold on plus or minus sensor to change it.

Awesome mod :)

 
Status
Not open for further replies.

Users who are viewing this thread