SlideShare a Scribd company logo
//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();
}
}

More Related Content

What's hot

Cisco 2960 basic configuration – vlan configuration
Cisco 2960 basic configuration – vlan configurationCisco 2960 basic configuration – vlan configuration
Cisco 2960 basic configuration – vlan configuration
3Anetwork 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 switch
IT 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 program
3Anetwork com
 
1
11
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
tcpipguru
 
Ssr 303 user manual
Ssr 303 user manualSsr 303 user manual
Ssr 303 user manual
Domotica daVinci
 
Rack
RackRack
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 static
tcpipguru
 
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 Configurations
Nicholas 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 switch
IT Tech
 
53340 0420 gs5_gs501_rca-30k
53340 0420 gs5_gs501_rca-30k53340 0420 gs5_gs501_rca-30k
53340 0420 gs5_gs501_rca-30k
Accurate Pool & Spa Services, llc
 
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
Dien Ha The
 

What's hot (14)

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
 
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
 

Similar to 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 v22
josnihmurni2907
 
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
josnihmurni2907
 
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
alltiusind
 
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
Eoin 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 2009
Eoin Brazil
 
Fadal Spindle Drive and Motor Manual
Fadal Spindle Drive and Motor ManualFadal Spindle Drive and Motor Manual
Fadal Spindle Drive and Motor Manual
Independent Technology Service Inc
 
MaxBotix Code Examples
MaxBotix Code ExamplesMaxBotix Code Examples
MaxBotix Code Examples
MaxBotix Inc
 
GSM GPRS SIM900A Modem
GSM GPRS SIM900A ModemGSM GPRS SIM900A Modem
GSM GPRS SIM900A Modem
Raghav 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.ppt
prasadkappala
 
Afd Control
Afd ControlAfd Control
Afd Control
Najam Siddiqui
 
How to configure cisco 6500 vss
How to configure cisco 6500 vssHow to configure cisco 6500 vss
How to configure cisco 6500 vss
IT Tech
 
Musical Machines and Flapping Phones
Musical Machines and Flapping PhonesMusical Machines and Flapping Phones
Musical Machines and Flapping Phones
Neil Mendoza
 
Applied motion products si5580 datasheet
Applied motion products si5580 datasheetApplied motion products si5580 datasheet
Applied motion products si5580 datasheet
Electromate
 
BLD-AC1000S.pdf
BLD-AC1000S.pdfBLD-AC1000S.pdf
BLD-AC1000S.pdf
STEPPERONLINE
 
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
Raghav Shetty
 
Lampiran 1.programdocx
Lampiran 1.programdocxLampiran 1.programdocx
Lampiran 1.programdocx
Lugik kristiyanto
 
PowerMate15 Technical Specification
PowerMate15 Technical SpecificationPowerMate15 Technical Specification
PowerMate15 Technical Specification
Rimsky 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 Connector
Raghav Shetty
 
PROGRAMMING ADC and DAC-mbed.pdf
PROGRAMMING ADC and DAC-mbed.pdfPROGRAMMING ADC and DAC-mbed.pdf
PROGRAMMING ADC and DAC-mbed.pdf
vidhyalakshmi153619
 

Similar to 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
 
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
 
PROGRAMMING ADC and DAC-mbed.pdf
PROGRAMMING ADC and DAC-mbed.pdfPROGRAMMING ADC and DAC-mbed.pdf
PROGRAMMING ADC and DAC-mbed.pdf
 

More from josnihmurni2907

Simple timer code for arduino
Simple timer code for arduinoSimple timer code for arduino
Simple timer code for arduino
josnihmurni2907
 
Michael kontopoulos
Michael kontopoulosMichael kontopoulos
Michael kontopoulos
josnihmurni2907
 
Michael kontopoulo1s
Michael kontopoulo1sMichael kontopoulo1s
Michael kontopoulo1s
josnihmurni2907
 
How to write timings and delays
How to write timings and delaysHow to write timings and delays
How to write timings and delays
josnihmurni2907
 
Define ba1
Define ba1Define ba1
Define ba1
josnihmurni2907
 
Define ba
Define baDefine ba
Define ba
josnihmurni2907
 
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
josnihmurni2907
 
Arduino
ArduinoArduino
Arduino 101
Arduino 101Arduino 101
Arduino 101
josnihmurni2907
 
140813560 nota-kimia-tingkatan-4
140813560 nota-kimia-tingkatan-4140813560 nota-kimia-tingkatan-4
140813560 nota-kimia-tingkatan-4
josnihmurni2907
 
1.funtions (1)
1.funtions (1)1.funtions (1)
1.funtions (1)
josnihmurni2907
 
132944997 rancangan-tahunan-mm-t5-2013
132944997 rancangan-tahunan-mm-t5-2013132944997 rancangan-tahunan-mm-t5-2013
132944997 rancangan-tahunan-mm-t5-2013
josnihmurni2907
 
Agihan kertas 1 dan kertas 2
Agihan kertas 1 dan kertas 2Agihan kertas 1 dan kertas 2
Agihan kertas 1 dan kertas 2
josnihmurni2907
 
Ciri pemimpin
Ciri pemimpinCiri pemimpin
Ciri pemimpin
josnihmurni2907
 
Cara menghilangkan rasa ngantuk di kelas
Cara menghilangkan rasa ngantuk di kelasCara menghilangkan rasa ngantuk di kelas
Cara menghilangkan rasa ngantuk di kelas
josnihmurni2907
 
Bercakap mengenai nikmat allah s
Bercakap mengenai nikmat allah sBercakap mengenai nikmat allah s
Bercakap mengenai nikmat allah s
josnihmurni2907
 
Bandar purba dalam tasik di china
Bandar purba dalam tasik di chinaBandar purba dalam tasik di china
Bandar purba dalam tasik di china
josnihmurni2907
 
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
josnihmurni2907
 
Smkts 2015 p1
Smkts 2015 p1Smkts 2015 p1
Smkts 2015 p1
josnihmurni2907
 

More from 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
 

Recently uploaded

Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 

Recently uploaded (20)

Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 

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. }