right now I'm using a Uno R3 to develop an enhanced lighting for my home office. It will consist of a control unit (which it is here about), and a power stage that will control the lighting itself.
The control unit will have its own PCB, to which a number of encoders and switches are attached, and a control command is send to power stage via I2C bus. Due to length of bus line, the physical layer is changed to CAN in between. Please refer to schematic below.
Of course, software is never perfect, and final integration may - oh, no, will(!) - require software modifications with ATmega328p installed on PCB.
--> So my question is what is - from your point of view - right solution to allow later software upload?
Some conditions / requirements
Installed Bootloader on final "product" is fine. Power-up time is not an issue because control unit will be always on.
It shall be possible to run the Arduino IDE, i.e. connect PC with "something" to the PCB. So, then I can run some tests for new software by serial monitor.
What I have understood so far is that SPI interface allows software upload without bootloader, however, it does not allow to run IDE, i.e. condition 2 is not fulfilled. Additonally - I'm not sure about - if SPI is used there shall be not other hardware attached to the pins. But since I need quite a lot of the GPIOs (in that sense the schematic isn't complete yet), I connected just normal open switches to MISO/MOSI pins.
With bootloader, communication would be done through USART (TxD, RxD). So, it looks to me that a device like this one Amazon: DSD TECH USB zu TTL Seriell Adapter should do the job. What I don't know if such a device allows to run the Arduino IDE ...
Here also a closer view to the adapter:
can I use the DSD-Tech-Adapter to upload software an run the Arduino IDE in the environment shown in the schematic? If not, do I need a different type of adapter, which one?
I assume the adapter is correctly connected, i.e RxD -> TxD and TXD -> RxD
I have just rough understanding about CTS pin, except that it is said to be tight to GND in my application. Correct that way?
SPI in the schematic is, so to say, a full provision - is it fine?
Do I need to add something to the schematic that it will work? (Of course, I use a breadboard, but I like to increase my confidence that I'm doing right).
Not correct, you can upload code via the SPI interface.
Correct
Add shift registers or I2C port expanders would solve that problem.
And DTR connected to the 328P reset line; look at te schematic of the Nano. You might want to consider https://www.pololu.com/product/3172. Far more flexible, supports both serial and SPI uploads.
I think that RTS needs to be connected to the reset line 328P.
Probably I haven't described it properly. So you say, that, Arduino IDE can be fully executed via SPI interface as well? I just like to double check because on Arduino UNO the USART is used....
Yes, but it is just that by making a "smart" assignment of function to GPIO there is the chance not to use I/O expander, and than this is prefered.
Nice piece! Thanks for the tip!
About RTS I'll have a look into the nana schematic ...
The Arduino Uno does not have 100nF from /RESET to GND, to be able to use it with the DTR signal and the bootloader.
Your RX input is floating. You could add 10k from RX to VCC. As soon as you call Serial.begin(), then a low at the RX pin can be seen as a startbit and the Serial input buffer will be filled.
You have exchanged RX and TX. Is that a mistake or are you trying to be funny
Arduino Uno: Pin 0 = PD0 = RX
The schematic does not show that the ATmega328P has multiple GND pin. You must connect all the GND pins to GND.
SW1 and SW2 don't have a pullup resistor ? The internal pullup resistor is weak. If there is a lot of noise, then I prefer 10k pullup resistors.
Code upload can be done via the boot loader or via ICSP (ISP). The latter is basically the same as burning the boot loader. There is an option in the IDE to upload using programmer.
This does require that you have some sort of programmer IN ADDITION TO the target board and the IDE. The IDE supports some, but not all, possible programmers.
umpf, so many views on that capacitor... So I triple-checked it, and, well, I'll remove it.
What do you mean by floating? On schematics of Arduino Uno or Nano they are never pulled up ... they just have a 1k resistor between RX<->TX and TX -> RX. But still floating in that sense that there are no external resistors.
No fun, mistake on my side.
Yes, symbol in KiCad is a little misleading. And it is about the ATmega328 in DIP-housing, which has just two GND, one of them is hidden in the symbol (Pin 22). So it is there, and connected (together with Pin 8).
According to data sheet for 328P internal resistor is in the range of 20..50k with typical value of 36k. With 50k current at 5V is 0.1mA ... on my breadboard I haven't used pull-up resistors for none of the four switches, working fine - I just ran a measurement with a scope attached. Nothing to worry about ... but thanks. Now I know the internal pull-up resistor in detail ...
What to say? The 1M is on the schematic on the UNO, but not on the Nano. So far I added to have the capability to add, I guess, I will not install.
"spam" the Serial Monitor of Arduino IDE connected via SPI and configuration of IDE as you have written?
What I struggle with is how does "Serial.println()" knows that the SPI shall be used and not USART? Programming (software download) is a data flow from Arduino IDE downwards to the processor, so a configuration of Arduino IDE will do the right thing. But "Serial.println()" is upwards to IDE - so I assume Serial.println gives a sh*t what the configuration of the IDE is, isn't it?
I don't know enough about the 1MΩ over the crystal. I think the official Uno board has a resonator ?
The RX of the Uno is connected to the usb-serial chip. If it is open (floating) and nothing is connected to it, then it can receive noise. I looked at the schematic of the Arduino Mini, and the RX is open. It is a problem that I ran into with my own barebone board.
We're only talking upload so you're correct, Serial.print doesn't give a ....
If you use e.g. Serial.print, it will use the USB (actually the UART of the main microcontroller like 328P that is connected to the ttl-to-usb converter) but it does not go through the boot loader.
The boot loader is not active when your sketch is running.
Hi,
I also had some trouble with uploads to a self made board with a 328P on it.
If you want to use the Arduino IDE for editing and debugging (with Serial.print() on the Serial Monitor) then you have to use the UART (RX, TX) in the controller and the controller needs to have the bootloader installed.
To burn the bootloader in a new controller you have to use the ISP interface. For this very first upload you need a programmer. I tried this with a USBasp without success because it works with a higher clock rate than the required <250 kHz. With an Arduino board and the ArduinoISP sketch I could burn the bootloader. Probably other programmers than USBasp can do this too. Be aware that the very first upload can be critical. After the very first upload the 328P runs with its external crystal/resonator at its full speed, and further uploads now are possible also with USBasp.
With the bootloader installed you can use the serial interface (RX, TX) via a USB to serial converter. The DTR output of the USB to serial converter has to be connected to the 328P reset pin via a 100nF capacitor. Now you can upload and test your sketches within the IDE.
An important item to add:
Every upload via ISP destroys the bootloader.
With the bootloader installed you can perform any number of uploads within the IDE - until the maximally allowed programming cycles of the chip.
... it looks as you have already done what I like to do soon! What kind of programmer do you use? The one I shared above does not have the DTR signal (just RTS, which is a different one), the one shared by sterretje has it (so still looking quite attractive) ... Despite, which is the one you use?
And I will delete the SPI interface freeing I/Os. As said, I like to use the Serial Monitor when my application is running in its real environment.