Arduino nano

Single to Multi propo
chlluk
Posts: 87
Joined: 19 Feb 2018, 15:38

Arduino nano

Post by chlluk »

Hi Phil
Do you still consider it necessary to load the script without the bootloader?
I have purchased an USBASP program adapter and will do the tutorial on you tube if its needed.
Clive
User avatar
Phil_G
Posts: 607
Joined: 15 Feb 2018, 23:32
Contact:

Re: Arduino nano

Post by Phil_G »

Hi Clive, yes if you're using any of my contributions, the delay it introduces causes problems.
Problem 1:
Whats the first thing you do on switching on an R/C set? you wiggle the sticks to check that the servos move.
Switch on, wiggle stick, bootloader times out as the stick is deflected, the encoder software starts up, sees a deflected stick and reverses the channel.
Problem 2:
With the bootloader enabled, the encoder doesnt start to produce PPM until the bootloader times out.
This time varies from one manufacturer to another, its typically 1-2 seconds, Digispark is 5 seconds!
So the encoder doesnt start doing its job until 1-5 seconds after the transmitter is switched on.
This is a Bad Thing™. Some sets notably Corona have stupid default timing in the abcense of a PPM stream. If a Corona or Jamara module is powered up without PPM, it defaults all channels to .5ms which is far enough outside the normal 1-2ms range to jam all the servos against their end-stop and strip their gears.

My own feeling is that a tranny that doesnt produce ppm immediately on power-up is well dodgy, hence the advice to dump the bootloader Image

Cheers
Phil
Guest

Re: Arduino nano

Post by Guest »

Thanks Phil
I will get on to that. As its such an important feature would it be possible to put together some kind of tutorial or provide a link to a trusted article on carrying this out for those doing there own builds. I will load a separate edition of the latest Arduino programming interface and make the modifications to the text files mentioned on YouTube. Haven't done this before so could be interesting.
Clive
Scott Todd
Posts: 66
Joined: 26 Mar 2018, 23:21

Re: Arduino nano

Post by Scott Todd »

I'm not very computer savy so this would be appreciated. I Googled the bootloader and could probably fumble my way thru it but didn't really find a good tutorial.

Thank you for the effort.

Scott
FBMinis
Posts: 55
Joined: 25 Feb 2018, 17:59

Re: Arduino nano

Post by FBMinis »

I used Arduino Uno as programer and Nano or Pro Mini as target, following this tutorial:

https://www.arduino.cc/en/Tutorial/ArduinoISP

I use the IDE to uplaod the "Arduino as ISP" sketch to the Uno; connect the Uno the Nano; open Phil's sketch, set the target as the Nano and the Programmer as "Arduino as ISP".
Last edited by FBMinis on 31 Mar 2018, 00:06, edited 2 times in total.
chlluk
Posts: 87
Joined: 19 Feb 2018, 15:38

Re: Arduino nano

Post by chlluk »

Thanks for the a Arduino link. I did read it through and I doesn't mention loading the sketch for the target board. I will try a combination of your instructions and the wiring from the tutorial. Many thanks for your help
Clive
User avatar
Flynn
Posts: 65
Joined: 17 Feb 2018, 14:48

Re: Arduino nano

Post by Flynn »

Apologies to Phil but maybe I can save him some time with a basic guide...

The bootloader that is supplied ready installed on any arduino based board that has a built in usb port is there to allow you to program the microprocessor directly from the USB connection. This firmware takes up some of the limited program space and also usually introduces a delay to the uP running its user-installed program. There are a couple of ways of achieving this function - by delay or by jumper. Because the uP needs to know if it should be executing its user-installed program or waiting to accept a new program it has to wait for a set time (can be up to 5 seconds) to see if it is being addressed on its 'data input' pins.. if it is it goes into 'accept data' mode, if it is not then it starts to execute its user-installed program.... hence the delay in starting to function. The other method used by some uP's involve moving a jumper on the uP board to inform the processor that you want to install new firmware, but the arduino boards generally don't use this method.

There is another way of installing new firmware... you can address the uP directly by squirting data into it on its In Circuit Serial Programming pins (ICSP = Sck(clock), MISO(master in slave out), MOSI(Master out slave in), RST(reset) + and - pins. If you search and print out the pinout diagrams (https://forum.arduino.cc/index.php?topic=147582.0) for the board you are using you should find the pins that are marked with these designations - on a nano they are -
sck - D13
MISO - D12
MOSI - D11
RST - RST
+ - 5v (or 3v3 if you have a 3v3 version)
- - GND

In order to program the Arduino in this way you are going to need a programmer because you cannot use the USB port. I guess the most common programmer you will find will be a USBASP (https://www.ebay.co.uk/sch/i.html?_from ... p&_sacat=0). These come with a 10 way ribbon cable but it will be easier if you also get the 10 to 6 way adapter... you will see these on ebay and they are marked with the mosi,miso,sck,Rst.gnd & vcc so you will know how to connect it to your arduino.

Next comes the tricky part.. at least if you are ysing windows...linux users don't need to bother with a driver as it is already built in to the kernel, but for windows users you are going to need a driver. download zadig (http://zadig.akeo.ie), then, with zadig open insert your new usbasp into a serial port, after the 'ding-dong' you should be able to select usbasp from the big window in zadig, then you need to ensure you have WinUSB(v6.1.7600.16385) in the window on the right. Once this is all ok you can press install driver. If this is successful you should find your USBasp under Universal Serial Bus devices....if it is anywhere else I don't think it will work... re-trace your steps..

Next you need to download your 'sketch' and fire up the Arduino IDE, open the sketch (file - open) , make sure that you have selected the correct board for the arduino board you are using (tools - board) and then make the six connections between your arduino and the programmer and then plug your usbasp into your computer usb port - the power led should light on the Arduino. To upload the firmware to the Arduino you DO NOT use the little right arrow in the IDE icon bar... this is for SERIAL upload via the USB port.. instead you have to select tools/programmer/usbasp and then sketch/upload using programmer....et voila!!

The firmware will be uploaded to the Arduino BUT it will most likely (thankfully) overwrite the existing bootloader as the bootloader resides within the program space - which means that once you have uploaded via a programmer in order to use the USB to program in the future you will have to re-install the bootloader..notice under tools you will see 'burn bootloader' clicking on this will re-install the default Arduino bootloader back onto your Arduino ( and screw up your program in the process)

ok.. so hopefully you now have your desired program installed on your Arduino and without the bootloader it should startup pretty quickly after power is applied.
You only ever need two tools....WD40 and duct tape.
If it doesn't move when it should use the WD40 and if it moves and it shouldn't use the tape.
User avatar
Phil_G
Posts: 607
Joined: 15 Feb 2018, 23:32
Contact:

Re: Arduino nano

Post by Phil_G »

Thanks Flynn, much appreciated, couple of additional points if I may Image
The bootloader takes up space regardless, we dont 'free' any space by 'overwriting' it.
The chip has two fuse bits which can be set (or not) to reverve blocks of memory for the bootloader, & another fuse says whether there is a bootloader or not/ Since we're not changing those fuses the bootloader memory area is still 'reserved' - an ideal target if you're short of memory Image

Mike_K wrote a brilliant paper explaining this aspect of the 328P, he goes into far more detail than the commonly available Atmel datasheet (I learned a lot from that, thanks Mike!)

>>you are going to need a programmer because you cannot use the USB port
to clarify, Flynn means you cant use the usb port on the arduino itself, your programmer of course will be usb connected to the PC. The Nano conveniently has a separate ICSP header where you'd plug in your programmer.

>>The bootloader that is supplied ready installed on any arduino based board that has a built in usb port
...and those without, eg Pro-Mini

Just chipping in some extra comments, its all good stuff thanks Flynn, its one of those things that is far harder to explain than to do...

Cheers
Phil
User avatar
Flynn
Posts: 65
Joined: 17 Feb 2018, 14:48

Re: Arduino nano

Post by Flynn »

Phil_G wrote: 30 Mar 2018, 23:13
The bootloader takes up space regardless, we dont 'free' any space by 'overwriting' it.
The chip has two fuse bits which can be set (or not) to reverve blocks of memory for the bootloader, & another fuse says whether there is a bootloader or not/ Since we're not changing those fuses the bootloader memory area is still 'reserved' - an ideal target if you're short of memory
Now I didn't know that - you learn something new every day :)
Phil_G wrote: 30 Mar 2018, 23:13
Mike_K wrote a brilliant paper explaining this aspect of the 328P, he goes into far more detail than the commonly available Atmel datasheet (I learned a lot from that, thanks Mike!)
Got a link Phil? I'd like to take a gander.
You only ever need two tools....WD40 and duct tape.
If it doesn't move when it should use the WD40 and if it moves and it shouldn't use the tape.
User avatar
Phil_G
Posts: 607
Joined: 15 Feb 2018, 23:32
Contact:

Re: Arduino nano

Post by Phil_G »

I'm sure Mike won't mind if I post his paper here.
Attachments
Arduino-Fuse-Setting.pdf
(1.06 MiB) Downloaded 316 times
Post Reply