Assignment: * read a microcontroller data sheet * program your board to do something, with as many different programming languages and programming environments as possible. Extra credit: experiment with other architectures". . . "
Guillermo Jaramillo :: Fab Academy 2017
Fab Academy 2017
I start reading the documentation of Atmel AtMega328p. For my final project to modify a custom mode satshakit to be able to operate inputs and outputs as input and output sensors, so I am interested in programming the 328p. The datasheet of the microprocessor is avaliable clicking the image below.
Now i try to compact the code and probe the digital outputs:
Here is the list of the pins and a correspondency between a satshakit, based on a 328p board and an arduino uno. In the picture the pins signed with an x means that this will not be availiable in the final design.
The configuration of the arduino IDE is that shown in the picture below.
And here is the video showing the software and hardware integration and funtion. This try is using an arduino uno with an atmel 328p, the ssame processor for my final project.
And for the final board design, such is in design phase the final physical view is something like this.
I try with other program languages, like python. So to probe the board with an Atmel ATMega328p doing something with a different environment i found ig GitHub a project called Python Arduino Prototyping API v2. (https://github.com/vascop/Python-Arduino-Proto-API-v2)
Here some basics commands to operate an 328P. From read and write:
#This is a little sample to read a value. from arduino import Arduino import time
b = Arduino('/dev/ttyUSB0') pin = 3
b.output([])
while (True): val = b.analogRead(pin) print val time.sleep(2)
#This is a little sample to write a value. from arduino import Arduino import time
b = Arduino('/dev/ttyUSB0') pin = 13
#declare output pins as a list/tuple b.output([pin])
if (brightness == 0 or brightness == 255): fadeAmount = -fadeAmount
#This is a little sample to blink a led in to a pin 8 from arduino import Arduino import time
b = Arduino('/dev/ttyUSB0') pin = 8
#declare output pins as a list/tuple b.output([pin])
for xrange(10): b.setHigh(pin) time.sleep(1) print b.getState(pin) b.setLow(pin) print b.getState(pin) time.sleep(1)
b.close()
Additionally i try another microprocessor architecture called the STM32F405RG family, based on the high-performance ARM®Cortex®-M4 32-bit RISC core operating at a frequency of up to 168 MHz. The Cortex-M4 core features a Floating point unit (FPU) single precision which supports all ARM single-precision data-processing instructions and data types. It also implements a full set of DSP instructions and a memory protection unit (MPU) which enhances application security.
There is a online demo application to program it, and its available here: http://micropython.org/
#This is a little sample to blink a led in the virtual board and move a servo motor using USR push button and to exit pushing RST button from pyb import Servo import time import pyb
s1 = Servo(1) # servo on position 1 (X1, VIN, GND) #turns servo to 0º s1.angle(0) # move to 45 degrees
while True: if pyb.Switch().value(): pyb.LED(3).on() pyb.LED(4).off() s1.angle(-85, 1500) # move to -85 degrees in 1500ms time.sleep_ms(1000) else: pyb.LED(4).on() pyb.LED(3).off() s1.angle(45) # move to 45 degrees time.sleep_ms(1000)
So, a little video with the program running is here: