nice!
This switch is for Arduinos with FTDI or simple said all arduinos that are not UNO R3.
If you have two arduinos lower than UNO R3 than you have to use this for the detection.
If the arduino is only sometimes detected -> this should also help.
xzek wrote:I was trying to use the alternative Arduino firmware BY ALE, but I couldn't make it work.
xzek wrote:int portdstatus =PORTD; // read the current port D bit mask
prilad wrote:xzek wrote:I was trying to use the alternative Arduino firmware BY ALE, but I couldn't make it work.
Why? Can you write more what you did and what did not work? You can do it in my thread ? ...
And about your question - I don't look Sir's code, but I think that problem in this place:xzek wrote:int portdstatus =PORTD; // read the current port D bit mask
because you want to use new pins from PORTB (pins 13,12,11,8) instead previous PORTD pins... And you mast change BIT MASK and code, where this MASK using..
Regards,
Ale
xzek wrote:I tried your firmware(ALE) successfully uploaded to the arduino and I made it work with SimCTRL but I couldn't find any interface option when I started the converter. Ill post more details if you could please link me to your thread.
xzek wrote:*.. about the port thing at X-PID... yes, I figure it out about changing PORTD instead PORTB where the pins that im using are settled. So, I changed the code in all instances where PORTD where used with the bit mask but same result...
int portdstatus =PORTD; // read the current port D bit mask
int ControlPinM1Inp1 =2; // motor 1 INP1 output, this is the arduino pin description
int ControlPinM1Inp2 =3; // motor 1 INP2 output, this is the arduino pin description
int ControlPinM2Inp1 =4; // motor 2 INP1 output, this is the arduino pin description
int ControlPinM2Inp2 =5; // motor 2 INP2 output, this is the arduino pin description
int portdstatus =PORTB; // read the current port B bit mask
int ControlPinM1Inp1 =8; // motor 1 INP1 output, this is the arduino pin description
int ControlPinM1Inp2 =12; // motor 1 INP2 output, this is the arduino pin description
int ControlPinM2Inp1 =11; // motor 2 INP1 output, this is the arduino pin description
int ControlPinM2Inp2 =13; // motor 2 INP2 output, this is the arduino pin description
// new variables
int PortmaskPinM1Inp1 = 0; // mask for PINB0 (this is arduino pin 8)
int PortmaskPinM1Inp2 = 4; // mask for PINB4 (this is arduino pin 12)
int PortmaskPinM2Inp1 = 3; // mask for PINB3 (this is arduino pin 11)
int PortmaskPinM2Inp2 = 5; // mask for PINB5 (this is arduino pin 13)
void setup()
{
//Serial.begin(115200); //Uncomment this for arduino UNO without ftdi serial chip
Serial.begin(9600); //Uncomment this for arduino nano, arduino with ftdi chip or arduino duemilanove
portdstatus=PORTD;
....
void setup()
{
//Serial.begin(115200); //Uncomment this for arduino UNO without ftdi serial chip
Serial.begin(9600); //Uncomment this for arduino nano, arduino with ftdi chip or arduino duemilanove
portdstatus=PORTB;
....
//Direct port manipulation, change here your port code
void SetMotor1Inp1()
{
portdstatus |= 1 << ControlPinM1Inp1;
PORTD = portdstatus;
}
void UnsetMotor1Inp1()
{
portdstatus &= ~(1 << ControlPinM1Inp1);
PORTD = portdstatus;
}
void SetMotor1Inp2()
{
portdstatus |= 1 << ControlPinM1Inp2;
PORTD = portdstatus;
}
void UnsetMotor1Inp2()
{
portdstatus &= ~(1 << ControlPinM1Inp2);
PORTD = portdstatus;
}
void SetMotor2Inp1()
{
portdstatus |= 1 << ControlPinM2Inp1;
PORTD = portdstatus;
}
void UnsetMotor2Inp1()
{
portdstatus &= ~(1 << ControlPinM2Inp1);
PORTD = portdstatus;
}
void SetMotor2Inp2()
{
portdstatus |= 1 << ControlPinM2Inp2;
PORTD = portdstatus;
}
void UnsetMotor2Inp2()
{
portdstatus &= ~(1 << ControlPinM2Inp2);
PORTD = portdstatus;
}
//Direct port manipulation, change here your port code
void SetMotor1Inp1()
{
portdstatus |= 1 << PortmaskPinM1Inp1;
PORTB = portdstatus;
}
void UnsetMotor1Inp1()
{
portdstatus &= ~(1 << PortmaskPinM1Inp1);
PORTB = portdstatus;
}
void SetMotor1Inp2()
{
portdstatus |= 1 << PortmaskPinM1Inp2;
PORTB = portdstatus;
}
void UnsetMotor1Inp2()
{
portdstatus &= ~(1 << PortmaskPinM1Inp2);
PORTB = portdstatus;
}
void SetMotor2Inp1()
{
portdstatus |= 1 << PortmaskPinM2Inp1;
PORTB = portdstatus;
}
void UnsetMotor2Inp1()
{
portdstatus &= ~(1 << PortmaskPinM2Inp1);
PORTB = portdstatus;
}
void SetMotor2Inp2()
{
portdstatus |= 1 << PortmaskPinM2Inp2;
PORTB = portdstatus;
}
void UnsetMotor2Inp2()
{
portdstatus &= ~(1 << PortmaskPinM2Inp1);
PORTB = portdstatus;
}
prilad wrote:xzek wrote:I tried your firmware(ALE) successfully uploaded to the arduino and I made it work with SimCTRL but I couldn't find any interface option when I started the converter. Ill post more details if you could please link me to your thread.
I mean this thread with my firmware - http://x-sim.de/forum/viewtopic.php?f=39&t=695
My firmware works through USO, with standart command line "AB~255~~a01~~a02"xzek wrote:*.. about the port thing at X-PID... yes, I figure it out about changing PORTD instead PORTB where the pins that im using are settled. So, I changed the code in all instances where PORTD where used with the bit mask but same result...
If you want to define new control pins instead arduino pins 2,3,4,5 you want to make next changes in the code:
OLD CODE
- Code: Select all
int portdstatus =PORTD; // read the current port D bit mask
int ControlPinM1Inp1 =2; // motor 1 INP1 output, this is the arduino pin description
int ControlPinM1Inp2 =3; // motor 1 INP2 output, this is the arduino pin description
int ControlPinM2Inp1 =4; // motor 2 INP1 output, this is the arduino pin description
int ControlPinM2Inp2 =5; // motor 2 INP2 output, this is the arduino pin description
NEW CODE
- Code: Select all
int portdstatus =PORTB; // read the current port B bit mask
int ControlPinM1Inp1 =8; // motor 1 INP1 output, this is the arduino pin description
int ControlPinM1Inp2 =12; // motor 1 INP2 output, this is the arduino pin description
int ControlPinM2Inp1 =11; // motor 2 INP1 output, this is the arduino pin description
int ControlPinM2Inp2 =13; // motor 2 INP2 output, this is the arduino pin description
// new variables
int PortmaskPinM1Inp1 = 0; // mask for PINB0 (this is arduino pin 8)
int PortmaskPinM1Inp2 = 4; // mask for PINB4 (this is arduino pin 12)
int PortmaskPinM2Inp1 = 3; // mask for PINB3 (this is arduino pin 11)
int PortmaskPinM2Inp2 = 5; // mask for PINB5 (this is arduino pin 13)
OLD CODE
- Code: Select all
void setup()
{
//Serial.begin(115200); //Uncomment this for arduino UNO without ftdi serial chip
Serial.begin(9600); //Uncomment this for arduino nano, arduino with ftdi chip or arduino duemilanove
portdstatus=PORTD;
....
NEW CODE
- Code: Select all
void setup()
{
//Serial.begin(115200); //Uncomment this for arduino UNO without ftdi serial chip
Serial.begin(9600); //Uncomment this for arduino nano, arduino with ftdi chip or arduino duemilanove
portdstatus=PORTB;
....
OLD CODE
- Code: Select all
//Direct port manipulation, change here your port code
void SetMotor1Inp1()
{
portdstatus |= 1 << ControlPinM1Inp1;
PORTD = portdstatus;
}
void UnsetMotor1Inp1()
{
portdstatus &= ~(1 << ControlPinM1Inp1);
PORTD = portdstatus;
}
void SetMotor1Inp2()
{
portdstatus |= 1 << ControlPinM1Inp2;
PORTD = portdstatus;
}
void UnsetMotor1Inp2()
{
portdstatus &= ~(1 << ControlPinM1Inp2);
PORTD = portdstatus;
}
void SetMotor2Inp1()
{
portdstatus |= 1 << ControlPinM2Inp1;
PORTD = portdstatus;
}
void UnsetMotor2Inp1()
{
portdstatus &= ~(1 << ControlPinM2Inp1);
PORTD = portdstatus;
}
void SetMotor2Inp2()
{
portdstatus |= 1 << ControlPinM2Inp2;
PORTD = portdstatus;
}
void UnsetMotor2Inp2()
{
portdstatus &= ~(1 << ControlPinM2Inp2);
PORTD = portdstatus;
}
NEW CODE
- Code: Select all
//Direct port manipulation, change here your port code
void SetMotor1Inp1()
{
portdstatus |= 1 << PortmaskPinM1Inp1;
PORTB = portdstatus;
}
void UnsetMotor1Inp1()
{
portdstatus &= ~(1 << PortmaskPinM1Inp1);
PORTB = portdstatus;
}
void SetMotor1Inp2()
{
portdstatus |= 1 << PortmaskPinM1Inp2;
PORTB = portdstatus;
}
void UnsetMotor1Inp2()
{
portdstatus &= ~(1 << PortmaskPinM1Inp2);
PORTB = portdstatus;
}
void SetMotor2Inp1()
{
portdstatus |= 1 << PortmaskPinM2Inp1;
PORTB = portdstatus;
}
void UnsetMotor2Inp1()
{
portdstatus &= ~(1 << PortmaskPinM2Inp1);
PORTB = portdstatus;
}
void SetMotor2Inp2()
{
portdstatus |= 1 << PortmaskPinM2Inp2;
PORTB = portdstatus;
}
void UnsetMotor2Inp2()
{
portdstatus &= ~(1 << PortmaskPinM2Inp1);
PORTB = portdstatus;
}
Return to Controllers and Drivers Projects
Users browsing this forum: No registered users and 2 guests