Arduino Open Source X-PID firmware incl.360°option

AMC, H-Bridge projects etc.
Please use the image gallery for your pictures, a short tutorial can be found here.
The first image in the first post will be shown in the project gallery.

Re: Arduino Open Source X-PID firmware incl.360°option

Postby sirnoname » Sat 11. May 2013, 01:56

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.
If a answer is correct or did help you for a solution, please use the solve button.
User avatar
sirnoname
Site Admin
 
Posts: 1829
Images: 45
Joined: Thu 1. Sep 2011, 22:02
Location: Munich, Germany
Has thanked: 35 times
Been thanked: 128 times

Re: Arduino Open Source X-PID firmware incl.360°option

Postby xzek » Fri 31. May 2013, 16:06

Hi, Im trying to configure the arduino with different pinouts as follows:

int portdstatus =PORTD; // read the current port D 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
int PWMPinM1 =9; // motor 1 PWM output
int PWMPinM2 =10; // motor 2 PWM output

// Pot feedback inputs
int FeedbackPin1 = A0; // select the input pin for the potentiometer 1, PC0
int FeedbackPin2 = A1;

but it doesn't work... I connected some leds to see whats going on, and apparently it must be something else that it has to be done with the code in order to get the pinounts config to work, because only the PWM led in both motors signals turns on.

I tried a test with the default pinouts and it works well...

I need to change de pinouts because I already made a PCB board with those pins since I was trying to use the alternative Arduino firmware BY ALE, but I couldn't make it work.

So I decided to go with X-PID and I checked the code and I couldnt see where I can also modify it to make it work with my configuration.,.. so please any help I will really thankful ...
xzek
 
Posts: 4
Images: 4
Joined: Thu 24. Jan 2013, 05:24
Has thanked: 2 times
Been thanked: 0 time

Re: Arduino Open Source X-PID firmware incl.360°option

Postby prilad » Fri 31. May 2013, 16:48

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
User avatar
prilad
 
Posts: 174
Images: 1
Joined: Tue 3. Apr 2012, 14:20
Location: Dubna, Moscow reg., Russia
Has thanked: 3 times
Been thanked: 37 times

Re: Arduino Open Source X-PID firmware incl.360°option

Postby xzek » Fri 31. May 2013, 20:09

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



Thanks for the answer.

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.

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

regards.
xzek
 
Posts: 4
Images: 4
Joined: Thu 24. Jan 2013, 05:24
Has thanked: 2 times
Been thanked: 0 time

Re: Arduino Open Source X-PID firmware incl.360°option

Postby prilad » Fri 31. May 2013, 21:02

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;
}
User avatar
prilad
 
Posts: 174
Images: 1
Joined: Tue 3. Apr 2012, 14:20
Location: Dubna, Moscow reg., Russia
Has thanked: 3 times
Been thanked: 37 times

Re: Arduino Open Source X-PID firmware incl.360°option

Postby xzek » Sat 1. Jun 2013, 20:36

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



THANKS A LOT!!!!

It works!!! ... So, I was wondering why the changes that I made didn't work and I realized that the command "pinMode()" had to be declared with arduino pinouts intead of the bitmask and of course, thats why you created new variables for the bitmask... so I changed numbers instead and its working *...

I couldn't have made it without your help.

again... thanks a lot man!

Now Im gonna try your firmware and I'll be straight to your thread.

Regards.
xzek
 
Posts: 4
Images: 4
Joined: Thu 24. Jan 2013, 05:24
Has thanked: 2 times
Been thanked: 0 time

Re: Arduino Open Source X-PID firmware incl.360°option

Postby sirnoname » Mon 3. Jun 2013, 21:20

Update with 3.0.1.6: Plugin can detect more connected interfaces. It did before but the names after the first one was whitespaces ....
If a answer is correct or did help you for a solution, please use the solve button.
User avatar
sirnoname
Site Admin
 
Posts: 1829
Images: 45
Joined: Thu 1. Sep 2011, 22:02
Location: Munich, Germany
Has thanked: 35 times
Been thanked: 128 times

Re: Arduino Open Source X-PID firmware incl.360°option

Postby adrenalinapf » Mon 17. Jun 2013, 00:33

so I could tell this electrical wiring diagram is something wrong, the board design ebay VCC 43A single bridge is not on pin 2, and so on pin 1 looking from the bottom up, the fourth pin is GND, and OUT1 and OUT2 is in the middle of the plate can then be said that this wiring diagram is completely wrong, or is my mistake
adrenalinapf
 
Posts: 4
Joined: Thu 14. Mar 2013, 16:54
Location: Brasil
Has thanked: 0 time
Been thanked: 0 time

Re: Arduino Open Source X-PID firmware incl.360°option

Postby sirnoname » Mon 17. Jun 2013, 07:17

As written in the wiring section: wiring informations are in the ino file.
If a answer is correct or did help you for a solution, please use the solve button.
User avatar
sirnoname
Site Admin
 
Posts: 1829
Images: 45
Joined: Thu 1. Sep 2011, 22:02
Location: Munich, Germany
Has thanked: 35 times
Been thanked: 128 times

Re: Arduino Open Source X-PID firmware incl.360°option

Postby adrenalinapf » Mon 17. Jun 2013, 17:01

adrenalinapf
 
Posts: 4
Joined: Thu 14. Mar 2013, 16:54
Location: Brasil
Has thanked: 0 time
Been thanked: 0 time

PreviousNext

Return to Controllers and Drivers Projects

Who is online

Users browsing this forum: No registered users and 2 guests

cron