Quick before MarkT sees, move R5 to the right of R4 !
Just in time too ![]()
The 150 ohm resistor is on the wrong side in the last post. The divider in your photo is not the divider inthe last post.
@OP,
Quite the list of credits...
TomGeorge:
Hi,
Okay literally a back of the envelope calculation, all for less than 0.01V.![]()
You forgot about “The Wrath of Khan MarkT” quotient ![]()
raschemmel:
The 150 ohm resistor is on the wrong side in the last post. The divider in your photo is not the divider inthe last post.@OP,
Quite the list of credits...
I was calculating for the previous circuit to that to show what the gate voltage would be == 4.99V as against the last circuit which would be 5V.
![]()
larryd:
Quick before MarkT sees, move R5 to the right of R4 !
larryd:
You forgot about “The Wrath ofKhanMarkT” quotient
Not sure whether it is MarkT but it is usually me!
It's just a point of engineering design. At 100k, I am not seriously going to claim it makes a difference, but people may for some reason or convenience use values which are closer. If the order is correct, it will not make a difference either way.
And it helps to be doing things for the right reasons. The resistor is not there to "pull down" the gate because there is a problem with the gate, but because before the microcontroller initialises, its output (because it starts as an input) is floating, so the microcontroller pin "owns" the problem and that is the specific place where it needs to be corrected.
Paul__B:
Not sure whether it is MarkT but it is usually me!
I stand corrected ![]()
Have a safe and heathy 2021 !
raschemmel:
It would still be safe if it was 1 F.
1F may be too much. There are at least two reasons to avoid excessively large decoupling caps:
- It slows down the voltage ramp when power is applied (or removed) increasing time in brown out condition. It may be problem for some devices.
- At first the cap looks like a short for the power source. If too large it may trigger protection devices or worse - blow something. 1 F cap charged to 5 V contains 12.5 J; to charge it from a constant voltage source the same amount of energy will be dissipated in the charging path. If concentrated to some weak spot it may burn.
- Cost and space considerations.
I know that @larryd and @aarg was told me to remove the capacitor on the gate and source before, now that I have a gate resistor, can I have (c11) as in this schematic? Otherwise the HZ does not show right. And if so, what uF?
maker-20_:
Otherwise the HZ does not show right.
Again: what does THIS mean?
Why do you need LED blinking so quickly?
maker-20_:
I know that @larryd and @aarg was told me to remove the capacitor on the gate and source before, now that I have a gate resistor, can I have (c11) as in this schematic?
No.
What makes you think that adding the necessary gate resistor(s) would have altered the way the circuit works?
maker-20_:
Otherwise the HZ does not show right.
Then you better explain - properly - what it is you mean by "not showing right". What is it you are actually doing/ measuring, what are you connecting and how?
Please redraw like TomGeorge.
Your design is difficult to understand. There is too much wires in all directions.
Use the + 5V and gnd symbols for power supplies.
In this way only useful connections will appear.
Thank.
Paul__B:
No.What makes you think that adding the necessary gate resistor(s) would have altered the way the circuit works?
Then you better explain - properly - what it is you mean by "not showing right". What is it you are actually doing/ measuring, what are you connecting and how?
I get the right HZ when connected as the last schematic without the c11, but when I put 108 LED paralell (around 1.85A)on it I get other HZ, if I put the c11 between I get the right results,
I am developing a device that will be used for medical research.
@68tjs
I agree! Sorry, Hope this is better.
So if I go without the c11 and put one led I get the HZ I want that I have programmed in my code, but if I put 108 LEDs (parallel 1.85A) I get wrong HZ. If I add the c11 I get the right ones, then the confusion kicks in...
How do you measure the "HZ"?
Smajdalf:
How do you measure the "HZ"?
Multimeeter have also used oscilloscope.
I think it is well past time to post your code using code tags.
In addition, you need to tell us what frequencies you need to generate and what you actually measure rather than just saying they’re wrong which just adds to the confusion over whatever it is that you’re trying to achieve.
#define PUSHED LOW
#define LEDon HIGH
#define LEDoff LOW
//***********************************************************************
//Switch connection
//+5V---[internal pullup resistor]---[input]---[switch]---GND(0V)
const byte startSwitch = 2;
const byte onIndicationLED = 7;
const byte LEDpin = 10; //[output pin]---[LED >|]---[220R]---GND/0V
byte frequencyCounter;
bool flashFlag = false;
uint8_t lastStartState;
//timing stuff
unsigned long xMillis;
uint32_t switchMillis;
const uint16_t
c_grBlinkPeriod[] =
{
16000u, //16000 x 62.5nS = 1mS --> 1kHz
5333u, //5333 x 62.5nS = 333.3125uS -->3000.19Hz
160u //160 x 62.5nS == 10uS --> 100kHz
};
const unsigned long xMinutes = 4 * 1000ul; //for testing use only 4 seconds
//***********************************************************************
void setup()
{
pinMode(onIndicationLED, OUTPUT);
pinMode(startSwitch, INPUT_PULLUP); //pushed/closed = LOW
lastStartState = digitalRead( startSwitch );
pinMode(LEDpin, OUTPUT);
digitalWrite( LEDpin, LEDoff );
//init WGM15 with prescaler of /1
//pin 10 is disconnected from timer
TCCR1A = _BV(WGM11) | _BV(WGM10);
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10);
OCR1A = 0;
OCR1B = 0;
} //END of setup()
//***********************************************************************
void loop()
{
//**************************
//check the switches every 50ms
//time to check our switches ?
if (millis() - switchMillis >= 50)
{
switchMillis = millis(); //restart timer
checkSwitches();
}//if
//**************************
//is flashing enabled ?
if (flashFlag == true)
{
//**************
//X minute timer
//has X minutes expired ?
if (millis() - xMillis >= xMinutes)
{
//restart the timer
xMillis = millis();
//next frequency
frequencyCounter++;
if( frequencyCounter > 2 )
{
//disable flashing
flashFlag = false;
//turn LED OFF
TCCR1A &= ~_BV(COM1B1);
digitalWrite(onIndicationLED, LEDoff);
}//if
else
{
TCCR1A &= ~_BV(COM1B1);
OCR1A = c_grBlinkPeriod[frequencyCounter];
OCR1B = c_grBlinkPeriod[frequencyCounter] >> 1;
TCCR1A |= _BV(COM1B1);
}//else
}//if
} //END of if (flashFlag == true)
} //END of loop()
void checkSwitches()
{
//**************************
//Start switch
uint8_t currentState = digitalRead(startSwitch);
//has the switch changed state ?
if (lastStartState != currentState)
{
//update to the new state
lastStartState = currentState;
//when we 'are not' flashing, was the switch just pushed/closed ?
if (flashFlag == false && currentState == PUSHED)
{
frequencyCounter = 0;
OCR1A = c_grBlinkPeriod[frequencyCounter];
OCR1B = c_grBlinkPeriod[frequencyCounter] >> 1;
TCCR1A |= _BV(COM1B1);
digitalWrite(onIndicationLED, LEDon);
//start the x timer
xMillis = millis();
//enable flashing
flashFlag = true;
}//if
else if (flashFlag == true && currentState == PUSHED)
{
//disable flashing
flashFlag = false;
//turn LED OFF
TCCR1A &= ~_BV(COM1B1);
digitalWrite(onIndicationLED, LEDoff);
}//else
}//if
}//checkSwitches
So I am getting the exact HZ if only powering a single LED, but if I go more LEDs it display other HZ that is wrong.




