This document describes code for controlling a self-balancing skateboard or robot using an Arduino board and a Sabertooth motor controller. It includes sections to initialize communication with the Sabertooth, sample sensor inputs from an IMU, apply filtering to the accelerometer data, and calculate steering commands based on gyroscope readings to maintain balance and allow for user steering input. The code is intended to balance the device and allow it to be steered either straight or in a turn with adjustable resistance to deviations from the desired heading.
Twin wheeler modified for arduino simplified serial protocol to sabertooth v22josnihmurni2907
This document provides code for a self-balancing two-wheeled robot (twin wheeler) modified to use a simplified serial protocol to control motors with an Arduino and Sabertooth motor controller. The code samples sensor inputs, runs control algorithms to maintain balance, and outputs motor control signals. It has been updated over time with improvements like a softer startup sequence, improved deadman switch functionality, and optional steering controls.
The document describes the design of an obstacle avoiding robot. It uses an Arduino Uno microcontroller along with an L298N motor driver and three ultrasonic sensors to detect obstacles and navigate around them. The robot is able to stop when an obstacle is detected within 20cm and can change direction left or right based on sensor readings to avoid the obstacle and resume movement. Some areas of potential improvement discussed are adding additional sensors to monitor environmental conditions and adapting the design for applications like assisting the blind or automatic vacuuming.
ELECTRICAL AND INSTRUMENTATION ENGINEERING COURSE
Lect 2- Electric Machines
Please subscribe to my YouTube Channel for best training lectures:
https://www.youtube.com/channel/UCRkUJFOsyZG1E1LDWzUr_hw
This document introduces SPICE (Simulation Program with Integrated Circuit Emphasis) and how to model and simulate circuits using SPICE. It describes SPICE control cards, circuit elements, units, voltage and current sources, and shows examples of modeling an RC circuit response, NMOS I-V characteristics, inverter transient analysis, propagation delay measurement, and leakage current measurement. It also discusses extracting SPICE netlists from circuit layout tools like L-Edit to verify the layout functionality through simulation.
This document describes and analyzes a parallel RLC circuit. It provides the circuit diagram and calculates the impedance, current, power, reactive power, and capacitance of the circuit for different component values. The key details provided include the circuit diagram, equations for impedance, power and reactive power, and sample calculations of these values for RLC circuits with various resistances, inductances and capacitances.
1) The document provides instructions for testing a microcontroller and motor driver circuit board. It describes verifying connections, programming the microcontroller, testing LEDs and motor operation, and completing the PCB assembly.
2) Key steps include verifying traces are not touching, ground and power connections, pre-soldering components for code upload and testing, programming the microcontroller with a blink test code, testing the LEDs and motor, soldering power components, and final assembly.
3) Upon completing the assembly, the instructions confirm the motor spins in both directions as controlled by the code, with the LEDs following accordingly, indicating the circuit is functioning properly.
Twin wheeler modified for arduino simplified serial protocol to sabertooth v22josnihmurni2907
This document provides code for a self-balancing two-wheeled robot (twin wheeler) modified to use a simplified serial protocol to control motors with an Arduino and Sabertooth motor controller. The code samples sensor inputs, runs control algorithms to maintain balance, and outputs motor control signals. It has been updated over time with improvements like a softer startup sequence, improved deadman switch functionality, and optional steering controls.
The document describes the design of an obstacle avoiding robot. It uses an Arduino Uno microcontroller along with an L298N motor driver and three ultrasonic sensors to detect obstacles and navigate around them. The robot is able to stop when an obstacle is detected within 20cm and can change direction left or right based on sensor readings to avoid the obstacle and resume movement. Some areas of potential improvement discussed are adding additional sensors to monitor environmental conditions and adapting the design for applications like assisting the blind or automatic vacuuming.
ELECTRICAL AND INSTRUMENTATION ENGINEERING COURSE
Lect 2- Electric Machines
Please subscribe to my YouTube Channel for best training lectures:
https://www.youtube.com/channel/UCRkUJFOsyZG1E1LDWzUr_hw
This document introduces SPICE (Simulation Program with Integrated Circuit Emphasis) and how to model and simulate circuits using SPICE. It describes SPICE control cards, circuit elements, units, voltage and current sources, and shows examples of modeling an RC circuit response, NMOS I-V characteristics, inverter transient analysis, propagation delay measurement, and leakage current measurement. It also discusses extracting SPICE netlists from circuit layout tools like L-Edit to verify the layout functionality through simulation.
This document describes and analyzes a parallel RLC circuit. It provides the circuit diagram and calculates the impedance, current, power, reactive power, and capacitance of the circuit for different component values. The key details provided include the circuit diagram, equations for impedance, power and reactive power, and sample calculations of these values for RLC circuits with various resistances, inductances and capacitances.
1) The document provides instructions for testing a microcontroller and motor driver circuit board. It describes verifying connections, programming the microcontroller, testing LEDs and motor operation, and completing the PCB assembly.
2) Key steps include verifying traces are not touching, ground and power connections, pre-soldering components for code upload and testing, programming the microcontroller with a blink test code, testing the LEDs and motor, soldering power components, and final assembly.
3) Upon completing the assembly, the instructions confirm the motor spins in both directions as controlled by the code, with the LEDs following accordingly, indicating the circuit is functioning properly.
DomCode 2015 - Abusing phones to make the internet of thingsJan Jongboom
The document discusses abusing phone sensors to create internet of things applications. It provides examples of using light, motion, and sound sensors to control music, visualize juggling, and generate computer music. It also covers using Bluetooth beacons and the physical web to discover and interact with devices, and a sample code for connecting to a drone over Bluetooth to control its flight. The overall message is about exploring creative ways to turn phones into interfaces for interactive experiences.
This document summarizes the specifications and performance of the N13T2 programmable unijunction transistor (PUT) made by NEC. It includes the component parameters, equivalent circuit diagram, characteristics such as peak voltage and current, forward voltage, and pulse output voltage and rise time. The performance is evaluated based on the manufacturer's specifications.
This document summarizes the SPICE model parameters for simulating the behavior of a TLP181 photocoupler device in a circuit simulation. It includes tables describing the parameters for modeling the internal photodiode, bipolar junction transistor, controlled voltage and current sources, and LED characteristics. Simulation results are also shown for key electrical characteristics of the photocoupler component along with comparison data to actual device measurements.
This document provides an overview of microprocessors and the Arduino development environment. It begins with definitions of a microprocessor as a tiny, inexpensive computer that can interact with the physical world through sensors and actuators. It then discusses what an Arduino is and provides instructions for a basic "blink" example project using an LED. The document covers Arduino software, hardware, and programming concepts like inputs, outputs, variables, and functions. It also explores modifying and debugging code and connecting additional hardware like buttons, sensors, and stepper motors.
This document summarizes the modeling of a TLP180 photocoupler component. It includes:
1) Equivalent circuit diagrams and descriptions of the diode, bipolar junction transistor, and voltage controlled voltage/current source models used.
2) Simulation results and comparisons with measurements for key characteristics like IV curves, switching times, and more.
3) Evaluation circuits used to simulate and compare the photocoupler's electrical behavior.
This document provides an overview of the operation of a SIPART PS2 pressure control device. It includes a view of the device labeling the main components. The document then provides a table that defines the functions and settings of 55 parameters that can be configured on the device. The parameters relate to functions like the type of actuator, initialization settings, setpoint settings, alarm settings, and resetting to factory defaults. It also provides information on automatic initialization processes and potential error messages that could display.
SPICE MODEL of KGH15N120NDA (Professional+FWDP Model) in SPICE PARKTsuyoshi Horigome
SPICE MODEL of KGH15N120NDA (Professional+FWDP Model) in SPICE PARK. English Version is http://www.spicepark.net. Japanese Version is http://www.spicepark.com by Bee Technologies.
Scoala de vara_idg_introducere_in_roboticaScoalaVara
This document introduces robotics and provides examples of robots like Mini Sumo and Line Follower robots. It discusses the main components of robots like sensors, motors, and processors. It provides code examples for testing sensors and motors and moving a robot by controlling the speed of each motor. The document suggests building obstacle detection and sumo wrestling as challenges for teams.
SPICE MODEL of KGH15N120NDA (Professional+FWDS Model) in SPICE PARKTsuyoshi Horigome
SPICE MODEL of KGH15N120NDA (Professional+FWDS Model) in SPICE PARK. English Version is http://www.spicepark.net. Japanese Version is http://www.spicepark.com by Bee Technologies.
SPICE MODEL of KGH15N120NDA (Professional+FWD+SP Model) in SPICE PARKTsuyoshi Horigome
SPICE MODEL of KGH15N120ND (Professional+FWD+SP Model) in SPICE PARK. English Version is http://www.spicepark.net. Japanese Version is http://www.spicepark.com by Bee Technologies.
This document provides a device modeling report for a programmable unijunction transistor (N13T1) manufactured by NEC. It includes the component parts, SPICE model parameters and equivalent circuit. Simulation results show the peak voltage and current characteristics meet specifications. The forward voltage at 50mA and pulse output voltage and rise time also meet given specifications.
SPICE MODEL of TC7PA175FU in SPICE PARK. English Version is http://www.spicepark.net. Japanese Version is http://www.spicepark.com by Bee Technologies.
The document provides information about the CHV110 series energy saving cabinet, including:
1. Details on the technology features, nameplate description, dimensions, and specifications of the cabinet.
2. Instructions for unpacking, installing, wiring, operating, and programming the various functions of the cabinet.
3. Guidelines for troubleshooting faults, maintenance, use in injection molding machines, and a list of function parameters.
This document discusses using Arduino with Ruby. It provides an overview of Arduino hardware and software, introduces RAD (Ruby Arduino Development) for writing Ruby code to control Arduino boards, and presents several example projects that combine Arduino and Ruby including Ruby on Bells, Barduino, and a Flying Robot. Code examples are provided for blinking an LED, fading an LED, reading an analog sensor, and using servos from Ruby. Additional sensors and shields discussed include Sharp IR sensors, ultrasonic rangefinders, and WiFi shields.
DomCode 2015 - Abusing phones to make the internet of thingsJan Jongboom
The document discusses abusing phone sensors to create internet of things applications. It provides examples of using light, motion, and sound sensors to control music, visualize juggling, and generate computer music. It also covers using Bluetooth beacons and the physical web to discover and interact with devices, and a sample code for connecting to a drone over Bluetooth to control its flight. The overall message is about exploring creative ways to turn phones into interfaces for interactive experiences.
This document summarizes the specifications and performance of the N13T2 programmable unijunction transistor (PUT) made by NEC. It includes the component parameters, equivalent circuit diagram, characteristics such as peak voltage and current, forward voltage, and pulse output voltage and rise time. The performance is evaluated based on the manufacturer's specifications.
This document summarizes the SPICE model parameters for simulating the behavior of a TLP181 photocoupler device in a circuit simulation. It includes tables describing the parameters for modeling the internal photodiode, bipolar junction transistor, controlled voltage and current sources, and LED characteristics. Simulation results are also shown for key electrical characteristics of the photocoupler component along with comparison data to actual device measurements.
This document provides an overview of microprocessors and the Arduino development environment. It begins with definitions of a microprocessor as a tiny, inexpensive computer that can interact with the physical world through sensors and actuators. It then discusses what an Arduino is and provides instructions for a basic "blink" example project using an LED. The document covers Arduino software, hardware, and programming concepts like inputs, outputs, variables, and functions. It also explores modifying and debugging code and connecting additional hardware like buttons, sensors, and stepper motors.
This document summarizes the modeling of a TLP180 photocoupler component. It includes:
1) Equivalent circuit diagrams and descriptions of the diode, bipolar junction transistor, and voltage controlled voltage/current source models used.
2) Simulation results and comparisons with measurements for key characteristics like IV curves, switching times, and more.
3) Evaluation circuits used to simulate and compare the photocoupler's electrical behavior.
This document provides an overview of the operation of a SIPART PS2 pressure control device. It includes a view of the device labeling the main components. The document then provides a table that defines the functions and settings of 55 parameters that can be configured on the device. The parameters relate to functions like the type of actuator, initialization settings, setpoint settings, alarm settings, and resetting to factory defaults. It also provides information on automatic initialization processes and potential error messages that could display.
SPICE MODEL of KGH15N120NDA (Professional+FWDP Model) in SPICE PARKTsuyoshi Horigome
SPICE MODEL of KGH15N120NDA (Professional+FWDP Model) in SPICE PARK. English Version is http://www.spicepark.net. Japanese Version is http://www.spicepark.com by Bee Technologies.
Scoala de vara_idg_introducere_in_roboticaScoalaVara
This document introduces robotics and provides examples of robots like Mini Sumo and Line Follower robots. It discusses the main components of robots like sensors, motors, and processors. It provides code examples for testing sensors and motors and moving a robot by controlling the speed of each motor. The document suggests building obstacle detection and sumo wrestling as challenges for teams.
SPICE MODEL of KGH15N120NDA (Professional+FWDS Model) in SPICE PARKTsuyoshi Horigome
SPICE MODEL of KGH15N120NDA (Professional+FWDS Model) in SPICE PARK. English Version is http://www.spicepark.net. Japanese Version is http://www.spicepark.com by Bee Technologies.
SPICE MODEL of KGH15N120NDA (Professional+FWD+SP Model) in SPICE PARKTsuyoshi Horigome
SPICE MODEL of KGH15N120ND (Professional+FWD+SP Model) in SPICE PARK. English Version is http://www.spicepark.net. Japanese Version is http://www.spicepark.com by Bee Technologies.
This document provides a device modeling report for a programmable unijunction transistor (N13T1) manufactured by NEC. It includes the component parts, SPICE model parameters and equivalent circuit. Simulation results show the peak voltage and current characteristics meet specifications. The forward voltage at 50mA and pulse output voltage and rise time also meet given specifications.
SPICE MODEL of TC7PA175FU in SPICE PARK. English Version is http://www.spicepark.net. Japanese Version is http://www.spicepark.com by Bee Technologies.
The document provides information about the CHV110 series energy saving cabinet, including:
1. Details on the technology features, nameplate description, dimensions, and specifications of the cabinet.
2. Instructions for unpacking, installing, wiring, operating, and programming the various functions of the cabinet.
3. Guidelines for troubleshooting faults, maintenance, use in injection molding machines, and a list of function parameters.
This document discusses using Arduino with Ruby. It provides an overview of Arduino hardware and software, introduces RAD (Ruby Arduino Development) for writing Ruby code to control Arduino boards, and presents several example projects that combine Arduino and Ruby including Ruby on Bells, Barduino, and a Flying Robot. Code examples are provided for blinking an LED, fading an LED, reading an analog sensor, and using servos from Ruby. Additional sensors and shields discussed include Sharp IR sensors, ultrasonic rangefinders, and WiFi shields.
Twin wheeler modified for arduino simplified serial protocol to sabertooth v2josnihmurni2907
This Arduino code modifies a twin-wheeled robot to use a Sabertooth motor controller with a simplified serial protocol. It tests communication between the Arduino, Sabertooth, and motors. A deadman switch cuts power if released for safety. The motors gradually increase in speed from 0-50% of full power over 5 seconds, then decrease from 50-0% over 5 more seconds in a continuous loop. Both wheels must spin at the same speed and direction or the robot will not drive straight.
The document discusses programming digital to analog conversion and analog to digital conversion using an LPC1768 microcontroller and the mbed development platform. It provides code examples for generating different output waveforms like constant voltages, sawtooth waves, and sine waves using the DAC and for reading analog sensor values with the ADC to control outputs. PWM is also demonstrated for controlling motor speed and generating tones with a speaker.
This document contains Arduino code to log accelerometer and gyroscope sensor data to an SD card. It initializes the SD card, sets up the gyroscope sensor with I2C communication, and takes readings from the accelerometer and gyroscope in a loop. The readings are appended to a string and written to an SD card file and serial port for logging. It converts the accelerometer data to g-forces and calculates the gyroscope rotation rate and angle from the readings.
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009Eoin Brazil
CS4062 Masters in Interactive Media - Third Arduino Lecture - March 11th 2009 - University of Limerick. This lecture presents an introduction to motors, LEDs and Arduino with examples. This was aimed at a digital media / music technology masters student audience.
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009Eoin Brazil
CS4062 Masters in Interactive Media - Third Arduino Lecture - March 11th 2009 - University of Limerick. This lecture presents an introduction to motors, LEDs and Arduino with examples. This was aimed at a digital media / music technology masters student audience.
Arduino Workshop Day 2 - Advance Arduino & DIYVishnu
Arduino Workshop Day 2 - IR, Ultrasonic & Temperature - Humidity Sensor Interfacing & Do It Yourself - Line Follower, Light Follower & Obstacle Avoider.
This document contains lecture notes on Verilog syntax and structural modeling. It discusses various Verilog concepts like commenting code, numbers and identifiers, vectors, arrays, parameters and defines, gate primitives, and hierarchy. It provides examples of modeling half adders and full adders structurally and behaviorally using primitives, modules, and always blocks. The document emphasizes choosing descriptive names and commenting code to explain the purpose or motivation behind design decisions.
What will be quantization step size in numbers and in voltage for th.pdfSIGMATAX1
What will be quantization step size in numbers and in voltage for this Arduino Code? Using 5V
const int led1 = 2;
const int led2 = 3;
const int led3 = 4;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
int dataConv = sensorValue*(8.0/1024);
//write analog equvivalant data on led pins
switch(dataConv)
{
case 0: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 1: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 2: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 3: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 4: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 5: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 6: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
case 7: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
}
Serial.println(sensorValue); // print out the value you read:
Serial.println(dataConv);
delay(1000); // delay in between reads for stability
}
const int led1 = 2;
const int led2 = 3;
const int led3 = 4;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
int dataConv = sensorValue*(8.0/1024);
//write analog equvivalant data on led pins
switch(dataConv)
{
case 0: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 1: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
break;
}
case 2: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 3: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,LOW);
break;
}
case 4: {
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 5: {
digitalWrite(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
break;
}
case 6: {
digitalWrite(led1,LOW);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
case 7: {
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
break;
}
}
Serial.println(sensorValue); // print out the value you read:
Serial.println(dataConv);
delay(1000); // delay in between reads for stability
}
Solution
// Random LED Dots - from noise source
// Ed Nisley - KE4ANU - September 2015
//----------
// Pin assignments
const byte PIN_HEARTBEAT = 8; // DO - heartbeat LED
const byte PIN_SYNC = A3; // DO.
the servo motor by controlling the PWM signal and also control the speed and position of robot via Bluetooth or IOT.
Hexapod robot has static as well as dynamic stability which make it more stable.
Technology used: Servomotor, Arduino IDE, HC-05 Bluetooth, Arduino App
This technical manual provides information on setting up and configuring the Altivar 11 variable speed drive. It begins with the basic steps for setting up the drive, including checking the drive against the purchase order, mounting it, making electrical connections, and performing initial configuration. Next, it describes the factory configuration settings, including default parameter values and I/O mappings. The document then lists the drive reference codes and specifications, provides guidance on programming and configuration menus, and covers maintenance and troubleshooting.
The document discusses Arduino, an open-source electronics prototyping platform. It describes Arduino Uno, including its processor, memory, input/output pins, and operating voltage. It provides steps for getting started with Arduino, including downloading the IDE, connecting the board, selecting options in the IDE, and uploading a basic blink program. The document also covers some key Arduino concepts like variables, conditional statements, loops, and functions.
This program controls a robot using a microcontroller. It defines pins for sensors and motors, includes libraries, and declares interrupt routines to control pulse-width modulation for motor speed. The main routine initializes ports, timers and interrupts, then calls functions for the robot to scan its environment, turn right, and repeat in a loop.
This document discusses how to control the direction and speed of a DC motor using an Arduino and an L293D motor driver chip. It explains how to connect the components, experiment with manually controlling the motor direction using the L293D pins, and write Arduino code to control the motor direction with a button and speed with a potentiometer. The code uses PWM on one L293D pin to control motor speed and sets the other two pins in opposite states to control motor direction.
The document provides setup instructions for a G320X DC servo drive. It explains how to connect the encoder, power supply, and control inputs to the drive terminals before connecting the motor. Key steps include connecting the encoder channels and power, testing the encoder functionality, and connecting the direction and step signals before finally attaching the motor. The drive has dip switches to set parameters like gain and following error limits.
Presentation about using the tech behind a couple of my projects in your own work. It contains tips about how to play music with machines and how to connect your cellphone to an Arduino.
Code for the presentation can be found here - https://github.com/neilmendoza/musicalmachines
This Arduino code measures the time interval between a pin going high and another pin going low. It waits for pin 4 to go high, starts a timer, lights an LED, then waits for pin 5 to go low, stops the timer, and reports the elapsed time in microseconds. The code provides a simple way to time events and can reliably measure intervals down to about 60 microseconds.
This document contains the code for a sigh collector receiver module. It defines variables to control an LED, pump, and reading value. It initializes serial communication and sets the pumpRunning and stepCounter variables. The main loop handles serial data, checks if the pump should start or stop based on the stepCounter and time thresholds, and debounces the button input. Additional functions start and stop the pump by controlling the LED and pump pins.
This code is used to detect sighs from a patient and send a signal to a mobile device. It reads analog sensor data to calculate a sliding average breath value and compare it to a threshold. When the average exceeds the threshold for a possible sigh, it monitors for the average to drop below a level to confirm the sigh. Upon detection, it sends a signal over a serial connection and lights an LED for one second.
This document provides instructions on how to write reliable timers and delays in Arduino without using the delay() function, which causes the system to pause while waiting. It introduces the elapsedMillis library for creating repeating and one-time timers. It then discusses alternatives that do not require this library, including examples of a repeating timer and single-shot timer using millis(). The document warns of issues with approaches that rely on millis() overflowing after 50 days and recommends using elapsed time comparisons instead of absolute times to ensure reliability. It emphasizes the importance of the loop() executing frequently enough.
The document defines constants for the bit patterns of various alphanumeric characters and symbols using hexadecimal values. It then defines arrays to store these patterns and functions to display the patterns on a 7-segment display by shifting the bit patterns and latching them to the display driver. When serial data is received, the appropriate character patterns are copied to a display array which is then scrolled on the display using the defined functions.
The document defines constants for binary representations of letters, numbers, and punctuation symbols. It then defines functions for displaying these symbols on a scrolling LED display using shift registers and SPI communication. The main loop calls the display function to scroll the text "HI WORLD" across the LED display.
Call and message using arduino and gsm modulejosnihmurni2907
This document describes building a simple mobile phone using an Arduino, GSM module, keypad, LCD display, speaker, and microphone. The phone can make and receive calls, and send and receive SMS messages. The GSM module handles the cellular connectivity, while the Arduino controls interfacing with the components and sending AT commands to the GSM module to perform phone functions. An alphanumeric keypad is used for input, and a LCD displays messages, instructions, and call/SMS information.
The document discusses code for independently flashing 3 LEDs with different on and off periods using an Arduino Uno board. The author has set up the hardware with 3 LEDs connected to digital pins 6, 7 and 8. Their code currently causes all LEDs to flash with the same on/off period rather than independently. They are seeking help altering their code to independently control the on and off periods of each LED. Several suggestions are provided, including using external interrupts triggered by a separate pin and counting interrupts to control the LED timing. However, the author is still struggling to get the LEDs flashing independently as intended.
This document provides an overview of timers and interrupts on Arduino boards. It explains what timers and interrupts are, how the different timers on Arduino boards like the Uno and Mega work, and how to configure and use them. It includes examples of blinking an LED using a timer compare match interrupt and generating PWM signals using timers. Common libraries that use timers like the Servo library are also discussed alongside potential issues when using timers and interrupts.
The document contains 13 math problems involving functions. The problems cover topics such as:
- Finding the image and object of elements under a given function
- Finding inverse functions
- Determining the type of relation between sets
- Evaluating composite functions
- Solving for unknown constants in function definitions
- Finding the value of x when a composite function equals a given value
The document provides the problems and blank spaces for the answers. The answers section gives the solutions to each of the 13 problems.
(i) Rangkaian tahunan matematika untuk tingkatan 5 SMK Taman Indah membincangkan topik-topik seperti asas nombor, graf fungsi, penjelmaan dan matriks. (ii) Topik-topik ini akan diajar selama 13 minggu dan diikuti dengan ujian selaras pada minggu ke-11 dan ke-18. (iii) Aktiviti pembelajaran terdiri daripada perbincangan kelas, projek, dan penggunaan perisian seperti Geometer's Sketchpad.
Dokumen tersebut memberikan 10 cara untuk menghilangkan rasa ngantuk di kelas, termasuk berjemur, olahraga ringan, minum teh hijau, berjalan, bernapas dalam, dan olahraga rutin. Tujuannya adalah meningkatkan aliran darah dan oksigenasi otak untuk menjaga fokus dan konsentrasi selama pelajaran.
Bandar purba berukuran 62 padang bola sepak ditemui terletak 26-40 meter di bawah permukaan Tasik Qiandao di China, dibina pada abad ke-3 Masehi dan menjadi tapak menyelam popular.
Dokumen tersebut merangkum 12 kaum yang dibinasakan Allah menurut Alquran karena mengingkari utusan-Nya, termasuk kaum Nabi Nuh, Nabi Hud, Nabi Saleh, Nabi Luth, Nabi Syuaib, Firaun, Ashab Al-Sabt, Ashab Al-Rass, Ashab Al-Ukhdud, Ashab Al-Qaryah, Kaum Tubba' dan Kaum Saba. Mereka dihukumi dengan berbagai azab seperti banjir, angin kencang,
This document contains a summary of the key points to address in answering additional mathematics questions from a 2015 SPM exam. It includes 24 questions covering topics like functions, vectors, probability, calculus, and statistics. For each question, it lists the correct answer or working, identified with a check mark. It provides guidance on acceptable versus unacceptable responses. The summary aims to help students understand the essential information and logical reasoning required to solve additional math problems.
How to Manage Your Lost Opportunities in Odoo 17 CRMCeline George
Odoo 17 CRM allows us to track why we lose sales opportunities with "Lost Reasons." This helps analyze our sales process and identify areas for improvement. Here's how to configure lost reasons in Odoo 17 CRM
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
The simplified electron and muon model, Oscillating Spacetime: The Foundation...RitikBhardwaj56
Discover the Simplified Electron and Muon Model: A New Wave-Based Approach to Understanding Particles delves into a groundbreaking theory that presents electrons and muons as rotating soliton waves within oscillating spacetime. Geared towards students, researchers, and science buffs, this book breaks down complex ideas into simple explanations. It covers topics such as electron waves, temporal dynamics, and the implications of this model on particle physics. With clear illustrations and easy-to-follow explanations, readers will gain a new outlook on the universe's fundamental nature.
বাংলাদেশের অর্থনৈতিক সমীক্ষা ২০২৪ [Bangladesh Economic Review 2024 Bangla.pdf] কম্পিউটার , ট্যাব ও স্মার্ট ফোন ভার্সন সহ সম্পূর্ণ বাংলা ই-বুক বা pdf বই " সুচিপত্র ...বুকমার্ক মেনু 🔖 ও হাইপার লিংক মেনু 📝👆 যুক্ত ..
আমাদের সবার জন্য খুব খুব গুরুত্বপূর্ণ একটি বই ..বিসিএস, ব্যাংক, ইউনিভার্সিটি ভর্তি ও যে কোন প্রতিযোগিতা মূলক পরীক্ষার জন্য এর খুব ইম্পরট্যান্ট একটি বিষয় ...তাছাড়া বাংলাদেশের সাম্প্রতিক যে কোন ডাটা বা তথ্য এই বইতে পাবেন ...
তাই একজন নাগরিক হিসাবে এই তথ্য গুলো আপনার জানা প্রয়োজন ...।
বিসিএস ও ব্যাংক এর লিখিত পরীক্ষা ...+এছাড়া মাধ্যমিক ও উচ্চমাধ্যমিকের স্টুডেন্টদের জন্য অনেক কাজে আসবে ...
Assessment and Planning in Educational technology.pptxKavitha Krishnan
In an education system, it is understood that assessment is only for the students, but on the other hand, the Assessment of teachers is also an important aspect of the education system that ensures teachers are providing high-quality instruction to students. The assessment process can be used to provide feedback and support for professional development, to inform decisions about teacher retention or promotion, or to evaluate teacher effectiveness for accountability purposes.
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
Executive Directors Chat Leveraging AI for Diversity, Equity, and InclusionTechSoup
Let’s explore the intersection of technology and equity in the final session of our DEI series. Discover how AI tools, like ChatGPT, can be used to support and enhance your nonprofit's DEI initiatives. Participants will gain insights into practical AI applications and get tips for leveraging technology to advance their DEI goals.
Strategies for Effective Upskilling is a presentation by Chinwendu Peace in a Your Skill Boost Masterclass organisation by the Excellence Foundation for South Sudan on 08th and 09th June 2024 from 1 PM to 3 PM on each day.
This presentation includes basic of PCOS their pathology and treatment and also Ayurveda correlation of PCOS and Ayurvedic line of treatment mentioned in classics.
Twin wheeler modified for arduino simplified serial protocol to sabertooth v21
1. //TWIN WHEELER MODIFIED FOR ARDUINO SIMPLIFIED SERIAL PROTOCOL TO
SABERTOOTH V2
//J. Dingley For Arduino 328 Duemalinove or similar with a 3.3V accessory
power output
//i.e. the current standard Arduino board.
//2nd April 2010
//small bugs fixed. Now uses second gyro to maintain a constant rate of
turn in degrees per second
//I have now built this as a skateboard with 24V lead acid batteries,
2x250Watt motors and Razor E100 chain driven wheels
//and it balances and turns fine with me standing on top of it.
//designed for use with a rocker switch for steering as in original
description on my "instructable":
//http://www.instructables.com/id/Easy-build-self-balancing-
skateboardrobotsegway-/
#include <SoftwareSerial.h>
//Set dip switches on the Sabertooth for simplified serial and 9600
Buadrate. Diagram of this on my Instructables page//
//Digital pin 13 is serial transmit pin to sabertooth
#define SABER_TX_PIN 13
//Not used but still initialised, Digital pin 12 is serial receive from
Sabertooth
#define SABER_RX_PIN 12
//set baudrate to match sabertooth dip settings
#define SABER_BAUDRATE 9600
//simplifierd serial limits for each motor
#define SABER_MOTOR1_FULL_FORWARD 127
#define SABER_MOTOR1_FULL_REVERSE 1
#define SABER_MOTOR2_FULL_FORWARD 255
#define SABER_MOTOR2_FULL_REVERSE 128
//motor level to send when issuing full stop command
#define SABER_ALL_STOP 0
SoftwareSerial SaberSerial = SoftwareSerial (SABER_RX_PIN, SABER_TX_PIN );
void initSabertooth (void) {
//initialise software to communicate with sabertooth
pinMode ( SABER_TX_PIN, OUTPUT );
SaberSerial.begin( SABER_BAUDRATE );
//2 sec delay to let it settle
delay (2000);
SaberSerial.print(0, BYTE); //kill motors when first switched on
}
2. //setup all variables. Terms may have strange names but this software has
evolved from bits and bobs done by other segway clone builders
float level=0;
float aa = 0.005; //this means 0.5% of the accelerometer reading is fed
into angle of tilt calculation with every loop of program (to correct the
gyro).
//accel is sensitive to vibration which is why we effectively average it
over time in this manner. You can increase aa if you want experiment.
//too high though and the board may become too vibration sensitive.
float Steering;
float SteerValue;
float SteerCorrect;
float steersum;
int Steer = 0;
float accraw;
float x_acc;
float accsum;
float x_accdeg;
float gyrosum;
float hiresgyrosum;
float g;
float s;
float t;
float gangleratedeg;
float gangleratedeg2;
int adc1;
int adc4;
int adc5;
float gangleraterads;
float ti = 2;
float k1;
int k2;
int k3;
int k4;
float overallgain;
float gyroangledt;
float angle;
float anglerads;
float balance_torque;
float softstart;
float cur_speed;
//float cycle_time = 0.00555; //seconds per cycle - currently 5.55
milliseconds per loop of the program. If you change it a lot you can
measure the pulse coming out of
//digital pin 8 (one per program cycle) to reccalculate this variable. Need
to know it as gyro measures rate of turning. Needs to know time between
each measurement
3. //so it can then work out angle it has turned through since the last
measurement - so it can know angle of tilt from vertical.
float cycle_time = 0.01;
float Balance_point;
float balancetrim;
int balleft;
int balright;
float a0, a1, a2, a3, a4, a5, a6; //Sav Golay variables. The TOBB bot
describes this neat filter for accelerometer called Savitsky Golay filter.
//More on this plus links on my website.
int i;
int j;
int tipstart;
signed char Motor1percent;
signed char Motor2percent;
//analog inputs. Wire up the IMU as in my Instructable and these inputs
will be valid.
int accelPin = 4; //pin 4 is analog input pin 4. z-acc to analog pin 4
int gyroPin = 3; //pin 3 is analog balance gyro input pin. Y-rate to analog
pin 3
int steergyroPin = 2; //steergyro analog input pin 2. x-rate to analog pin
2. This gyro allows software to "resist" sudden turns (i.e. when one wheel
hits small object)
//I have just used the low res output from this gyro.
//int overallgainPin = 1; //overall gain analog pin 1. Gain knob to analog
pin 1
int hiresgyroPin = 0; //hi res balance gyro input is analog pin 0. Y-rate
4.5 to analog pin 0
//The IMU has a low res and a high res output for each gyro. Low res one
used by software when tipping over fast and higher res one when tipping
gently.
//digital inputs
int deadmanbuttonPin = 9; // deadman button is digital input pin 9
int balancepointleftPin = 7; //if digital pin 7 is 5V then reduce
balancepoint variable. Allows manual fine tune of the ideal target balance
point
int balancepointrightPin = 6; //if digital pin 6 is 5V then increase
balancepoint variable. Allows manual fine tune of the ideal target balance
point
int steeringvariableleftPin = 5; //digital pin5 Used to steer
int steeringvariablerightPin = 4; //digital pin 4 Used to steer the other
way.
//digital outputs
int oscilloscopePin = 8; //oscilloscope pin is digital pin 8 so you can
work out the program loop time (currently about 5.5millisec)
void setup() // run once, when the sketch starts
{
initSabertooth( );
//analogINPUTS
pinMode(accelPin, INPUT);
pinMode(gyroPin, INPUT);
pinMode(steergyroPin, INPUT);
//pinMode(overallgainPin, INPUT);
pinMode(hiresgyroPin, INPUT);
4. //digital inputs
pinMode(deadmanbuttonPin, INPUT);
pinMode(balancepointleftPin, INPUT);
pinMode(balancepointrightPin, INPUT);
pinMode(steeringvariableleftPin, INPUT);
pinMode(steeringvariablerightPin, INPUT);
//digital outputs
pinMode(oscilloscopePin, OUTPUT);
//Serial.begin(9600); // HARD wired Serial feedback to PC for
debugging in Wiring
}
void sample_inputs() {
gyrosum = 0;
steersum = 0;
hiresgyrosum = 0;
accraw = analogRead(accelPin); //read the accelerometer pin (0-1023)
//Take a set of 7 readings very fast
for (j=0; j<7; j++) {
adc1 = analogRead(gyroPin);
adc4 = analogRead(steergyroPin);
adc5 = analogRead(hiresgyroPin);
gyrosum = (float) gyrosum + adc1; //sum of the 7 readings
steersum = (float) steersum + adc4; //sum of the 7 readings
hiresgyrosum = (float)hiresgyrosum +adc5; //sum of the 7 readings
}
//k1 = analogRead(overallgainPin);
k2 = digitalRead(steeringvariableleftPin);
k3 = digitalRead(steeringvariablerightPin);
k4 = digitalRead(deadmanbuttonPin);
overallgain = 0.5;
balleft = digitalRead(balancepointleftPin);
balright = digitalRead(balancepointrightPin);
if (balleft == 1) balancetrim = balancetrim - 0.04; //if pressing balance
point adjust switch then slowly alter the balancetrim variable by 0.04 per
loop of the program
//while you are pressing the switch
5. if (balright == 1) balancetrim = balancetrim + 0.04; //same again in
other direction
if (balancetrim < -30) balancetrim = -30; //stops you going too far with
this
if (balancetrim > 30) balancetrim = 30; //stops you going too far the
other way
// Savitsky Golay filter for accelerometer readings. It is better than a
simple rolling average which is always out of date.
// SG filter looks at trend of last few readings, projects a curve into
the future, then takes mean of whole lot, giving you a more "current" value
- Neat!
// Lots of theory on this on net.
a0 = a1;
a1 = a2;
a2 = a3;
a3 = a4;
a4 = a5;
a5 = a6;
a6 = (float) accraw;
accsum = (float) ((-2*a0) + (3*a1) + (6*a2) + (7*a3) + (6*a4) + (3*a5) +
(-2*a6))/21;
//accsum isnt really a "sum" (it used to be once),
//now it is the accelerometer value from the rolling SG filter on the 0-
1023 scale
digitalWrite(oscilloscopePin, HIGH); //puts out signal to oscilloscope
//****COMMENT THIS STEERING SECTION OUT IF YOU DONT WANT ANY STEERING
FUNCTIONS TO BEGIN WITH. JUST KEEP THE COMMAND: SteerValue=512; and add a
command: SteerCorrect = 0;
//****COMMENT THIS STEERING SECTION OUT IF YOU DONT WANT ANY STEERING
FUNCTIONS TO BEGIN WITH. JUST KEEP THE COMMAND: SteerValue=512; and add a
command: SteerCorrect = 0;
//****COMMENT THIS STEERING SECTION OUT IF YOU DONT WANT ANY STEERING
FUNCTIONS TO BEGIN WITH. JUST KEEP THE COMMAND: SteerValue=512; and add a
command: SteerCorrect = 0;
//****COMMENT THIS STEERING SECTION OUT IF YOU DONT WANT ANY STEERING
FUNCTIONS TO BEGIN WITH. JUST KEEP THE COMMAND: SteerValue=512; and add a
command: SteerCorrect = 0;
gangleratedeg2 = (float) ((steersum/7) - s) * 2.44; //divide by 0.41 as
for low resolution balance gyro i.e. multiply by 2.44
// NO steering wanted. Use second gyro to maintain a (roughly) straight
line heading (it will drift a bit).
if (k2 == 0 && k3 == 0) {
//gangleratedeg2 = (float) ((steersum/7) - s) * 2.44;
//divide by 0.41 as for low resolution balance gyro i.e. multiply by 2.44
SteerCorrect = 0; //blocks the direction stabiliser unless
rate of turn exceeds -10 or +10 degrees per sec
if (gangleratedeg2 > 10 || gangleratedeg2 < -10) { //resists
turning if turn rate exceeds 10deg per sec
6. SteerCorrect = (float) 0.4 * gangleratedeg2;
//vary the 0.4 according to how much "resistance" to being nudged off
course you want.
//a value called SteerCorrect is added to the
steering value proportional to the rate of unwanted turning. It keeps
getting
//larger if this condition is till being satisfied
i.e. still turning >10deg per sec until the change has been resisted.
//can experiment with the value of 10. Try 5 deg
per sec if you want - play around - this can probably be improved
//but if you try to turn it fast with your hand
while balancing you will feel it resisting you so it does work
//also, when coming to a stop, one motor has a bit
more friction than the other so as this motor stops first then as board
//comes to standstill it spins round and you can
fall off. This is original reason I built in this feature.
//if motors have same friction you will not notice
it so much.
}
//Serial.println(gangleratedeg2); //for debugging
//delay(50);
SteerValue = 512;
}
else {
//i.e. we DO want to steer
//steer one way SteerValue of 512 is straight ahead
if (k2 == 1) {
if (gangleratedeg2 < 8) { //will turn clockwise at 8
degrees per sec and if not, more power fed into steering until it does
SteerValue = SteerValue + 1;
}
if (gangleratedeg2 > 8) {
SteerValue = SteerValue - 1;
}
}
//change the 5 and -5 values if you want faster turn rates. Could use a
potentiometer to control these values so would have proportional control of
steering
//steer the other way
if (k3 == 1) {
if (gangleratedeg2 < -8) { //will turn anticlockwise at 8
degrees per sec and if not, more power fed into steering until it does
SteerValue = SteerValue + 1;
}
if (gangleratedeg2 > -8) {
SteerValue = SteerValue - 1;
}
}
if (SteerValue < 1) {
SteerValue = 1;
}
if (SteerValue > 1023) {
SteerValue = 1023;
7. }
SteerCorrect = 0;
}
//*****END OF STEERING SECTION
//*****END OF STEERING SECTION
//*****END OF STEERING SECTION
//*****END OF STEERING SECTION
/*
//for debugging. NOTE: when debugging with serial print commands to your
PC the cycle time of program will slow down beyond the 5.5ms it is set up
for and the
//angle values etc can turn into nonsense even if there is nothing wrong
with your code otherwise
Serial.print(k1);
Serial.print(" ");
Serial.print(k2);
Serial.print(" ");
Serial.print(k3);
Serial.print(" ");
Serial.print(k4);
Serial.print(" ");
Serial.print(balleft);
Serial.print(" ");
Serial.print(balright);
Serial.println(" ");
*/
//ACCELEROMETER notes for the 5 d of f Sparfun IMU I have used in my
Instructable:
//300mV (0.3V) per G i.e. at 90 degree angle
//Supply 3.3V is OK from Arduino NOT the 5V supply. Modern Arduinos have a
3.3V power out for small peripherals like this.
//Midpoint is 1.58 Volts when supply to IMU is 3.3V i.e. 323 on the 0-1024
scale when read from a 0-5V Arduino analog input pin
//not the 512 we are all perhaps more used to with 5V powered accel and
gyro systems.
//testing with voltmeter over 0-30 degree tilt range shows about 5.666mV
per degree. Note: Should use the Sin to get angle i.e. trigonometry, but
over our small
//tilt angles (0-30deg from the vertical) the raw value is very similar to
the Sin so we dont bother calculating it.
// 1mv is 1024/5000 = 0.2048 steps on the 0-1023 scale so 5.666mV is 1.16
steps on the 0-1023 scale
8. //THE VALUE OF 350 BELOW NEEDS TO BE VARIED BY TRIAL AND ERROR UNTIL
MACHINE BALANCES EXACTLY LEVEL AS TIPSTART TAKES EFFECT
x_accdeg = (float)((accsum - (350 + balancetrim))*0.862); //approx 1.16
steps per degree so divide by 1.16 i.e. multiply by 0.862
if (x_accdeg < -72) x_accdeg = -72; //rejects silly values to stop it
going berserk!
if (x_accdeg > 72) x_accdeg = 72;
/*
//for debugging
Serial.print("accsum = ");
Serial.println(accsum);
Serial.print("balancetrim = ");
Serial.println(balancetrim);
Serial.print("x_accdeg = ");
Serial.println(x_accdeg);
*/
//GYRO NOTES:
//Low resolution gyro output: 2mV per degree per sec up to 500deg per sec.
5V = 1024 units on 0-1023 scale, 1Volt = 204.8 units on this scale.
//2mV = 0.41 units = 1deg per sec
// Hi res gyro output pin(from the same gyro): 9.1mV per degree per sec up
to 110deg per sec on hires input. 5V = 1024 units on 0-1023 scale, 1Volt =
204.8 units on this scale.
//9.1mV = 1.86 units = 1 deg per sec
//Low res gyro rate of tipping reading calculated first
gangleratedeg = (float)(((gyrosum/7) - g)*2.44); //divide by 0.41 for low
res balance gyro i.e. multiply by 2.44
if (gangleratedeg < -450) gangleratedeg = -450; //stops crazy values
entering rest of the program
if (gangleratedeg > 450) gangleratedeg = 450;
//debugging relic
//Serial.print("gangleratedeg1 = ");
//Serial.println(gangleratedeg);
//..BUT...Hi res gyro ideally used to re-calculate the rate of tipping in
degrees per sec, i.e. use to calculate gangleratedeg IF rate is less than
100 deg per sec
if (gangleratedeg < 100 && gangleratedeg > -100) {
gangleratedeg = (float)(((hiresgyrosum/7) - t)*0.538); //divide by
1.86 i.e. multiply by 0.538
if (gangleratedeg < -110) gangleratedeg = -110;
if (gangleratedeg > 110) gangleratedeg = 110;
}
//debugging relic
//Serial.print("gangleratedeg2 = ");
//Serial.println(gangleratedeg);
digitalWrite(oscilloscopePin, LOW); //cuts signal to oscilloscope pin so
we have one pulse on scope per cycle of the program so we can work out
cycle time.
9. //Key calculations. Gyro measures rate of tilt gangleratedeg in degrees.
We know time since last measurement is cycle_time (5.5ms) so can work out
much we have tipped over since last measurement
//What is ti variable? Strictly it should be 1. However if you tilt
board, then it moves along at an angle, then SLOWLY comes back to level
point as it is moving along
//this suggests the gyro is slightly underestimating the rate of tilt and
the accelerometer is correcting it (slowly as it is meant to).
//This is why, by trial and error, I have increased ti to 1.2 at start of
program where I define my variables.
//experiment with this variable and see how it behaves. Temporarily
reconfigure the overallgain potentiometer as an input to change ti and
experiment with this variable
//potentiometer is useful for this sort of experiment. You can alter any
variable on the fly by temporarily using the potentiometer to adjust it and
see what effect it has
gyroangledt = (float) ti * cycle_time * gangleratedeg;
//x_accdeg = x_accdeg * (-1);
gangleraterads = (float) gangleratedeg * 0.017453; //convert to radians -
just a scaling issue from history
angle = (float) ((1-aa) * (angle + gyroangledt)) - (aa * x_accdeg);//aa
allows us to feed a bit (0.5%) of the accelerometer data into the angle
calculation
//so it slowly corrects the gyro (which drifts slowly with tinme
remember). Accel sensitive to vibration though so aa does not want to be
too large.
//this is why these boards do not work if an accel only is used. We use
gyro to do short term tilt measurements because it is insensitive to
vibration
//the video on my instructable shows the skateboard working fine over a
brick cobbled surface - vibration +++ !
anglerads = (float) angle * 0.017453; //converting to radians again a
historic scaling issue from past software
//debugging
//Serial.print("Angle = ");
//Serial.println(angle);
balance_torque = (float) (4.5 * anglerads) + (0.5 * gangleraterads);
//power to motors (will be adjusted for each motor later to create any
steering effects
//balance torque is motor control variable we would use even if we just
ahd one motor. It is what is required to make the thing balance only.
//the values of 4.5 and 0.5 came from Trevor Blackwell's segway clone
experiments and were derived by good old trial and error
//I have also found them to be about right
//We set the torque proportionally to the actual angle of tilt
(anglerads), and also proportional to the RATE of tipping over (ganglerate
rads)
//the 4.5 and the 0.5 set the amount of each we use - play around with
them if you want.
//Much more on all this, PID controlo etc on my website
cur_speed = (float) (cur_speed + (anglerads * 6 * cycle_time)) * 0.999;
//this is not current speed. We do not know actual speed as we have no
wheel rotation encoders. This is a type of accelerator pedal effect:
//this variable increases with each loop of the program IF board is
deliberately held at an angle (by rider for example)
//So it means "if we are STILL tilted, speed up a bit" and it keeps
accelerating as long as you hold it tilted.
10. //You do NOT need this to just balance, but to go up a slight incline for
example you would need it: if board hits incline and then stops - if you
hold it
//tilted for long eneough, it will eventually go up the slope (so long as
motors powerfull enough and motor controller powerful enough)
//Why the 0.999 value? I got this from the SeWii project code - thanks!
//If you have built up a large cur_speed value and you tilt it back to
come to a standstill, you will have to keep it tilted back even when you
have come to rest
//i.e. board will stop moving OK but will now not be level as you are
tiliting it back other way to counteract this large cur_speed value
//The 0.999 means that if you bring board level after a long period
tilted forwards, the cur_speed value magically decays away to nothing and
your board
//is now not only stationary but also level!
level = (float)(balance_torque + cur_speed) * overallgain;
//level = (float)balance_torque * overallgain; //You can omit cur speed
term during testing while just getting it to initially balance if you want
to
//avoids confusion
}
void set_motor() {
unsigned char cSpeedVal_Motor1 = 0;
unsigned char cSpeedVal_Motor2 = 0;
level = level * 200; //changes it to a scale of about -100 to +100
//debugging
//Serial.print("level on -100 to +100 scale = ");
//Serial.println(level);
Steer = (float) SteerValue - SteerCorrect; //at this point is on the 0-
1023 scale
//SteerValue is either 512 for dead ahead or bigger/smaller if you are
pressing steering switch left or right
//SteerCorrect is the "adjustment" made by the second gyro that resists
sudden turns if one wheel hits a small object for example.
Steer = (Steer - 512) * 0.19; //gets it down from 0-1023 (with 512 as
the middle no-steer point) to -100 to +100 with 0 as the middle no-steer
point on scale
//debugging
//Serial.print("Steer on -100 to +100 scale is= ");
//Serial.println(Steer);
//set motors using the simplified serial Sabertooth protocol (same for
smaller 2 x 5 Watt Sabertooth by the way)
Motor1percent = (signed char) level + Steer;
Motor2percent = (signed char) level - Steer;
if (Motor1percent > 100) Motor1percent = 100;
12. //Tilt board one end on floor. Turn it on. This 200 loop creates a delay
while you finish turning it on and let go i.e. stop wobbling it about
//as now the software will read the gyro values when there is no
rotational movement to find the zero point for each gyro. I could have used
a simple delay command.
for (i=0; i<200; i++) {
sample_inputs();
}
//now you have stepped away from baord having turned it on, we get 7
readings from each gyro (and a hires reading from the balance gyro)
g = (float) gyrosum/7; //gyro balance value when stationary i.e. 1.35V
s = (float) steersum/7; //steer gyro value when stationary i.e. about
1.32V
t = (float) hiresgyrosum/7; //hiresgyro balance output when stationary
i.e. about 1.38V
//we divide sum of the 7 readings by 7 to get mean for each
//tiltstart routine now comes in. It is reading the angle from
accelerometer. When you first tilt the board past the level point
//the self balancing algorithm will go "live". If it did not have this, it
would fly across the room as you turned it on (tilted)!
while (tipstart < 5) {
for (i=0; i<10; i++) {
sample_inputs();
}
//x_accdeg is tilt angle from accelerometer in degrees
if (x_accdeg < -12 || x_accdeg > -2) {
//*****ADJUST THESE LIMITS TO SUIT YOUR BOARD SO TILTSTART
KICKS IN WHERE YOU WANT IT TO*******
//MY IMU IS NOT QUITE VERTICALLY MOUNTED
tipstart = 0;
overallgain = 0;
cur_speed = 0;
level = 0;
Steer = 0;
balancetrim = 0;
}
else {
tipstart = 5;
}
}
overallgain = 0.5;
angle = 0;
cur_speed = 0;
Steering = 512;
SteerValue = 512;
balancetrim = 0;
//end of tiltstart code. If go beyond this point then machine is active
//main balance routine, just loops forever. Machine is just trying to stay
level. You "trick" it into moving by tilting one end down
13. //works best if keep legs stiff so you are more rigid like a broom handle
is if you are balancing it vertically on end of your finger
//if you are all wobbly, the board will go crazy trying to correct your own
flexibility.
//NB: This is why a segway has to have vertical handlebar otherwise ankle
joint flexibility in fore-aft direction would make it oscillate wildly.
//NB: This is why the handlebar-less version of Toyota Winglet still has a
vertical section you jam between your knees.
while (1) {
sample_inputs();
set_motor();
}
}