Home Berytech Fab Lab Fab Academy

Embedded Programming

When it comes to comparing the performance and development workflow of the different approaches one can take to program a PCB, there are a lot of factors that should be taken into consideration. I cannot say for all but as for the ones I used here is my assessment and comparison:

Arduino-Code

When it comes to programming, especially someone new to this, Arduino is the most straight forward approach to program a PCB, the fact that it could be considered as a 'joker' as in you can use it as an ISP.

The code that is written for the arduino is also basic as it encapsulates C-code in more userfriendly functions and terms that make it easier and more efficient to execute any desired code.

The backdraw of using the Arduino code is that since it is considered user friendly, is that it really is the most 'on the surface' code someone can use. Although it is true that it is a great way to start and one can achieve many milestones with it, more complex processes might require other codes.

C-Code

C-code is the most basic coding language, it can be applied and implemented to most of micro-processors. It is not as simple as Arduino-code but at the same time it is somewhat logical. without the Arduino IDE, C-code could be uploaded to an ISP and processor through the terminal on Lynux with the steps shown above.

C-code is pretty straight forward and closer to the 'end product' which is the binary code. as in when you want to specify a pin, instead of saying ex: PIN 11. You need to first specify the PORT as in A or B and it goes on depending on the microprocessor capacity and size. Then each PORT is comprized of 8 pins starting from 0 all the way to 7. And then each pin's function is specified as input or output, 0 or 1. so if you want to use Pin 2 as an output and the rest are inputs, you would have to set is as PORTA = 0b00100000. Then you go again and set each pin when you want to use it. It is somewhat confusing because you are using the same letters for different functions with different uses.

Even though I am not use C-code for my future projects, it was important to get to know the basics of C and the uses of it. I think it is crucial to understand C to set the basis for other coding languages.

Python-Code

Based on my experience, I only used the Python-code on Raspberry Pi 3, and on the Rasperian Operating system to be specific. It is my first experience with this and it is just great. The fact that I am 'inside' the microprocessor, having a very user friendly and efficient operation system as in only have the most basic functions that one might use, it is amazing. I am sure more experienced users would find a lot of downsides for it but so far I like it and it really was, in my humble opinion, the most efficient.

I like to take it as biomimicry as in the processor is the brain and all connected circuits are extensions of this nervous systems. Being inside that processor and be able to execute any Python code and run it on the circuits with a command or pressign F5 is incredible. Instead of having to go through all the wiring and additional extensions. So it is basically an all in one for basic projects, but we all know these have downsides I just havent figured them out yet.

The Python-code and uploading goes as follows:

And thats it, you write the code and run it. It also have a screen that displays errors where you would easily pinpoint the source of any bug.

As for the Python code itself, it also is almost as basic as Arduino it just uses different functions and different approaches to achieve the desired outputs.

I learned through simple tutorials with basic searches on the web. Although there is always more that one way to achieve the desired output, it comes down to a matter of the most efficient one.

The code I used was basically a push button and 6 LEDs and had the LEDs flash quickly in a circular pattern and run the loop for any specified amount of times. The code is found below:

import RPi.GPIO as GPIO from time import sleep GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) GPIO.setup(8, GPIO.OUT, initial=GPIO.LOW) GPIO.setup(10, GPIO.OUT, initial=GPIO.LOW) GPIO.setup(12, GPIO.OUT, initial=GPIO.LOW) GPIO.setup(16, GPIO.OUT, initial=GPIO.LOW) GPIO.setup(18, GPIO.OUT, initial=GPIO.LOW) GPIO.setup(3, GPIO.OUT, initial=GPIO.LOW) GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) i=0 while True: if GPIO.input(24) == GPIO.HIGH: while i<100: GPIO.output(8, GPIO.HIGH) sleep(.01) GPIO.output(8, GPIO.LOW) sleep(.01) GPIO.output(10, GPIO.HIGH) sleep(.01) GPIO.output(10, GPIO.LOW) sleep(.01) GPIO.output(12, GPIO.HIGH) sleep(.01) GPIO.output(12, GPIO.LOW) sleep(.01) GPIO.output(16, GPIO.HIGH) sleep(.01) GPIO.output(16, GPIO.LOW) sleep(.01) GPIO.output(18, GPIO.HIGH) sleep(.01) GPIO.output (18, GPIO.LOW) sleep(.01) GPIO.output(3, GPIO.HIGH) sleep(.01) GPIO.output(3, GPIO.LOW) sleep(.01) i+=1

I could also add that Python sort of forces you to keep your command line in order as in it goes in in hierarichal order. Wich is something fairly important to keep in mind and take into consideration when writing any sort of code. Maybe not for the time being but for future references and when trying to go back to it for any adjustments and way easier for debugging.

Here is a short video of the result using Raspberry Pi: