4. Computer controlled cutting¶
Tasks¶
-
Individual
- Browse through the data sheet for a microcontroller.
- Write a program for a microcontroller and simulate its operation.
-
Group
- demonstrate and compare the toolchains and development workflows for available embedded architectures.
Data Sheet¶
Here is the PDF for the data sheet of the XIAO RP2040.
Summary RP2040:
The RP2040 is a low cost high-performace microcontroller made y Raspberry Pi. It has a dual arm cortex-M0+ processor core that runs up to 133 MHz, 264 KB of embedded SRAM, and supports for up to 16 MB of external flash memory. The chip offers 30 multifunction of GPIO pins, with additional dedicated pins for SPI flash it inclueds hardware support for common peripherals. Other features include a 4-channe 12-bit ADC, USB 1.1 host support, and various low-power modes for battery-powered applications.
XIAO ESP-32-C3¶
First I used WokWi to simulate C++ blinking LED using a button for a C3.
My orignal code for this did not work so I asked Tyler Russell for help and he provided me this code to stimulate the C3.
int buttonState = 0;
void setup()
{
pinMode(D6, INPUT);
pinMode(D2, OUTPUT);
}
void loop()
{
// read the state of the pushbutton value
buttonState = digitalRead(D6);
// check if pushbutton is pressed. if it is, the
// buttonState is HIGH
if (buttonState == HIGH) {
// turn LED on
digitalWrite(D2, HIGH);
} else {
// turn LED off
digitalWrite(D2, LOW);
}
delay(10); // Delay a little bit to improve simulation performance
}
I then took the C++ code and used Arduino IDE to light up. The only problem with this was my button placement. I placed my button exactly across the usb-c port, so when I put the cord in the C3 it was over the button.
After I got my WokWi simulation working I followed this tutorial to download and set up Thonny onto my device. After I successfully installed Thonny, I asked chatgpt to change my original c++ code to micropython language.
``` from machine import Pin
import time
Setup pin modes¶
button = Pin(0, Pin.IN, Pin.PULL_UP) # GPIO 6 (D6 pin) as input with internal pull-up resistor led = Pin(28, Pin.OUT) # GPIO 2 (D2 pin) as output
while True: # Read the state of the button button_state = button.value()
# If the button is pressed, the button_state will be 0 (since we use a pull-up resistor)
if button_state == 1:
led.value(1) # Turn LED on
else:
led.value(0) # Turn LED off
time.sleep(0.01) # Delay a little bit to improve simulation performance
``` I used this code givent to me by chatgbt and put it into Thonny.
ATTINY85¶
XIAO RP2040¶
Issues I faced¶
ESP-C3:
- I was following the steps on the website to install esptool, but I kept running into issues getting it on my computer. I asked Angel for help, and we figured out that the problem was that I wasn’t running Command Prompt as an administrator. Because of that, every time I tried to install esptool for my C3, it wasn’t actually downloading onto my device.
- p