SlideShare ist ein Scribd-Unternehmen logo
1 von 5
//TWIN WHEELER MODIFIED FOR ARDUINO SIMPLIFIED SERIAL PROTOCOL TO
SABERTOOTH V2
//**********THIS VERSION JUST TESTS COMMUNICATION BETWEEN ARDUINO AND
SABERTOOTH AND MOTORS PLUS DEADMAN SWITCH****************
//*********** DEADMAN SWITCH MUST BE PRESSED IN, MOTORS WILL STOP IF
RELEASED **********************
//MOTORS WILL INCREASE IN SPEED BY 10% EVERY 5 SECONDS UNTIL 50% OF FULL
POWER IS REACHED
//THEY WILL THEN GO DOWN TO ZERO IN STEPS OF 10%.
//BOTH WHEELS SHOULD BE SPINNING IN SAME DIRECTION AT THE SAME SPEED AT ALL
TIMES ELSE YOU WILL HAVE WIRED ONE MOTOR UP BACK TO FRONT
//SABERTOOTH MUST HAVE DIP SWITCHES SET TO THE SERIAL MODE:i.e. DIP
switches 1, 3, 5 and 6 set to ON, the remainder set to OFF
//IMU NOT CONNECTED AT THIS POINT (CAN BE PHYSICALLY CONNECTED IF YOU LIKE
BUT ARDUINO WILL NOT BE READING IT AT ALL)
//ONLY THING YOU NEED IS DEAD MAN SWITCH TO DIGITAL PIN 9 (+5V TO PIN 9
WHEN SWITCH PRESSED, PULL DOWN RESISTOR FROM PIN 9 TO GND KEEPS IT AT 0V
OTHERWISE)
//J. Dingley March 1 2011 For Arduino 328 Duemalinove or similar with a
3.3V accessory power output
//i.e. the current standard Arduino board.
#include <SoftwareSerial.h>
//******************** IMPORTANT ***************************
//Set dip switches on the Sabertooth for simplified serial and 9600
Buadrate. Diagram of this on my Instructables page//
//i.e. DIP switches 1, 3, 5 and 6 set to ON, the remainder set to OFF
//******************** IMPORTANT ***************************
//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
}
float level = 0;
int u;
//float k1;
//int k2;
//int k3;
int k4;
signed char Motor1percent;
signed char Motor2percent;
//DIGITAL INPUT
int deadmanbuttonPin = 9; // deadman button is digital input pin 9
void setup() // run once, when the sketch starts
{
initSabertooth( );
//analogINPUTS
//digital inputs
pinMode(deadmanbuttonPin, INPUT);
Serial.begin(9600); // HARD wired Serial feedback to PC for
debugging in Wiring
}
void sample_inputs() {
k4 = digitalRead(deadmanbuttonPin); //this is needed - if you let go the
motors both stop for your own safety
}
void set_motor() {
unsigned char cSpeedVal_Motor1 = 0;
unsigned char cSpeedVal_Motor2 = 0;
//set motors using the simplified serial Sabertooth protocol (same for
smaller 2 x 5 Watt Sabertooth by the way)
Motor1percent = (signed char) level;
Motor2percent = (signed char) level;
Serial.print("level ");
Serial.println(level);
if (Motor1percent > 100) Motor1percent = 100;
if (Motor1percent < -100) Motor1percent = -100;
if (Motor2percent > 100) Motor2percent = 100;
if (Motor2percent < -100) Motor2percent = -100;
//if not pressing deadman button on hand controller - cut everything
if (k4 < 1) {
level = 0;
Motor1percent = 0;
Motor2percent = 0;
Serial.println("Pressing Dead Man Button");
delay(1000);
}
cSpeedVal_Motor1 = map (Motor1percent,
-100,
100,
SABER_MOTOR1_FULL_REVERSE,
SABER_MOTOR1_FULL_FORWARD);
cSpeedVal_Motor2 = map (Motor2percent,
-100,
100,
SABER_MOTOR2_FULL_REVERSE,
SABER_MOTOR2_FULL_FORWARD);
SaberSerial.print (cSpeedVal_Motor1, BYTE);
SaberSerial.print (cSpeedVal_Motor2, BYTE);
/*
//debugging
Serial.print("Motor1percent = ");
Serial.print(Motor1percent);
Serial.print (" level = ");
Serial.println (level);
Serial.print("Motor2percent = ");
Serial.println(Motor2percent);
Serial.print("cSpeedVal_Motor1 = ");
Serial.println(cSpeedVal_Motor1);
Serial.print("cSpeedVal_Motor2 = ");
Serial.println(cSpeedVal_Motor2);
*/
delay(5000); //5 second delay
}
void loop () {
for (u=0; u<5; u++) {
level= u * 10; //level = 0 then 10, then 20 until it gets to 50% of max
motor power. each set motor routine has 5 sec delay at end of it
sample_inputs(); //check the dead man button still pressed in
set_motor();
}
for (u=0; u<5; u++) {
level= (5- u) * 10; //level = 50 then 40, then 30 then 20 until it gets
to 0% of max motor power. each set motor routine has 5 sec delay at end of
it
sample_inputs();//check the dead man button still pressed in
set_motor();
}
}

Weitere ähnliche Inhalte

Was ist angesagt?

Cisco 2960 basic configuration – vlan configuration
Cisco 2960 basic configuration – vlan configurationCisco 2960 basic configuration – vlan configuration
Cisco 2960 basic configuration – vlan configuration3Anetwork com
 
How to create and delete vlan on cisco catalyst switch
How to create and delete vlan on cisco catalyst switchHow to create and delete vlan on cisco catalyst switch
How to create and delete vlan on cisco catalyst switchIT Tech
 
Configuring the cisco switch with the cli based setup program
Configuring the cisco switch with the cli based setup programConfiguring the cisco switch with the cli based setup program
Configuring the cisco switch with the cli based setup program3Anetwork com
 
How to obtain ip address from a different network dhcp
How to obtain ip address from a different network dhcpHow to obtain ip address from a different network dhcp
How to obtain ip address from a different network dhcptcpipguru
 
Trik singkat STATIC ROUTING via cli Packet Tracer
Trik singkat STATIC ROUTING via cli Packet Tracer Trik singkat STATIC ROUTING via cli Packet Tracer
Trik singkat STATIC ROUTING via cli Packet Tracer Selamet Hariadi
 
Mac address-table static
Mac address-table staticMac address-table static
Mac address-table statictcpipguru
 
PBR-LB - Direct Server Return Load Balancing using Policy Based Routing (MEMO)
PBR-LB - Direct Server Return Load Balancing using Policy Based Routing (MEMO)PBR-LB - Direct Server Return Load Balancing using Policy Based Routing (MEMO)
PBR-LB - Direct Server Return Load Balancing using Policy Based Routing (MEMO)Naoto MATSUMOTO
 
Basic Switch Configurations
Basic Switch ConfigurationsBasic Switch Configurations
Basic Switch ConfigurationsNicholas Shell
 
How to configure port security in cisco switch
How to configure port security in cisco switchHow to configure port security in cisco switch
How to configure port security in cisco switchIT Tech
 
Catalog mikro mikro mk233a-user-dienhathe.vn
Catalog mikro mikro mk233a-user-dienhathe.vnCatalog mikro mikro mk233a-user-dienhathe.vn
Catalog mikro mikro mk233a-user-dienhathe.vnDien Ha The
 

Was ist angesagt? (15)

Cisco 2960 basic configuration – vlan configuration
Cisco 2960 basic configuration – vlan configurationCisco 2960 basic configuration – vlan configuration
Cisco 2960 basic configuration – vlan configuration
 
How to create and delete vlan on cisco catalyst switch
How to create and delete vlan on cisco catalyst switchHow to create and delete vlan on cisco catalyst switch
How to create and delete vlan on cisco catalyst switch
 
Configuring the cisco switch with the cli based setup program
Configuring the cisco switch with the cli based setup programConfiguring the cisco switch with the cli based setup program
Configuring the cisco switch with the cli based setup program
 
1
11
1
 
How to obtain ip address from a different network dhcp
How to obtain ip address from a different network dhcpHow to obtain ip address from a different network dhcp
How to obtain ip address from a different network dhcp
 
Ssr 303 user manual
Ssr 303 user manualSsr 303 user manual
Ssr 303 user manual
 
Rack
RackRack
Rack
 
Trik singkat STATIC ROUTING via cli Packet Tracer
Trik singkat STATIC ROUTING via cli Packet Tracer Trik singkat STATIC ROUTING via cli Packet Tracer
Trik singkat STATIC ROUTING via cli Packet Tracer
 
Mac address-table static
Mac address-table staticMac address-table static
Mac address-table static
 
4010069 e
4010069 e4010069 e
4010069 e
 
PBR-LB - Direct Server Return Load Balancing using Policy Based Routing (MEMO)
PBR-LB - Direct Server Return Load Balancing using Policy Based Routing (MEMO)PBR-LB - Direct Server Return Load Balancing using Policy Based Routing (MEMO)
PBR-LB - Direct Server Return Load Balancing using Policy Based Routing (MEMO)
 
Basic Switch Configurations
Basic Switch ConfigurationsBasic Switch Configurations
Basic Switch Configurations
 
How to configure port security in cisco switch
How to configure port security in cisco switchHow to configure port security in cisco switch
How to configure port security in cisco switch
 
53340 0420 gs5_gs501_rca-30k
53340 0420 gs5_gs501_rca-30k53340 0420 gs5_gs501_rca-30k
53340 0420 gs5_gs501_rca-30k
 
Catalog mikro mikro mk233a-user-dienhathe.vn
Catalog mikro mikro mk233a-user-dienhathe.vnCatalog mikro mikro mk233a-user-dienhathe.vn
Catalog mikro mikro mk233a-user-dienhathe.vn
 

Ähnlich wie Twin wheeler modified for arduino simplified serial protocol to sabertooth v2

Twin wheeler modified for arduino simplified serial protocol to sabertooth v22
Twin wheeler modified for arduino simplified serial protocol to sabertooth v22Twin wheeler modified for arduino simplified serial protocol to sabertooth v22
Twin wheeler modified for arduino simplified serial protocol to sabertooth v22josnihmurni2907
 
Twin wheeler modified for arduino simplified serial protocol to sabertooth v21
Twin wheeler modified for arduino simplified serial protocol to sabertooth v21Twin wheeler modified for arduino simplified serial protocol to sabertooth v21
Twin wheeler modified for arduino simplified serial protocol to sabertooth v21josnihmurni2907
 
GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
 GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdfalltiusind
 
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009Eoin Brazil
 
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009Eoin Brazil
 
Mdp plus 2.1
Mdp plus 2.1Mdp plus 2.1
Mdp plus 2.1boedax
 
MaxBotix Code Examples
MaxBotix Code ExamplesMaxBotix Code Examples
MaxBotix Code ExamplesMaxBotix Inc
 
GSM GPRS SIM900A Modem
GSM GPRS SIM900A ModemGSM GPRS SIM900A Modem
GSM GPRS SIM900A ModemRaghav Shetty
 
Program, Code of Program and Screen Shot of Output (UNIVERSAL DRIVER USING µ...
Program, Code of Program and  Screen Shot of Output (UNIVERSAL DRIVER USING µ...Program, Code of Program and  Screen Shot of Output (UNIVERSAL DRIVER USING µ...
Program, Code of Program and Screen Shot of Output (UNIVERSAL DRIVER USING µ...Er. Ashish Pandey
 
AVR_GENERAL KOSTI.ppt
AVR_GENERAL KOSTI.pptAVR_GENERAL KOSTI.ppt
AVR_GENERAL KOSTI.pptprasadkappala
 
How to configure cisco 6500 vss
How to configure cisco 6500 vssHow to configure cisco 6500 vss
How to configure cisco 6500 vssIT Tech
 
Musical Machines and Flapping Phones
Musical Machines and Flapping PhonesMusical Machines and Flapping Phones
Musical Machines and Flapping PhonesNeil Mendoza
 
Applied motion products si5580 datasheet
Applied motion products si5580 datasheetApplied motion products si5580 datasheet
Applied motion products si5580 datasheetElectromate
 
GSM GPRS sim900 a modem with stub antenna and sma connector-USB
GSM GPRS sim900 a modem with stub antenna and sma connector-USBGSM GPRS sim900 a modem with stub antenna and sma connector-USB
GSM GPRS sim900 a modem with stub antenna and sma connector-USBRaghav Shetty
 
PowerMate15 Technical Specification
PowerMate15 Technical SpecificationPowerMate15 Technical Specification
PowerMate15 Technical SpecificationRimsky Cheng
 
GSM GPRS SIM900A Module with Stub Antenna and SMA Connector
GSM GPRS SIM900A Module with Stub Antenna and SMA ConnectorGSM GPRS SIM900A Module with Stub Antenna and SMA Connector
GSM GPRS SIM900A Module with Stub Antenna and SMA ConnectorRaghav Shetty
 

Ähnlich wie Twin wheeler modified for arduino simplified serial protocol to sabertooth v2 (20)

Twin wheeler modified for arduino simplified serial protocol to sabertooth v22
Twin wheeler modified for arduino simplified serial protocol to sabertooth v22Twin wheeler modified for arduino simplified serial protocol to sabertooth v22
Twin wheeler modified for arduino simplified serial protocol to sabertooth v22
 
Twin wheeler modified for arduino simplified serial protocol to sabertooth v21
Twin wheeler modified for arduino simplified serial protocol to sabertooth v21Twin wheeler modified for arduino simplified serial protocol to sabertooth v21
Twin wheeler modified for arduino simplified serial protocol to sabertooth v21
 
GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
 GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
GENESIS BOARD MINI SUMO ROBOT PROGRAMFOR 3 OPPONENT SENSOR, .pdf
 
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
 
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
Arduino Lecture 3 - Interactive Media CS4062 Semester 2 2009
 
Mdp plus 2.1
Mdp plus 2.1Mdp plus 2.1
Mdp plus 2.1
 
Fadal Spindle Drive and Motor Manual
Fadal Spindle Drive and Motor ManualFadal Spindle Drive and Motor Manual
Fadal Spindle Drive and Motor Manual
 
MaxBotix Code Examples
MaxBotix Code ExamplesMaxBotix Code Examples
MaxBotix Code Examples
 
GSM GPRS SIM900A Modem
GSM GPRS SIM900A ModemGSM GPRS SIM900A Modem
GSM GPRS SIM900A Modem
 
Program, Code of Program and Screen Shot of Output (UNIVERSAL DRIVER USING µ...
Program, Code of Program and  Screen Shot of Output (UNIVERSAL DRIVER USING µ...Program, Code of Program and  Screen Shot of Output (UNIVERSAL DRIVER USING µ...
Program, Code of Program and Screen Shot of Output (UNIVERSAL DRIVER USING µ...
 
AVR_GENERAL KOSTI.ppt
AVR_GENERAL KOSTI.pptAVR_GENERAL KOSTI.ppt
AVR_GENERAL KOSTI.ppt
 
Afd Control
Afd ControlAfd Control
Afd Control
 
How to configure cisco 6500 vss
How to configure cisco 6500 vssHow to configure cisco 6500 vss
How to configure cisco 6500 vss
 
Musical Machines and Flapping Phones
Musical Machines and Flapping PhonesMusical Machines and Flapping Phones
Musical Machines and Flapping Phones
 
Applied motion products si5580 datasheet
Applied motion products si5580 datasheetApplied motion products si5580 datasheet
Applied motion products si5580 datasheet
 
BLD-AC1000S.pdf
BLD-AC1000S.pdfBLD-AC1000S.pdf
BLD-AC1000S.pdf
 
GSM GPRS sim900 a modem with stub antenna and sma connector-USB
GSM GPRS sim900 a modem with stub antenna and sma connector-USBGSM GPRS sim900 a modem with stub antenna and sma connector-USB
GSM GPRS sim900 a modem with stub antenna and sma connector-USB
 
Lampiran 1.programdocx
Lampiran 1.programdocxLampiran 1.programdocx
Lampiran 1.programdocx
 
PowerMate15 Technical Specification
PowerMate15 Technical SpecificationPowerMate15 Technical Specification
PowerMate15 Technical Specification
 
GSM GPRS SIM900A Module with Stub Antenna and SMA Connector
GSM GPRS SIM900A Module with Stub Antenna and SMA ConnectorGSM GPRS SIM900A Module with Stub Antenna and SMA Connector
GSM GPRS SIM900A Module with Stub Antenna and SMA Connector
 

Mehr von josnihmurni2907

Simple timer code for arduino
Simple timer code for arduinoSimple timer code for arduino
Simple timer code for arduinojosnihmurni2907
 
How to write timings and delays
How to write timings and delaysHow to write timings and delays
How to write timings and delaysjosnihmurni2907
 
Call and message using arduino and gsm module
Call and message using arduino and gsm moduleCall and message using arduino and gsm module
Call and message using arduino and gsm modulejosnihmurni2907
 
140813560 nota-kimia-tingkatan-4
140813560 nota-kimia-tingkatan-4140813560 nota-kimia-tingkatan-4
140813560 nota-kimia-tingkatan-4josnihmurni2907
 
132944997 rancangan-tahunan-mm-t5-2013
132944997 rancangan-tahunan-mm-t5-2013132944997 rancangan-tahunan-mm-t5-2013
132944997 rancangan-tahunan-mm-t5-2013josnihmurni2907
 
Agihan kertas 1 dan kertas 2
Agihan kertas 1 dan kertas 2Agihan kertas 1 dan kertas 2
Agihan kertas 1 dan kertas 2josnihmurni2907
 
Cara menghilangkan rasa ngantuk di kelas
Cara menghilangkan rasa ngantuk di kelasCara menghilangkan rasa ngantuk di kelas
Cara menghilangkan rasa ngantuk di kelasjosnihmurni2907
 
Bercakap mengenai nikmat allah s
Bercakap mengenai nikmat allah sBercakap mengenai nikmat allah s
Bercakap mengenai nikmat allah sjosnihmurni2907
 
Bandar purba dalam tasik di china
Bandar purba dalam tasik di chinaBandar purba dalam tasik di china
Bandar purba dalam tasik di chinajosnihmurni2907
 
12 kaum yang telah allah swt binasakan
12 kaum yang telah allah swt binasakan12 kaum yang telah allah swt binasakan
12 kaum yang telah allah swt binasakanjosnihmurni2907
 

Mehr von josnihmurni2907 (19)

Simple timer code for arduino
Simple timer code for arduinoSimple timer code for arduino
Simple timer code for arduino
 
Michael kontopoulos
Michael kontopoulosMichael kontopoulos
Michael kontopoulos
 
Michael kontopoulo1s
Michael kontopoulo1sMichael kontopoulo1s
Michael kontopoulo1s
 
How to write timings and delays
How to write timings and delaysHow to write timings and delays
How to write timings and delays
 
Define ba1
Define ba1Define ba1
Define ba1
 
Define ba
Define baDefine ba
Define ba
 
Call and message using arduino and gsm module
Call and message using arduino and gsm moduleCall and message using arduino and gsm module
Call and message using arduino and gsm module
 
Arduino
ArduinoArduino
Arduino
 
Arduino 101
Arduino 101Arduino 101
Arduino 101
 
140813560 nota-kimia-tingkatan-4
140813560 nota-kimia-tingkatan-4140813560 nota-kimia-tingkatan-4
140813560 nota-kimia-tingkatan-4
 
1.funtions (1)
1.funtions (1)1.funtions (1)
1.funtions (1)
 
132944997 rancangan-tahunan-mm-t5-2013
132944997 rancangan-tahunan-mm-t5-2013132944997 rancangan-tahunan-mm-t5-2013
132944997 rancangan-tahunan-mm-t5-2013
 
Agihan kertas 1 dan kertas 2
Agihan kertas 1 dan kertas 2Agihan kertas 1 dan kertas 2
Agihan kertas 1 dan kertas 2
 
Ciri pemimpin
Ciri pemimpinCiri pemimpin
Ciri pemimpin
 
Cara menghilangkan rasa ngantuk di kelas
Cara menghilangkan rasa ngantuk di kelasCara menghilangkan rasa ngantuk di kelas
Cara menghilangkan rasa ngantuk di kelas
 
Bercakap mengenai nikmat allah s
Bercakap mengenai nikmat allah sBercakap mengenai nikmat allah s
Bercakap mengenai nikmat allah s
 
Bandar purba dalam tasik di china
Bandar purba dalam tasik di chinaBandar purba dalam tasik di china
Bandar purba dalam tasik di china
 
12 kaum yang telah allah swt binasakan
12 kaum yang telah allah swt binasakan12 kaum yang telah allah swt binasakan
12 kaum yang telah allah swt binasakan
 
Smkts 2015 p1
Smkts 2015 p1Smkts 2015 p1
Smkts 2015 p1
 

Kürzlich hochgeladen

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 

Kürzlich hochgeladen (20)

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 

Twin wheeler modified for arduino simplified serial protocol to sabertooth v2

  • 1. //TWIN WHEELER MODIFIED FOR ARDUINO SIMPLIFIED SERIAL PROTOCOL TO SABERTOOTH V2 //**********THIS VERSION JUST TESTS COMMUNICATION BETWEEN ARDUINO AND SABERTOOTH AND MOTORS PLUS DEADMAN SWITCH**************** //*********** DEADMAN SWITCH MUST BE PRESSED IN, MOTORS WILL STOP IF RELEASED ********************** //MOTORS WILL INCREASE IN SPEED BY 10% EVERY 5 SECONDS UNTIL 50% OF FULL POWER IS REACHED //THEY WILL THEN GO DOWN TO ZERO IN STEPS OF 10%. //BOTH WHEELS SHOULD BE SPINNING IN SAME DIRECTION AT THE SAME SPEED AT ALL TIMES ELSE YOU WILL HAVE WIRED ONE MOTOR UP BACK TO FRONT //SABERTOOTH MUST HAVE DIP SWITCHES SET TO THE SERIAL MODE:i.e. DIP switches 1, 3, 5 and 6 set to ON, the remainder set to OFF //IMU NOT CONNECTED AT THIS POINT (CAN BE PHYSICALLY CONNECTED IF YOU LIKE BUT ARDUINO WILL NOT BE READING IT AT ALL) //ONLY THING YOU NEED IS DEAD MAN SWITCH TO DIGITAL PIN 9 (+5V TO PIN 9 WHEN SWITCH PRESSED, PULL DOWN RESISTOR FROM PIN 9 TO GND KEEPS IT AT 0V OTHERWISE) //J. Dingley March 1 2011 For Arduino 328 Duemalinove or similar with a 3.3V accessory power output //i.e. the current standard Arduino board. #include <SoftwareSerial.h> //******************** IMPORTANT *************************** //Set dip switches on the Sabertooth for simplified serial and 9600 Buadrate. Diagram of this on my Instructables page// //i.e. DIP switches 1, 3, 5 and 6 set to ON, the remainder set to OFF //******************** IMPORTANT *************************** //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
  • 2. #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 } float level = 0; int u; //float k1; //int k2; //int k3; int k4; signed char Motor1percent; signed char Motor2percent; //DIGITAL INPUT int deadmanbuttonPin = 9; // deadman button is digital input pin 9 void setup() // run once, when the sketch starts { initSabertooth( ); //analogINPUTS //digital inputs pinMode(deadmanbuttonPin, INPUT); Serial.begin(9600); // HARD wired Serial feedback to PC for debugging in Wiring }
  • 3. void sample_inputs() { k4 = digitalRead(deadmanbuttonPin); //this is needed - if you let go the motors both stop for your own safety } void set_motor() { unsigned char cSpeedVal_Motor1 = 0; unsigned char cSpeedVal_Motor2 = 0; //set motors using the simplified serial Sabertooth protocol (same for smaller 2 x 5 Watt Sabertooth by the way) Motor1percent = (signed char) level; Motor2percent = (signed char) level; Serial.print("level "); Serial.println(level); if (Motor1percent > 100) Motor1percent = 100; if (Motor1percent < -100) Motor1percent = -100; if (Motor2percent > 100) Motor2percent = 100; if (Motor2percent < -100) Motor2percent = -100; //if not pressing deadman button on hand controller - cut everything if (k4 < 1) { level = 0; Motor1percent = 0; Motor2percent = 0; Serial.println("Pressing Dead Man Button"); delay(1000); } cSpeedVal_Motor1 = map (Motor1percent, -100, 100, SABER_MOTOR1_FULL_REVERSE, SABER_MOTOR1_FULL_FORWARD); cSpeedVal_Motor2 = map (Motor2percent, -100, 100,
  • 4. SABER_MOTOR2_FULL_REVERSE, SABER_MOTOR2_FULL_FORWARD); SaberSerial.print (cSpeedVal_Motor1, BYTE); SaberSerial.print (cSpeedVal_Motor2, BYTE); /* //debugging Serial.print("Motor1percent = "); Serial.print(Motor1percent); Serial.print (" level = "); Serial.println (level); Serial.print("Motor2percent = "); Serial.println(Motor2percent); Serial.print("cSpeedVal_Motor1 = "); Serial.println(cSpeedVal_Motor1); Serial.print("cSpeedVal_Motor2 = "); Serial.println(cSpeedVal_Motor2); */ delay(5000); //5 second delay } void loop () { for (u=0; u<5; u++) { level= u * 10; //level = 0 then 10, then 20 until it gets to 50% of max motor power. each set motor routine has 5 sec delay at end of it sample_inputs(); //check the dead man button still pressed in set_motor(); } for (u=0; u<5; u++) { level= (5- u) * 10; //level = 50 then 40, then 30 then 20 until it gets to 0% of max motor power. each set motor routine has 5 sec delay at end of it sample_inputs();//check the dead man button still pressed in set_motor(); }
  • 5. }