Skip to content

silverprojectA/electronics-Y2-T2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Electronics_2

ROBERT_TheRobot

Challenge 1: Dancing LED lights (Level 1)

This is the easiest to achieve. In Lab 6, you already worked on the skeleton beat detection using Pybench and blinking the blue LED. You can combine beat detection with loudness to light up more LEDs, synchronised to the beat, when the volume of music is louder. You can also improve the beat detection algorithm as you see fit. This challenge was already specified in Lab 6 instruction sheet as “option” for Lab 6!

Edited the lab 6 task task 3 code

In addition to the previous code, I have added a calculation to work out the instantaneous energy of the beat. As well as changing the led from the inbuilt led to the strip of leds.

The instantaneous energy equates (on a linear scale) to the number of leds being lit up. With a greater energy equating to more leds being lit.

M = 50
BEAT_THRESHOLD = 2.0
MIN_BEAT_PERIOD = 500

Challenge 5: Self-balancing the Segway (Level 4)

This challenge requires you to implement a PID algorithm using the pitch angle as the set-pont variable and control the motors to maintain the pitch angle to be zero (verticle). You should attempt this challenge initially with stablizers (much like when you learned to ride a bike), and remove them after self-balancing is achieved. Download the Lab 7 instruction, which contains quite a few tips and pseudo-code segment to help you towards the goal.

There are some unused implementations in the code which will be usefull if i ever get the robot into a state where it is balanced and dancing these include:

  • The code for implementing the potentiometer (this is used during tuning)
  • The code that calculates the instantaneous energy
  • The set up of the Microphone
  • The external interupts for the hall effect sensors

implemented a complimentary filter

g_pitch = alpha * (g_pitch + pitch_dot * dt * 0.001) + (1-alpha) * pitch
  • alpha - filter coefficient. Determines the weight given to the gyroscope vs the accelerometer.
  • pitch_dot - The pitch rate (angular velocity) from the gyroscope.
  • dt - The time step (in milliseconds, hence the 0.001 factor to convert to seconds)
  • pitch - The pitch angle from the accelerometer

Gyroscope part:

multiplied by alpha to give gyroscope weighting

(g_pitch + pitch_dot * dt * 0.001)

Accelerometer part:

Multiplied by 1-alpha

pitch

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages