How do I get above Arduino level? - Page 1
Forum section: electronics / beginners

author: rzeznicc
author_rank: Contributor
timestamp: March 04, 2017, 09:31:03 pm
content: GOAL: I want to make an electromechanical gizmo – one manipulates it resulting in information showing on a PC (Windows) screen.INFO:1. I have came up with a mechanism and designed it in mCAD.2. For the electronics part I have started with an Arduino UNO to get a functional works-like prototype and to learn programming (Arduino C) – a messy protoboard with wires and sensors plugged.3. Next step for me was to move to Teensy, because Arduino UNO works around USB HID. At this step I had to use custom designed sensor IC PCBs which I did in in EDA (just 2 layers). PCBs were made using OSHPARK and it was also a nice introduction to hand soldering.4. Right now I am working on using a bootloader sold from Teensy website (https://www.pjrc.com/store/ic_mkl02.html) and designing a custom microcontroller PCB for my I/O needs.5. I want to write a windows program displaying measurement data on screen (x,y curves most likely). My research led me to VisualStudio IDE with its extensive libraries for easy windows and menu creation. I have also seen that LabView can make an executable capable of this, but VisualStudio is free and LabView is not.QUESTIONS:1. What is the level (levels) of advancement above using a Teensy bootloader on a custom PCB? Lets say I wanted to sell a few of my creations and not be too ashamed of it. Is it then a feasible thing for a hobbyist to do? (how faster/cheaper will it be compared to learning/difficulty increase)2. If I want to up my microcontroller programming skills a notch, will moving from Arduino C (Wiring language) and Arduino IDE to just C and VisualStudio IDE help? How does it compare to, for example, AtmelStudio? Or is there a better way all togather?3. Having by then learned C for microcontroller purposes, how do I go around making a PC program? Which, C# or C++, will get me there better? I know, knowing a lot of programming languages is nice and all, but I just want a simple yet effective tool to do the job.THANK YOU very much for reading all of this and I look forward to all replies!

author: Rerouter
author_rank: Super Contributor
timestamp: March 04, 2017, 09:57:55 pm
content: For 1, At the end of the day, most of the common "arduino" boards are just an AVR microcontroller loaded with a bootloader, the arduino functions would be called "macros" in straight C or C++, just a block of code that you pass arguments to, and it passes back,As such, for popping your own micro on your own PCB, pull up that arduino's schematic, search for "X model Barebones" to find out how little you can get away with, and refer to the datsheet for that micro if something is unclear (being able to read from the datasheet of the micro would be the fastest way to step away from the arduino macros).If you meet those hardware requirements, then it looks more professional than a shield, and should work to the same performance,2. The fastest way i could recommend would be pull up the datasheet for the device you have, and try and write in the arduino IDE some of the basic examples without using any of the macro's, e.g. flashing an led on a pin without digital.write, or more challenging, reading from an ADC without using analog.read, and so on, if you can do the same just by setting the registers in the micro itself, you will have the foundation to stop using the macros they have built,After you have that foundation, and understand that without those macros things might be a bit harder initially, then i would say try to jump to another IDE, i cannot say which one is better,3. Hoping to hear that answered for myself, coming from a high school course on VB6 has made the transition pretty steep.

author: rstofer
author_rank: Super Contributor
timestamp: March 05, 2017, 01:49:02 am
content: It's pretty easy to use Visual Studio to write code for and program Arduinos:http://www.visualmicro.com/page/Arduino-Visual-Studio-Downloads.aspxC is C so it doesn't make a whole lot of difference which toolchain you use. The difference will be in library support and that's why the VisualMicro add-in uses the Arduino libraries. Just because you want to roll your own PCB doesn't mean you have to walk away from the Arduino libraries. Just make sure your end product either includes a compatible bootloader or, perhaps, some form of JTAG or OneWire programming. You'll have to look that up, I haven't done it. Maybe ICSP works. You might need an Atmel programmer or equivalent.Rewriting all the code that comes free in the libraries is a PITA. Why do it?In particular, I am not going to rewrite the TCP/IP stack for something like the mbed when it already exists and is known to work. Same with the USB stack.

author: brucehoult
author_rank: Super Contributor
timestamp: March 05, 2017, 06:44:45 am
content: I don't think there is anything wrong -- let alone "unprofessional" -- about continuing to use the Arduino libraries. They do a lot of hand-holding, but that's all to the good. They're pretty well designed.The only problem is that things such as digitalWrite do quite a bit of checking of various things, convert logical pin numbers to physical pin numbers, create bitmasks and so forth. That takes quite a bit of time, and limits the maximum frequency at which you can turn those pins on and off. In most applications that is not a problem.The other thing is that typical Arduino loop() functions run like crazy and use a lot of power. That's passable for mains-powered things, but not so good for battery powered. There are a number of web pages showing how to use the AVR's low power modes while still using the Arduino libraries. e.g.http://www.home-automation-community.com/arduino-low-power-how-to-run-atmega328p-for-a-year-on-coin-cell-battery/

author: kosine
author_rank: Regular Contributor
timestamp: March 05, 2017, 12:51:09 pm
content: "GOAL: I want to make an electromechanical gizmo... I just want a simple yet effective tool to do the job"Simplest solution would be to stick with the Arduino and its IDE, then do the PC side with Processing (https://processing.org/). The Arduino just becomes a data gathering front end and sends everything back to the PC over the USB. You "serialRead" the data with your stand-alone Processing .exe and graph the data as required. If you can use the Arduino IDE, Processing is essentially the same but with many more commands.To go beyond that prototype level, just switch the Arduino for an ATMega328 chip - or rip the one out of your Arduino once it's programmed.If you want to improve your programming skills with the Mega328 (or equivalent Teensy boards), learn to programme some of the registers directly. If you search inside the Arduino directory you'll find some files called "wiring_analog.c" and "wiring_digital.c". These contain the low-level code that you'd normally call through the Arduino IDE macro commands (like digitalWrite, analogRead, etc.) Once you understand what they're doing, you're essentially down to the hardware level. The ATMega328 datasheet has all the information you need about setting the registers:http://www.atmel.com/Images/Atmel-42735-8-bit-AVR-Microcontroller-ATmega328-328P_Datasheet.pdfIf you want to get really serious, you can also use the "asm( )" command to insert assembly code directly into your Arduino sketch. The datasheet includes all the commands in the instruction set section. The "Arduino" itself is a convenient prototyping board, but the Mega328 is really the heart (or brain!) of the system. Everything it's capable of doing can be accessed through the standard IDE. There's really no need to go searching for an alternative tool-chain.

author: rstofer
author_rank: Super Contributor
timestamp: March 05, 2017, 04:06:50 pm
content: Using a variant of the Arduino that incorporates a DIP package implies you can use the Arduino infrastructure to program the device and then install it on another PCB.https://www.sparkfun.com/products/11021

author: brucehoult
author_rank: Super Contributor
timestamp: March 05, 2017, 04:16:35 pm
content: Quote from: rstofer on March 05, 2017, 04:06:50 pmYup, for a few years now you've been able to choose between an Uno R3 with original socketed DIP package, or newer smaller better but not removable SMP.

author: rzeznicc
author_rank: Contributor
timestamp: March 05, 2017, 05:38:24 pm
content: Thank you ALL for the insightful replies!

author: rrinker
author_rank: Super Contributor
timestamp: March 06, 2017, 08:48:53 pm
content: Quote from: blueskull on March 04, 2017, 10:28:33 pmFYI VS 6.0, with VB6, runs fine on Win10. Should also work on Win 7. You can still download the whole thing, I recently installed it to work on a project that I didn't want to use a .NET version of VB for. The IDE opens fine, lets me build forms and attach code and run them.