Hi Guys,
Thank you for the responses. To be clear, I did not write the sketch. I'm brand new to Arduino. I'm trying to use a sketch written for the Uno R3 by others. Because I'm new to the forum I cannot upload. So I have copied and pasted a portion of the code up to the error line into the window. I don't know of a better way and pasting the entire code was obnoxious. The first error starts on line 145. If someone can suggest a better way, or if I should paste the entire code, just let me know.
Line 145 int OutputPort =PORTD; // read the current port D bit mask
Error Code
Compilation error: 'PORTD' was not declared in this scope
Thanks again,
Lee
//****************************************************************************************************************
// SMC3.ino is basic Motor PID driver designed for motion simulators with upto 3 motors (written for UNO R3)
// Sabertooth Mode 3 upgrade to packet serial mode with serial timeout by BlazinH
// Softstart by BlazinH
//****************************************************************************************************************
//****************************************************************************************************************
//SET SOFTSTART SPEED
const int SSloop = 30;
//****************************************************************************************************************
// Set to MODE1 for use with a typical H-Bride that requires PWM and 1 or 2 direction inputs
// Set to MODE2 for a 43A "Chinese" IBT-2 H-Bridge from e-bay or equiv
// Set to MODE3 for a Sabretooth setup in simple serial mode
#define MODE3
// Uncomment the following line to reverse the direction of Motor 1.
// #define REVERSE_MOTOR1
// Uncomment ONE of the following lines to enable analogue input AN5 as a scaler for the motion values.
// #define ENABLE_POT_SCALING
// #define ENABLE_NON_LINEAR_POT_SCALING
// Uncomment the following line to enable the second software serial port.
// NOTE: This is currently not working - leave commented out until fixed!!!
// #define SECOND_SERIAL
// COMMAND SET:
//
// [] Drive all motors to defined stop positions and hold there
// [Axx],[Bxx],[Cxx] Send position updates for Motor 1,2,3 where xx is the binary position limitted to range 0-1024
// [Dxx],[Exx],[Fxx] Send the Kp parameter for motor 1,2,3 where xx is the Kp value multiplied by 100
// [Gxx],[Hxx],[Ixx] Send the Ki parameter for motor 1,2,3 where xx is the Ki value multiplied by 100
// [Jxx],[Kxx],[Lxx] Send the Kd parameter for motor 1,2,3 where xx is the Kd value multiplied by 100
// [Mxx],[Nxx],[Oxx] Send the Ks parameter for motor 1,2,3 where xx is the Ks value
// [Pxy],[Qxy],[Rxy] Send the PWMmin and PWMmax values x is the PWMmin and y is PWMmax each being in range 0-255
// [Sxy],[Txy],[Uxy] Send the Motor Min/Max Limits (x) and Input Min/Max Limits (y) (Note same value used for Min and Max)
// [Vxy],[Wxy],[Xxy] Send the Feedback dead zone (x) and the PWM reverse duty (y) for each motor
// [rdx] Read a value from the controller where x is the code for the parameter to read
// [ena] Enable all motors
// [sav] Save parameters to non-volatile memory
// [ver] Send the SMC3 software version
//
// Arduino UNO Pinouts Used
//
// 9 - Motor 1 PWM
// 10 - Motor 2 PWM
// 11 - Motor 3 PWM
// 2 - Motor 1 H-Bridge ENA
// 3 - Motor 1 H-Bridge ENB
// 4 - Motor 2 H-Bridge ENA
// 5 - Motor 2 H-Bridge ENB
// 6 - Motor 3 H-Bridge ENA
// 7 - Motor 3 H-Bridge ENB
// A0 - Motor 1 Feedback
// A1 - Motor 2 Feedback
// A2 - Motor 3 Feedback
// A5 - Motion scaler pot input
// BOF preprocessor bug prevention - leave me at the top of the arduino-code
#if 1
__asm volatile ("nop");
#endif
#include <EEPROM.h>
#include <SoftwareSerial.h>
// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
#define COM0 0 // hardware Serial Port
#define COM1 1 // Software Serial Port
#define START_BYTE '[' // Start Byte for serial commands
#define END_BYTE ']' // End Byte for serial commands
#define PROCESS_PERIOD_uS 1000 // 244 -> 4096 per second approx
#define TIMER_UPPER_LIMIT 4294966000 // Used to check for timer wraparound
#define TIMER_LOWER_LIMIT 1000 // Used to check for timer wraparound
int holdmax1;
int holdmax2;
int holdmax3;
int softstart = 0;
int counter = 0;
unsigned long TimesUp=0; // Counter used to see if it's time to calculate next PID update
int Feedback1 = 512;
int Feedback2 = 512;
int Feedback3 = 512;
int Target1 = 512;
int Target2 = 512;
int Target3 = 512;
int PotInput = 512;
int OffsetAdjust=0;
unsigned int RxByte[2]={0}; // Current byte received from each of the two comm ports
int BufferEnd[2]={-1}; // Rx Buffer end index for each of the two comm ports
unsigned int RxBuffer[5][2]={0}; // 5 byte Rx Command Buffer for each of the two comm ports
unsigned long LoopCount = 0; // unsigned 32bit, 0 to 4,294,967,295 to count times round loop
unsigned long LastCount = 0; // loop counter the last time it was read so can calc delta
byte errorcount = 0; // serial receive error detected by invalid packet start/end bytes
unsigned int CommsTimeout = 0; // used to reduce motor power if there has been no comms for a while
byte PowerScale = 7; // used to divide(shift) PID result changes when in low power
//
//
// +----+ +------+
// +-|PWR |--------------| USB |-----+
// | | | | | |
// | +----+ +------+ o|
// | o|
// | o|AREF
// | o|GND
// NC|o o|13 TTL (software) Serial
// IOREF|o +----+ o|12 TTL (software) Serial
// RESET|o | | o|11~ PWM Motor 3
// 3.3V|o | | o|10~ PWM Motor 2
// 5V|o | | Arduino o|9~ PWM Motor 1
// GND|o | | UNO o|8
// GND|o | | |
// VIN|o | | o|7 Motor 3 ENB
// | | | o|6~ Motor 3 ENA
// Motor 1 Pot A0|o | | o|5~ Motor 2 ENB
// Motor 2 Pot A1|o | | o|4 Motor 2 ENA
// Motor 3 Pot A2|o | | o|3~ Motor 1 ENB
// A3|o | | o|2 Motor 1 ENA
// A4|o | | o|1
// Motion Scaler A5|o +-/-+ o|0
// +-\ /---------+
// --------------------/
//
//
int OutputPort =PORTD; // read the current port D bit mask