I read on the attiny's datasheet that it has inverting outputs to drive stepper motors, I basically need the same thing, To create an inverting output in 2 pins, a square wave to feed into a voltage doubler. The voltage doubler is going to drive a slow switching, like really slow, once every few hours slow MosFET's gate. I would have loved to use a logic level mosfet, but i cant find them at all.
I cant find any simple enough document online that can help me learn how to adress these in an attiny.
One more thing, the attiny also needs to constantly and reliably monitor analog voltage input. So i need a single spare analog input.
This project has only 5V source available for many reasons, i wont bore you with the details.
another thing,
In my case, I basically want to take an analog input ( constantly ) and run a pair of inverting outputs. As i still dont know what frequency i should run the voltage doubler (A two-stage Cockcroft–Walton multiplier) at, Does the frequency i set (9.6/4.8/1.2 Mhz) affect the former option? the analog input?
I would have loved to use a logic level mosfet, but i cant find them at all.
im pretty sure we live in different countries, Im looking at this as a last resort, If i cant continue to find one. I would need to ship that.95 dollar item through about 8000 Miles. I have already tried all local online retailers.
jremington:
It is not clear from your post what you are asking.
The frequency used to drive a Cockroft-Walton voltage doubler is not critical.
Im new to this and still doing my studies on this.
The basic thing i asked is,
How would i Program an attiny 13 with such frequency ( higher frequency = higher current ) on one pin that it can directly feed a voltage doubler to drive a very slow switching 10V mosfet gate.
also while not interrupting an analog input.
I would love to get a store bought one, But i cant find them in my country. Not.a.single.one
kaseftamjid:
im pretty sure we live in different countries, Im looking at this as a last resort, If i cant continue to find one. I would need to ship that.95 dollar item through about 8000 Miles. I have already tried all local online retailers.
So its not possible? the thing i asked?
turns out my local retailer never even heard of logic level mosfets, let alone IRL***, voltage doubler is going to be a joke. More intrestingly, none of the hundreds of website i can order from neither list a logic level mosfet or a voltage doubler.. which is why i have to go through the pain of making one myself, but this seems to be fun learning.
okay, so i finally put together a code largely based on the blink without delay example.
const int MosFETPin = 1;
int MosFETState = LOW;
unsigned long previousMicros = 0;
unsigned long interval = 50; // t=1/F , so 1/2 of T , 10 kHz
const int voltageRead = A2;
void setup() {
pinMode(MosFETPin, OUTPUT);
pinMode(voltageRead, INPUT);
}
void loop() {
if(analogRead(A2) >= 205)// 1023(10bit ADC)/system Voltage = Adc value/analog voltage measured|| due to a voltage divider needed, 205 refers to 1 V, which in series refers to 3V
{ unsigned long currentMicros = micros();
if (currentMicros - previousMicros > interval)
{
previousMicros = currentMicros;
if (MosFETState == LOW)
MosFETState = HIGH;
else
MosFETState = LOW;
digitalWrite(MosFETPin, MosFETState);
}
}
else{digitalWrite(MosFETPin, LOW);}
}
does this seem okay? one more thing i am worried about, is that the powerbank circuit thats going to power the attiny, has a safety chip onboard that switches the ground of the battery through a mosfet for Overcurrent/overvoltage protection. So the grounds are not sharing per se(no continuity ), but theres only one source in the circuit so only one ground. And avr's need ground to be ground!! So would the attiny still be able to read a near correct voltage? of the batteries?
God damn it i need some sleep.
this is getting more irritating by the moment. Some sources are pointing out that regular square pwm (0 to 5V and then again 5V to 0) can drive a voltage regulator, while other sources are referring it needs ac voltage (5V then 5V to -5V and then 5V and so on). For a thing that lives and breathes on frequency i cant find a single piece of clear info that can point me why and which frequency i need. The datasheet you generously provided shows that they use 38kHz, why? where did they figure that out? someone please help.
As i was looking into using LiPo batteries recently i was confronted with something similar, (i wanted to use a single 3.7v Lipo to drive a WS2812, which runs at 5v) I looked at simple voltage doubler circuits and found a ne555 based circuit that i got to work quite easily, and without the use of driving frequency, though highly inefficient, and not quite doubling, but i suppose you could cascade 2 of these to reach you required voltage. The other thing that i wonder about is that if there is 12v available (which there is in your schematic) why don't you just simply drive the mosfet from there and use an opto-coupler as a switch ?
For my application i will probably use a max660 which is easily available at AliExcpress, and very efficient.
Deva_Rishi:
As i was looking into using LiPo batteries recently i was confronted with something similar, (i wanted to use a single 3.7v Lipo to drive a WS2812, which runs at 5v) I looked at simple voltage doubler circuits and found a ne555 based circuit that i got to work quite easily, and without the use of driving frequency, though highly inefficient, and not quite doubling, but i suppose you could cascade 2 of these to reach you required voltage. The other thing that i wonder about is that if there is 12v available (which there is in your schematic) why don't you just simply drive the mosfet from there and use an opto-coupler as a switch ?
For my application i will probably use a max660 which is easily available at AliExcpress, and very efficient.
Although i do have 555 ics in hand but i would love to use the attiny to do this, just stacking ics is wasteful in my opinion.. the attiny should be plenty capable. But the weird 9.6Mhz frequency has me worried that the time units are not equal.
smarts-jb:
Tone itself doesn't block, afair from testing with it some time ago. The blocking problem with tone comes in when you do a delay() between one freq and the next.
If you do this for example:
tone(tonePin, 500, 1000);
tone(tonePin, 2000, 1000);
... it immediately plays the second tone, since in fact it [u]doesn[/u]'t block for the first 1000ms to wait until that duration expires.
So then the temptation is to do this:
... so that the sketch delays for at least as long as the first tone's duration.
At which point it's simple to just use blink without delay() style thinking.
just stacking ics is wasteful in my opinion.. the attiny should be plenty capable
an ATtiny is a microprocessor. ne555's are just timer chips. 2 ne555's are cheaper than a single ATtiny13 (about half price for me) The whole insisting on a mosfet seems a tad wasteful to me, since you can probably manage with a Power Transistor that will open when 5v are applied, and you wouldn't need the voltage doubler. Otherwise get a max660. If you are just going to use an Attiny to create a squarewave of a certain frequency i'd say that is anyway rather wasteful leaving sooooo much of it's capabilities unused.