Neuling braucht Hilfe

Deutsche Sprache - beachtet den Google Übersetzer oben rechts

Re: Neuling braucht Hilfe

Postby Panhead58 » Sat 23. May 2015, 22:55

hallo nilsk28,
man bin ich froh das sich hier jemand meldet!
Danke schon mal im voraus!

Baudeinstellung war verkehrt!
115200 eingestellt und befehl eingegeben!
Motoren drehten sich beide permanent in eine richtung! (meine Poties sind ja mechanisch nicht verbunden!)
kann nun abermit den Poties besser regeln (in ungefährer mittelstellung kann ich sie aber nun nicht mehr stellen! sonder 2 drittel zu einer seite damit die Motoren stehen!)
programm beendet und nochmal gestartet weil ich sie nicht mehr am laufen bekommen habe nachdem ich sie an den Poties zum stehen gebracht habe!
nach öffen des Monitors rannten sie sofort wieder los ohne was einzugeben!
frage habe ich mit eingabe deines Codes das Programm auf dem Arduino permanent geändert?

ich habe im Arduino tutorial gesehen das beim auswählen des com ports dahinter der Arduino steht, bei mir steht nur der com port!
im Geräte Manager wird er als USB-SERIAL CH340 (COM5) erkannt!
Im SIM Converter unter Interfac settings steht unter all Outputs foung Interface nichts !
ist alles leer!
beim Spielen bewegen sich die Motoren immer noch nicht!
Ich habe alles über einen PC ( relativ neu und leistungsstark extra fürs Zocken) laufen(Spiele und X-Sim)
Panhead58
 
Posts: 7
Joined: Mon 11. May 2015, 18:11
Has thanked: 0 time
Been thanked: 0 time

Re: Neuling braucht Hilfe

Postby Nilsk28 » Mon 25. May 2015, 14:17

nein durch den Befehl wurde nichts verändert ,
aber dein programm will in die nullstellung fahren was es ohne die potis nicht kann
Nilsk28
 
Posts: 9
Joined: Sun 29. Mar 2015, 15:32
Has thanked: 0 time
Been thanked: 0 time

Re: Neuling braucht Hilfe

Postby Nilsk28 » Mon 25. May 2015, 22:20

wenn du möchtst können wir mal ein termin ausmachen wo beide online sind ,ist glaube ich besser zum schreiben
Nilsk28
 
Posts: 9
Joined: Sun 29. Mar 2015, 15:32
Has thanked: 0 time
Been thanked: 0 time

Re: Neuling braucht Hilfe

Postby Panhead58 » Mon 25. May 2015, 23:17

hallo nilsk28,
so, nachdem ich die Software aus der Project Gallerie/Controllers and Drivers Projects / SparksFun dual Moto Monster China Edition H-Bridge installiert habe hat sich hier was getan!
habe in einer Auswahl nun als Output X-PID 2.0 COM5 position 1 stehen!
habe mal gas und bremse ausgewählt und die motoren liefen mal in die eine mal in die andere richtung je nach gas geben oder bremsen!
habe heute die Potis proviesorisch mit einem Draht verbunden !
beimstarten des conwerters sind die motoren kurz angelaufen wobei einer sich mehrmals drehte! (ein Potikontrollkabel war an einer Lötstelle los!)
der andere Motor ruckte immer hin und her!
als ich Rfactor startete fing der eine wider an in beide richtungen zu zucken (ich denke mal da muss nun die feineinstellung ran!)
der andere Motor drehte sich permanent da Kabel ab!
nach ca. 10 bis 15 sec war der Arduino hinüber es machte pätsch es roch und der Computer schaltete sich Automatisch aus Schutzgründen aus!
Jetzt muss erstmal ein neuerher, hab ihn gerade bestellt!
Wo stelle ich die Potis ein?
was muss ich als input einstellen?
habe bei Input das G27 mit allen Pedalen und Tasten aufgeführt! das kann ja irgendwie nicht sein oder?
die Steuerbefehle kommen ja von den Spielen!

mit dem Online Termin das würde mir sehr gefallen!
in ein paar tagen sollte der Arduino hier sein!

gruss Rolf
Panhead58
 
Posts: 7
Joined: Mon 11. May 2015, 18:11
Has thanked: 0 time
Been thanked: 0 time

Re: Neuling braucht Hilfe

Postby Nilsk28 » Thu 28. May 2015, 19:51

gib einfach mal bescheid wenn der neue da ist
Nilsk28
 
Posts: 9
Joined: Sun 29. Mar 2015, 15:32
Has thanked: 0 time
Been thanked: 0 time

Re: Neuling braucht Hilfe

Postby Panhead58 » Thu 28. May 2015, 21:43

Tach

ja der neue war da!
angeschlossen programm drauf geladen!
kurz X-Sim converter gestartet motoren liefen dabei an PC aus (nu ist der 2 USB Port hin) Arduino auch wieder platt!
ich werde das ganze hier mal über denken!
viel zuviele unbeantwortete fragen!
im forum für meine Person alles zu unübersichtlich!
zu viele übersetzungen durch google meinerseitz die ich nicht verstehe!
firmware update am Arduino? welche? wo kommt die hin? wo finde ich meine version?
welcher code ist nun der richtige?
wo stellt man was ein?
das ganze kann ich so unendlich weiter aufzählen!
schade das ichdie Hardware mit gelenken anbindungen etc. schon fertig habe!
ich finde hier immer wieder irgend was anderes im forum was mich verwiert!
Herzlichen Glückwunsch und mein ganzen Respect an die die es geschaft haben!
ich werde nicht die flinte ins korn werfrn aber nun muss ich erstmal alles überdenken!
Danke erstmal für deine hilfe nilsk28
gruss Rolf
Panhead58
 
Posts: 7
Joined: Mon 11. May 2015, 18:11
Has thanked: 0 time
Been thanked: 0 time

Re: Neuling braucht Hilfe

Postby Nilsk28 » Fri 29. May 2015, 12:58

wenn dein Arduino abraucht hast du die falschen potis bestell die hier http://www.ebay.de/itm/261226296893?_tr ... EBIDX%3AIT
und klemm sie so an
danach sollte es keine probleme mehr geben
Attachments
Nilsk28
 
Posts: 9
Joined: Sun 29. Mar 2015, 15:32
Has thanked: 0 time
Been thanked: 0 time

Re: Neuling braucht Hilfe

Postby Nilsk28 » Fri 29. May 2015, 13:01

und benutze diesen code

/*
Arduino code for dynamic playseat 2DOF
Created 24 May 2011 by Jim Lindblom SparkFun Electronics https://www.sparkfun.com/products/10182 "Example Code"
Created 24 Apr 2012 by Jean David SEDRUE Version betatest26 - 24042012 http://www.gamoover.net/Forums/index.php?topic=25907
Updated 20 May 2013 by RacingMat in english http://www.x-sim.de/forum/posting.php?m ... 943&p=8481 in french : http://www.gamoover.net/Forums/index.php?topic=27617
Updated 30 April 2014 by RacingMat (bug for value below 16 corrected)
*/

#define BRAKEVCC 0
#define RV 2 //beware it's depending on your hardware wiring
#define FW 1 //beware it's depending on your hardware wiring
#define STOP 0
#define BRAKEGND 3

////////////////////////////////////////////////////////////////////////////////
#define pwmMax 255 // or less, if you want to lower the maximum motor's speed

// defining the range of potentiometer's rotation
const int potMini=208;
const int potMaxi=815;

////////////////////////////////////////////////////////////////////////////////
#define motLeft 0
#define motRight 1
#define potL A5
#define potR A4

////////////////////////////////////////////////////////////////////////////////
// DECLARATIONS
////////////////////////////////////////////////////////////////////////////////
/* VNH2SP30 pin definitions*/
int inApin[2] = {
7, 4}; // INA: Clockwise input
int inBpin[2] = {
8, 9}; // INB: Counter-clockwise input
int pwmpin[2] = {
5, 6}; // PWM input
int cspin[2] = {
2, 3}; // CS: Current sense ANALOG input
int enpin[2] = {
0, 1}; // EN: Status of switches output (Analog pin)
int statpin = 13; //not explained by Sparkfun
/* init position value*/
int DataValueL=512; //middle position 0-1024
int DataValueR=512; //middle position 0-1024

////////////////////////////////////////////////////////////////////////////////
// INITIALIZATION
////////////////////////////////////////////////////////////////////////////////
void setup()
{
// serial initialization
Serial.begin(115200);

// initialization of Arduino's pins
pinMode(statpin, OUTPUT); //not explained by Sparkfun
digitalWrite(statpin, LOW);

for (int i=0; i<2; i++)
{
pinMode(inApin[i], OUTPUT);
pinMode(inBpin[i], OUTPUT);
pinMode(pwmpin[i], OUTPUT);
}
// Initialize braked for motor
for (int i=0; i<2; i++)
{
digitalWrite(inApin[i], LOW);
digitalWrite(inBpin[i], LOW);
}
}
////////////////////////////////////////////////////////////////////////////////
///////////////////////////////// Main Loop ////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
void loop()
{
int sensorL,sensorR;

readSerialData(); // DataValueR & L contain the last order received (if there is no newer received, the last is kept)
// the previous order will still be used by the PID regulation MotorMotion Function

sensorR = analogRead(potR); // range 0-1024
sensorL = analogRead(potL); // range 0-1024

motorMotion(motRight,sensorR,DataValueR);
motorMotion(motLeft,sensorL,DataValueL);
}
////////////////////////////////////////////////////////////////////////////////
// Procedure: wait for complete trame
////////////////////////////////////////////////////////////////////////////////
void readSerialData()
{
byte Data[3]={
'0','0','0' };
// keep this function short, because the loop has to be short to keep the control over the motors

if (Serial.available()>2){
//parse the buffer : test if the byte is the first of the order "R"
Data[0]=Serial.read();
if (Data[0]=='L'){
Data[1]=Serial.read();
Data[2]=Serial.read();
// call the function that converts the hexa in decimal and that maps the range
DataValueR=NormalizeData(Data);
}
if (Data[0]=='R'){
Data[1]=Serial.read();
Data[2]=Serial.read();
// call the function that converts the hexa in decimal and maps the range
DataValueL=NormalizeData(Data);

}
}
if (Serial.available()>16) Serial.flush();
}
////////////////////////////////////////////////////////
void motorMotion(int numMot,int actualPos,int targetPos)
////////////////////////////////////////////////////////
{
int Tol=20; // no order to move will be sent to the motor if the target is close to the actual position
// this prevents short jittering moves
//could be a parameter read from a pot on an analogic pin
// the highest value, the calmest the simulator would be (less moves)

int gap;
int pwm;
int brakingDistance=30;

// security concern : targetPos has to be within the mechanically authorized range
targetPos=constrain(targetPos,potMini+brakingDistance,potMaxi-brakingDistance);

gap=abs(targetPos-actualPos);

if (gap<= Tol) {
motorOff(numMot); //too near to move
}
else {
// PID : calculates speed according to distance
pwm=195;
if (gap>50) pwm=215;
if (gap>75) pwm=235;
if (gap>100) pwm=255;
pwm=map(pwm, 0, 255, 0, pwmMax); //adjust the value according to pwmMax for mechanical debugging purpose !

// if motor is outside from the range, send motor back to the limit !
// go forward (up)
if ((actualPos<potMini) || (actualPos<targetPos)) motorGo(numMot, FW, pwm);
// go reverse (down)
if ((actualPos>potMaxi) || (actualPos>targetPos)) motorGo(numMot, RV, pwm);

}
}



////////////////////////////////////////////////////////////////////////////////
void motorOff(int motor){ //Brake Ground : free wheel actually
////////////////////////////////////////////////////////////////////////////////
digitalWrite(inApin[motor], LOW);
digitalWrite(inBpin[motor], LOW);
analogWrite(pwmpin[motor], 0);
}
////////////////////////////////////////////////////////////////////////////////
void motorOffBraked(int motor){ // "brake VCC" : short-circuit inducing electromagnetic brake
////////////////////////////////////////////////////////////////////////////////
digitalWrite(inApin[motor], HIGH);
digitalWrite(inBpin[motor], HIGH);
analogWrite(pwmpin[motor], 0);
}

////////////////////////////////////////////////////////////////////////////////
void motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)
////////////////////////////////////////////////////////////////////////////////
{
if (motor <= 1)
{
if (direct <=4)
{
// Set inA[motor]
if (direct <=1)
digitalWrite(inApin[motor], HIGH);
else
digitalWrite(inApin[motor], LOW);

// Set inB[motor]
if ((direct==0)||(direct==2))
digitalWrite(inBpin[motor], HIGH);
else
digitalWrite(inBpin[motor], LOW);

analogWrite(pwmpin[motor], pwm);

}
}
}

////////////////////////////////////////////////////////////////////////////////
void motorDrive(uint8_t motor, uint8_t direct, uint8_t pwm)
////////////////////////////////////////////////////////////////////////////////
{
// more readable function than Jim's (for educational purpose)
// but 50 octets heavier -> unused
if (motor <= 1 && direct <=4)
{
switch (direct) {
case 0: //electromagnetic brake : brake VCC
digitalWrite(inApin[motor], HIGH);
digitalWrite(inBpin[motor], HIGH);
break;
case 3: //Brake Ground (free wheel)
digitalWrite(inApin[motor], LOW);
digitalWrite(inBpin[motor], LOW);
break;
case 1: // forward : beware it's depending on your hardware wiring
digitalWrite(inApin[motor], HIGH);
digitalWrite(inBpin[motor], LOW);
break;
case 2: // Reverse : beware it's depending on your hardware wiring
digitalWrite(inApin[motor], LOW);
digitalWrite(inBpin[motor], HIGH);
break;
}
analogWrite(pwmpin[motor], pwm);
}
}
////////////////////////////////////////////////////////////////////////////////
// testPot
////////////////////////////////////////////////////////////////////////////////
void testPot(){

Serial.print(analogRead(A4));
Serial.print(";");
Serial.println(analogRead(A5));
delay(250);

}
////////////////////////////////////////////////////////////////////////////////
void testpulse(){
int pw=120;
while (true){

motorGo(motLeft, FW, pw);
delay(250);
motorOff(motLeft);
delay(250);
motorGo(motLeft, RV, pw);
delay(250);
motorOff(motLeft);

delay(500);

motorGo(motRight, FW, pw);
delay(250);
motorOff(motRight);
delay(250);
motorGo(motRight, RV, pw);
delay(250);
motorOff(motRight);
Serial.println("testpulse pwm:80");
delay(500);

}
}
////////////////////////////////////////////////////////////////////////////////
// Function: convert Hex to Dec
////////////////////////////////////////////////////////////////////////////////
int NormalizeData(byte x[3])
////////////////////////////////////////////////////////////////////////////////
{
int result;

if ((x[2]==13) || (x[2]=='R') || (x[2]=='L')) //only a LSB and Carrier Return or 'L' or 'R' in case of value below 16 (ie one CHAR and not 2)
{
x[2]=x[1]; //move MSB to LSB
x[1]='0'; //clear MSB
}
for (int i=1; i<3; i++)
{
if (x[i]>47 && x[i]<58 ){//for x0 to x9
x[i]=x[i]-48;
}
if (x[i]>64 && x[i]<71 ){//for xA to xF
x[i]=(x[i]-65)+10;
}
}
// map the range from Xsim (0 <-> 255) to the mechanically authorized range (potMini <-> potMaxi)
result=map((x[1]*16+x[2]),0,255,potMini,potMaxi);
return result;
}
Nilsk28
 
Posts: 9
Joined: Sun 29. Mar 2015, 15:32
Has thanked: 0 time
Been thanked: 0 time

Re: Neuling braucht Hilfe

Postby Panhead58 » Fri 29. May 2015, 21:27

hallo nilsk28,
ok bestelle mir den nächsten Arduin :? o und die Potis!
ich hatte 10 Kohm von Conrad werde aber auch die von Ebay bestellen!
du hast mich wieder aufgegleist!
Danke melde mich
Rolf
Panhead58
 
Posts: 7
Joined: Mon 11. May 2015, 18:11
Has thanked: 0 time
Been thanked: 0 time

Re: Neuling braucht Hilfe

Postby sirnoname » Sat 30. May 2015, 16:28

Dann aber anschliessen, Fotos machen, hier verifizieren lassen.
Wenn keiner antwortet kannst du ja per PM die Leute drauf aufmerksam machen!

Potis gehen von 500Ohm bis 47 kOhm alle zum Anschliessen ohne das was passiert. Kauf dir nur lineare Potis, sind sie nicht so ausgeschrieben, dann lass die Finger davon weg. Auch gehen Hall Potis (magnetisch mit 0bis5V Ausgang) und Schieberegler (anbringen wie beim Rock'n'Ride).
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

PreviousNext

Return to German language

Who is online

Users browsing this forum: No registered users and 2 guests