Posts

Week 6 L293D Motor Driver IC

Image
 How the motor driver Works Download specification q Using a Breadboard Using the Pico pico_code\hbridge.py #This is the pin out starting from the top left (Notch is the top) #Pin 1 enable = GPIO pin 1 (PWM pin) #Pin 2 = GPIO pin 2 #Pin 3 OUT 1 = motor lead 1 #Pin 4 GND = GND Pi #Pin 5 If using an external power source connect to the ground of that. #Pin 12, 13 are also GND that can be used to ground the external power supply or Pico #Pin 4,5,12 and 13 are internally connected so can be used for any ground.  #Pin 6 = motor lead 2 #Pin 7 = = GPIO 3 #Pin 8 (Vs) =  3.3V on Pico (Supplies power to the motor)  Can use external power. #Pin 16 (Vss) = 3.3 V Powers the board logic  #IC pins are numbered 1 and up anticlockwise. # pin 16 is top right. Python Coding Using Inputs Casting stings to numbers from input String functions (To split an input) Homework Turn the hbridge.py code into requestHBridge.py from the user to go forward or back and at what speed.  Make ...

Week 8 Reading Inputs, Pull Up and pull down resistors, ADC

Image
 What are Pull Up and Down resistors / Reading high low voltages with the pico What are they Experiment to show why the are needed Pico comes with them built in.  (But I could not get them to work) ADC What voltage drop is expected across a 1000 + 10000 voltage divider. Experiment This setup using a voltage divider is required for ADC work Equation to work out Vout Vdrop = R1/(R1+R2) * Vtotal Vdrop = 1000/(1000+10000) * 3.3 Vdrop = 0.3 V The voltage measured after the 1000Ohm resistor would be 3.3Ohm - 0.3Ohm. = 3.0 Ohm If we put the 10000 Ohm resistor as R1 it would drop the voltage by 3V so the measurement would be 0.3V GPIO 26, 27,28 are the only ADC pins Experiment with potentiometer Experiment with light dependent resistor Powering the Pico from an external source Power via usb powerbank Connect pins. Using between 1.8 and 5.5 V  Steps to Power Externally Connect a suitable power source  such as a battery pack (e.g., three AA batteries, or a single-cell LiPo bat...

Week 7 Servo Motor

Image
 How Servo motors work. Wiki Article From https://en.wikipedia.org/wiki/Servo_control#/media/File:Servomotor_Timing_Diagram.svg Now for a cycle of 50 Hz this means..... Each cycle lasts 1/50 sec = 0.2 sec = 20 ms  For -90 degree position 1ms /  20ms  =  5% 1.5ms /  20ms  = 7.5% duty cycle for 0 position For 90 degree position 2ms / 20ms = 10% duty cycle How a servo motor works So...  percent_duty_cycle = 0.0278 * degree + 7.5 Pico pin out Programming Collections basics\collectionsTest.py

Week 5 Using a transistor to run a motor.

Image
 What is a Transistor Youtube video  on transistors Youtube video  on transistors Why we need flyback diodes. Youtube Video Control a motor using a transistor without Pico  Control a motor using a transistor using Pico and PWM Run through last week's homework.

Week 4 Programming Looping and functions, make a buzzer sound with PWM

Fix up Code We need to fix up the mistake in several programs where the pin reset is wrong to do this  save basics/variables.py as basics/variables_your_name.py This is because we are going to update the code and we may lose the work you did otherwise. In Thonny open any file and go to tools->open system shell In the raspberry directory (you may need to change directory) type git pull Programming Conditionals (basics\conditionals.py) Looping For, While (basics\looping.py) Functions (basics\functions2025) Scope of blocks (counter inside function) use of the global keyword. Pico Make a buzzer sound using pwm (pico_code\buzzer.py) Homework Using a while loop add Fibonacci numbers and output their values until the Fibonacci number is greater that 100,000 Extension homework.  Find the largest prime number you can in 1 hr. (Ok to use your watch no need to look up "time" functions) Out of interest...  RSA prime numbers used are between 1024 bits long and 2048 bits long which ...

Week 2 Resistors, Using the Solderless Breadboard, Turning an LED on and off using the Pico

 Resistors Reading Resistors Using the Breadboard Power to the Breadboard How the jumper pins work for 3.3V and 5V  What pins are connected on the board. How to use the connectors LEDOnOff Program How IO pins work. How Breadboard pins work Meaning of extra names on pins (Especially SPI pins) Safety with Pi Set all pins to input at close of program Unplug Pi to set up circuit If doing something you are unsure of test with LEDs or Multimeter. Have no physical connections to expensive laptops etc. (More on running the pico without a laptop connection later) Try with 500 ohm resistor first. Run LED program on pico. Explaining the program Commenting with # The importance of indents in python try, exception, finally Homework Make your LED flash an SOS in Morse Code S is 3 dits.  O is 3 dahs The Dot (Dit):  The shortest element, representing 1 unit of time. The Dash (Dah):  A longer element, equal to 3 dots in duration. Intra-character Gap:  The short silence betw...

Week 3 Introducing Python Coding, Pulse Width Modulation

 Python Coding Program set out imports constants global variables functions main block Program Exercises Comments Constants ( Why we use them,   Where do they go) Variables Data types Operations Micropython is different to standard python.  They have to pack a lot into a little microcontroller.  So if something works on your local machine interpreter but not on the pico have a look in the differences doco for work arounds Work through the exercises in basics/variables.py Pulse Width Modulation (PWM) Watch Core Electronics video on PWM Set up led_pwm.py on breadboard and run.