Skip to content

Instantly share code, notes, and snippets.

import pygame, time, math
# white background
background_colour = (255,255,255)
(width, height) = (1000, 500)
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption('Pendulum')
screen.fill(background_colour)
# rod length, meters
L = 2
@maxsimmonds1337
maxsimmonds1337 / MLIA_CSV_READER.py
Last active September 10, 2020 07:26
Converts the CSV file of the MLIA to a bode plot of mag/phase
## reads the CSV files generated by the Zurich Instruments MLIA impedance analyser
mag_index = 14
phase_index = 11
freq_index = 7
x_index = 20
y_index = 23
#### USER DEFINED VARIABLES ####
@maxsimmonds1337
maxsimmonds1337 / speedo.c
Last active November 13, 2020 09:43
Speedo for ebike controller using hall effect sensor
#include "stm32f4xx.h" // Device header
// Constants
const int hall_counts_per_rot = 23; // number of counts per one wheel rotation
const float wheel_diameter = 0.4;// 0.662; //meters
const float pi = 3.1412; // pi
const float cir = pi * wheel_diameter; // circumfrenece of the wheel
const float mps_mph = 2.23694; // m/s to m/h conversion
@maxsimmonds1337
maxsimmonds1337 / DMM.a51
Created April 29, 2021 09:07
DMM in Assembly
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Initialise Some Addresses ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pwm_out EQU P1.7 ;; PWM Output Set To MSB
lcd_cmd EQU 0800h ;; Write COMMAND reg address 0800h
lcd_st EQU 0801h ;; Read STATUS reg address 0801h
lcd_wr EQU 0802h ;; Write DATA reg address 0802h
lcd_rd EQU 0803h ;; Read DATA reg address 0803h
DAC EQU 0600h ;; DAC mapped at address 0600h
LEDs EQU P1 ;; Declare LEDs At P1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Define Some Origins ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
# importing the required module
from email.base64mime import header_length
import matplotlib.pyplot as plt
import cmath
import sys
import os
import subprocess
import uuid
import subprocess
@maxsimmonds1337
maxsimmonds1337 / Set point generator.v
Created August 31, 2022 19:47
Set point generator
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 31.08.2022 08:57:26
// Design Name:
// Module Name: set_point_generator
// Project Name:
// Target Devices:
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 29.08.2022 20:22:22
// Design Name:
// Module Name: pwm
// Project Name:
// Target Devices: