Maker Pro
Maker Pro

Where to start

flippineck

Sep 8, 2013
358
Joined
Sep 8, 2013
Messages
358
I have some limited prior experience programming in the following, with best ability in the first languages and worst as you go down the list..

php
perl
BASIC
javascript
C
1980's PLC ladder logic
Z80, 6502 assembly

Ability level going from slightly sub-moderate down to slightly above poor.

I've arrived at a need to build a control system which will monitor several sets of UK mains voltage and current flows, and operate relays in response to switch a load between a choice of different power sources, and control the appropriate starting and stopping of the different sources.

Thought about trying to do it all using discrete components but using a reprogrammable microcontroller seems a much more flexible way to do it.

At the same time I have a son due to start highschool soon, and I figured it might be a good chance to get up to speed so I can help him in a few years if he ends up faced with a microcontroller project.

So I guess I'm looking for a microcontroller family that's commonly used for teaching in UK secondary schools, and a specific up to date model of such a family that'll do what I need.

I'm imagining something I could program easily with the help of a Lubuntu 20.04 Linux PC, with readily available accessories like current, voltage sensor, comms etc modules

Which families of microcontroller and which specific models should I begin looking at, before I take the plunge and order something?

Arduino (which board?), Great Cow BASIC with a PIC chip?
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
Here's two issues: the programming part and the high voltage part.

As @Nanren888 indicated by his question: The high voltage part is the dangerous on. Depending on your level of experience with that I recommend you use complete sensor solutions for current and voltage that are sealed and deliver a safe low voltage signal for further processing. You'll need such sensors anyway as you cannot connect a microcontroller directly to mains. If your level of experience is good enough, you could build the sensors yourself. But safety really is an issue plus with a homebrew sensor you never know whether it's the sensor of your program when you start troubleshooting.

So assuming you have off the shelf sensors an safe low voltage output signals, there's a variety of choices for microcontrollers.
  • A popular one is the family of Arduino boards. Programmed in a C(++) based language, imho easy to learn. Assembler can be done, if you so wish.
  • More power can be had with one of the STM32 based boards. Also C(++) based or assembler.
  • Wireless connectivity comes easily with the use of ESP based boa)rds (ESP32, ESP8266). Also C(++) based or assembler. Also variant of Python called Micropython is available.
  • As far as I know the BBC Micro:bit is popular in Great Britain's educati)onal system. Programmed graphically or in Python.
  • A Raspberry Pi is way more advances than the ones I mentioned previously, comes with an operating system, can be connected to standard peripherals (USB mouse and keyboard, HDMI monitor), is easily programmed in Python..

There are many more options, I mentioned just a few that are imho rather popular. Don't expect anybody to tell you which platform to use. Each platform has its pros and cons. It boils down to your personal preferences and your willingness to adapt. For each of these (and other) platforms you will find loads of programming examples and tutorials to get you started and each platform has at least one (often more) forum where you can discuss issues.
Personally I have a bunch of pcbs with various types of microcontrollers lying around. Which one I use for a specific purpose I sometimes decide on a whim, sometimes by the features available (e.g. WIFI needed or not?).
So I guess I'm looking for a microcontroller family that's commonly used for teaching in UK secondary schools, and a specific up to date model of such a family that'll do what I need.
That would be the BBC Micro:bit
I'm imagining something I could program easily with the help of a Lubuntu 20.04 Linux PC, with readily available accessories like current, voltage sensor, comms etc modules
The type of sensors you're looking at are probably not easy to find for the Micro:bit - if at all.
Sensors for the Arduino platform can often be used (with maybe minor adaptations) on Raspberry Pis or ESP32 based boards. Programming of all these platforms is usually done with an IDE on a PC. Common are the Arduino IDE or Visual Studio Code, both as I understand are available on Windows and on Linux.
An exception are the Python based modules (e.g. ESp32 running Micropython or Raspberry Pi) which can be programmed directly on the REPL or by downloading a Python script.
 

flippineck

Sep 8, 2013
358
Joined
Sep 8, 2013
Messages
358
Had a short career as a domestic/industrial electrician many years ago, 5 years or so going from mate through to time served C&G qualified, wasn't a lifelong tour of duty but did give me some solid experience (including quite a few bangs!) and some appreciation of mains voltage issues.

I was on the point last night of ordering an Arduino Mega2560 R3 compatible board (next to nothing, I was surprised how cheap these are) to start playing around with, the main thing that puts me off is C. Last time I tried learning C, I couldn't get my head round 'pointers' and 'casts'.

I'll maybe look into BBC Micro:bit seperately to get me up to speed for when my lad encounters such things.

[edit] took the plunge, ordered an Arduino Mega2560 R3. If it turns out to be unsuitable, haven't lost much.
 
Last edited:

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
Had a short career as a domestic/industrial electrician many years ago, 5 years or so going from mate through to time served C&G qualified
I trust that not all has been forgotten and you'll know how to safely handle the high voltage part of your project ;).

Last time I tried learning C, I couldn't get my head round 'pointers' and 'casts'.
"C" (C++) is a high level language that is very near at the machine level. Therefore it is well suited to programming microcontrollers. This is not to say that other languages aren't suitable, too.
"C" may not be one of the most intuitive languages, I agree, but it generally leads to rather efficient code due it being structurally near the machine level (plus good compiler, of course).
"C" being close to the machine level has advantages and disadvantages. You'll find these when you use it or while studying the available literature.
You can go a long way without using pointers. Pointers aren't per se difficult to understand, but care has to be taken when using them as incorrect usage can easily cause havoc.
Casts are simply a way to tell the compiler how to interpret a datum when you have to convert from one type to another (e.g. from int_8 to int_16).

I was on the point last night of ordering an Arduino Mega2560 R3 compatible board (next to nothing, I was surprised how cheap these are)
Not much you can do wrong. You'll find plenty of examples and tutorials for the Arduino family. Also heaps of libraries for functionalities you may not even have dreamed of as yet.
 
Top