Show Posts
Pages: [1] 2 3 ... 19
1  Development / Other Software Development / NetLoad bootloader, yet another tftp bootloader on: September 15, 2014, 11:32:37 am
I forked the ariadne bootloader on github and modified the code (mostly simplifications).
One change I made is the bootloader will work even if ethernet shield is not attached. The ariadne bootloader will hang if ethernet shield is not present. Also the time it waits after reset for program upload via usb serial is 1 second if ethernet shield is not present, and 5 seconds if ethernet shield (upload either via usb or tftp)  is present (it takes a couple seconds to initialize ethernet). The ariadne boot timeout is 20 seconds. I also fixed all error return messages so it now works.

I have tested this on Arduino Mega and UNO only. On Mega, my test sketch binary size is 92kb. It takes almost 4 minutes to upload with ariadne bootloader. I fixed this so it now takes only 5 seconds to upload.

The code is available here

2  Using Arduino / General Electronics / Re: cannot turn off fan using npn transistor on: September 04, 2014, 10:05:35 pm
ok, I see now the load needs to be grounded, due to the additional pwm and tach connections.  The 5v I am seeing is actually coming from the arduino pin and from the pullup of the input pin (tach pin). so that output pin is essentially powering the fan when the npn transistor is supposed to be off. so the standard npn switch will not work. I'll need something like this

hopefully this info may be helpful to others who may run into this.
3  Using Arduino / General Electronics / Re: cannot turn off fan using npn transistor on: September 04, 2014, 06:52:02 pm
ok, I see the problem is caused by connecting the arduino ground to the +12v power supply ground. If I disconnect the arduino gnd, then the  V CE goes to +12 when I disconnect the base.

The problem now is, the PWM and Tach signals are not properly grounded (they essentially float on the V CE saturation voltage level. And the result is arduino is not able to detect the level change of the tach signal.

perhaps this one needs a PNP circuit in order to have the proper ground connection.
4  Using Arduino / General Electronics / Re: cannot turn off fan using npn transistor on: September 04, 2014, 01:32:24 pm
I'll try on a different breadboard. maybe there is some loose connection. but then again, why the same result on the uln2803?

I used an oscilloscope to check the input and it goes +5 and 0 fine, and the base-emitter voltage  is less than 1v.
5  Using Arduino / General Electronics / Re: cannot turn off fan using npn transistor on: September 04, 2014, 01:19:43 pm
maybe. I can check that.

but as I said, I tested on ULN2803 and the result is exactly the same. I even tried using MOSFET and same result.

I have not tried disconnecting the pwm and tach to isolate the problem further, but I doubt it affects the V CE. The tach signal is open-collector from the fan, so it should be fine to pull it up to 5v instead of 12v.

I used the same circuit on another computer fan, rated 0.15 amp, and it turns off just fine. But when I measured the V CE, its the same 5v. But somehow, with this other fan, it stops spinning even if voltage across it is still 7v.

and yes, the connection is correct, otherwise the fan will not even turn on no? plus on ULN2803, there is no way to mix up collector and emitter.
6  Using Arduino / General Electronics / cannot turn off fan using npn transistor on: September 04, 2014, 12:50:50 pm
I am using a BC338 as a switch to turn a 12v computer fan on/off. The fan is rated 0.3 amp.

this is your typical npn switch circuit.

arduino to base resistor to transistor base, transistor emitter to gnd, transistor collector to fan ground, fan +v to 12v. diode across fan. There is also a resistor from base to gnd.

I tried 1k and 4.7k base resistor and got the same result. base to gnd resistor is 47k.
When fan is on, V CE is about 1v (less actually).
when I disconnect the base signal or switch arduino pin to low, V CE is about 5v, so fan is still getting 7v so it is still spinning.

I tried this on ULN2803 and result is the same.

Any ideas how  to make the V CE higher so the fan will turn off?

The fan is a 4 pin fan so I have connections to the PWM and Tach pins. PWM is connected to an arduino pwm pin, and tach pin is connected to an arduino input pin with pull up enabled. Not sure if this is affecting the transistor switch or not, but though I'd mention it.  The pwm and tach circuit works fine. I can control fan speed and get rpm value. Just that I can't completely switch the fan off.

7  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet client connect can return negative number on: August 22, 2014, 08:52:34 am
thanks. I just entered a new report.
8  Using Arduino / Networking, Protocols, and Devices / Ethernet client connect can return negative number on: August 22, 2014, 01:36:25 am
I spent a good half a day today trying to figure out why my ethernet client code suddenly does not work anymore.

It turns out if you are using "hostname" to connect, ethernet client will do a dns lookup, and if dns lookup fails, connect returns a negative value, which tests to TRUE if you do this code

if (client.connect("",80)) {
  //apparently connected, NOT if there was a dns error.

The correct code is to explicity test for 1

if (client.connect("",80)==1) {

I think someone should change the WebClient example that comes with Arduino Ethernet library and update the documentation as well.
9  Using Arduino / Programming Questions / Re: Incorrect calculation for micros() for CPUs running at 20 MHz, 24 MHz etc. on: November 14, 2013, 02:11:27 pm
sorry, but you are looking at this incorrectly.

start from 0, how many times do you increment to get to 255?
you say 256?
I say 255.
at 0, time is 0, after 255 increments, time is 1020 us.

If you really think it is 256, you need to have arduino correct their pwm frequency to 488 instead of saying it is 490.

I  can guarantee you without any doubt that I am right on this one.
and since this thread is about accuracy, I thought I should point out your mistake.
10  Using Arduino / Programming Questions / Re: Incorrect calculation for micros() for CPUs running at 20 MHz, 24 MHz etc. on: November 14, 2013, 01:47:36 pm
But aren't you still out by a small amount?

Running at 16 MHz, the interrupt service routine is called every...
(1/(16000000/(64*256)))*1000 = 1.024 ms

the above is not quite right.
16000000/64 = 250,000
1/250,000=4us per timer count.
but timer counts from 0 to 255 is only 255 increments, not 256, so the time is 1020us to be exact.
The overflow interrupt is called once every 510 count, not 512, since 0 and 255 only occurs once (check the datasheet)
hence one cycle is 2040us, or 490.19608 which is the PWM frequency (otherwise if it is really 2.048, arduino documentation should say the pwm frequency is 488hz).

It took me a while to figure out why I am getting 2.04ms cycle on the oscilloscope when I initially thought it should be 2.048.
11  Using Arduino / Programming Questions / Re: Arduino HTML timer on: November 14, 2013, 01:15:55 pm
I have an implementation that's similar to what you are looking for.

what I do is I run a javascript countdown on the html page, and periodically (like every 5 seconds I think, I can't remember),  the javascript will make a call back to the arduino to get the actual time in order to synchronize the local countdown.

I implement json service on the arduino to provide the countdown value, and it is an ajax call from the html file.

I initially tried to update the countdown in real time, but the network latency is very unpredictable, so I just do a local countdown and just synchronize.

this is a screenshot of the page doing the countdown
12  Using Arduino / Programming Questions / Re: Port manipulation Arduino Uno on: November 14, 2013, 12:28:32 pm
PORTD &= ~(_BV(PD4)|_BV(PD7));
instead of this
PORTD = PORTD & ~B00000000;// set pins 4&7 LOW
13  Using Arduino / Programming Questions / Re: creating an averaging function correctly on: November 12, 2013, 11:37:06 am
from performance point of view
average = ((9 * average) + newValue + 5) / 10;
the divider better be a multiple of 2  (even if average and newvalue are floats)
average = ((7 * average) + newValue + 5) / 8;

indeed better for integer values. However, if the value is a float, I think the method using sum and avg variable is more efficient, as it only involves one addition, one subtraction and one division.
14  Using Arduino / General Electronics / Re: Arduino monitoring Amp flow from a Car 12V Battery to some drvice on: November 11, 2013, 05:00:47 pm
I think there might be a confusion between amps and ampere-hour.
If all you want is to cut power at 10a, just replace the inverter fuse with a 10a fuse. (brings lots of 10a fuse)
15  Using Arduino / Programming Questions / Re: Anyone have a sketch to calculate the day of week based on the date? on: November 09, 2013, 04:21:35 pm
ok, I missed the part where OP said he cannot use time library.

I'd be more curious as to why and address that.

Just the same, the time library code is better, as Paul said, OP can adapt that. Just takes a little creativity. smiley-razz

At first I could not use Time library because I need to call time function now() from that ISR, so I modified the Time library with a few lines change so I have an interrupt friendly now() function. No need to reinvent the wheel.
Pages: [1] 2 3 ... 19