SIGforum
Learning to program microcontrollers

This topic can be found at:
https://sigforum.com/eve/forums/a/tpc/f/320601935/m/1100047544

August 13, 2018, 07:54 PM
mark123
Learning to program microcontrollers
I'm looking to learn to program microcontrollers. I've been messing with them and got some working circuits with a microcontroller firing a relay but the more I read, the more I find I'm going about things the wrong way. I haven't programmed in about 8 years so I'm rusty but C seems simple (i was a C# guy before).

I also want to incorporate Bluetooth and MIDI into my design.

I tend to learn better with books rather than online articles and real-world examples work best for me rather than abstract analogies. Foo(bar) examples don't work for me very well and I don't like "it's like a car and your driving it home" because it's nothing like me driving a car. Analogies make things harder to understand for me.

I'm working with Microchip PICs and MPLAB X IDE but I'm not married to either.

Any suggestions for me? Books? Better IDE? Better microcontroller brand?
August 13, 2018, 07:57 PM
btgoanna
You may want to look at Arduino. They have some good stuff and a reasonable IDE.
There is a tinyduino that plugs into USB port on pc.



.
August 13, 2018, 08:05 PM
mark123
quote:
Originally posted by btgoanna:
You may want to look at Arduino. They have some good stuff and a reasonable IDE.
There is a tinyduino that plugs into USB port on pc.
I kind of have a thing against pre-built circuits and working from kits. I probably should pick one up though. They are popular for a reason, I'd imagine. I surely could learn to use the interrupts instead of a nest of IFs in the loop.

What did you mean by "reasonable"?

If I get something rolling on the arduino AT chip how will that translate if I want to go with the Microchip PIC.
August 13, 2018, 08:08 PM
Bytes
C is really simple, as long as you ALWAYS remember to de-allocate all allocations you make, you never try to access the -256 index of an array you created, you always remember to de-reference pointers, etc., etc., etc. C is a bitch if you're not really careful and you can really screw things up. C also lets your project morph easily due to to lack of objects and all of an objects goodness. Buffer overruns are easy as hell to create and they can be a major pain to find. Visual Studio community edition is free, really mature, and has c, c++ compilers if you choose to go with a language that is that low level. You can also write in assembler if you want to kick it down a notch lower.
August 13, 2018, 08:11 PM
btgoanna
quote:
Originally posted by mark123:
quote:
Originally posted by btgoanna:
You may want to look at Arduino. They have some good stuff and a reasonable IDE.
There is a tinyduino that plugs into USB port on pc.
I kind of have a thing against pre-built circuits and working from kits. I probably should pick one up though. They are popular for a reason, I'd imagine. I surely could learn to use the interrupts instead of a nest of IFs in the loop.

What did you mean by "reasonable"?


Well it isn't in the same league as visual studio , but it is free , and functional



.
August 13, 2018, 08:15 PM
mark123
quote:
Originally posted by Bytes:
C is really simple, as long as you ALWAYS remember to de-allocate all allocations you make, you never try to access the -256 index of an array you created, you always remember to de-reference pointers, etc., etc., etc. C is a bitch if you're not really careful and you can really screw things up. C also lets your project morph easily due to to lack of objects and all of an objects goodness. Buffer overruns are easy as hell to create and they can be a major pain to find. Visual Studio community edition is free, really mature, and has c, c++ compilers if you choose to go with a language that is that low level. You can also write in assembler if you want to kick it down a notch lower.
I own an older licensed copy of Visual Studio. I imagine the newer versions would work a bit smoother but I'd have to check if there are any restrictions on the use of the free version. Thanks.
August 13, 2018, 08:16 PM
vthoky
I'm trying like heck to learn Arduino, but C kicks my butt. Frown




God bless America.
August 13, 2018, 08:21 PM
mark123
My programs are going to be extremely simple. Tripping a relay or sending a MIDI control change while muting audio output for a few microseconds.
August 13, 2018, 08:22 PM
mark123
quote:
Originally posted by vthoky:
I'm trying like heck to learn Arduino, but C kicks my butt. Frown
The thing I'm having issues with is accessing and using the different bits of architecture in the microcontrollers.
August 13, 2018, 09:54 PM
grinder
There are options out there now other than C/C++ for microcontroller programming. One popular choice is Circuit Python. Not being a python guy myself, I have mostly stayed away from it but I have to admit that it does seem to make things really easy to learn.

As far as an IDE goes, the official Arduino IDE sucks. I use Visual Studio with the visual micro plugin (not free but there is a trial). You can also use visual studio code with the Arduino add on, or vs code with platform.io. There are a bunch of options to choose from.

I am working on a Bluetooth project at the moment and use the nrf52 development board from adafruit. I think there is circuit python support as well but cannot remember for certain. This gets you a pretty powerful microcontroller with integrated Bluetooth LE and has various avenues for MIDI control, including over BLE and serial.
August 14, 2018, 02:26 AM
Bytes
quote:
Originally posted by mark123:
quote:
Originally posted by Bytes:
C is really simple, as long as you ALWAYS remember to de-allocate all allocations you make, you never try to access the -256 index of an array you created, you always remember to de-reference pointers, etc., etc., etc. C is a bitch if you're not really careful and you can really screw things up. C also lets your project morph easily due to to lack of objects and all of an objects goodness. Buffer overruns are easy as hell to create and they can be a major pain to find. Visual Studio community edition is free, really mature, and has c, c++ compilers if you choose to go with a language that is that low level. You can also write in assembler if you want to kick it down a notch lower.
I own an older licensed copy of Visual Studio. I imagine the newer versions would work a bit smoother but I'd have to check if there are any restrictions on the use of the free version. Thanks.


Free version has no restrictions, it just doesn't some of the features the "full blown" version has. I also have one more licence on an "Architect" version of Visual Studio 2013 that you are more than welcome to. I moved on from the 2013 version.
August 15, 2018, 06:11 AM
mark123
quote:
Originally posted by Bytes:
Free version has no restrictions, it just doesn't some of the features the "full blown" version has. I also have one more licence on an "Architect" version of Visual Studio 2013 that you are more than welcome to. I moved on from the 2013 version.

Thanks! Any idea about using Visual Studio with PicKit3? I got it off of Amazon but I think it's a Chinese knock-off. It will not work with my Mac but does work with any of the Windows machines in the house.