Show Posts
Pages: [1]
1  Using Arduino / Sensors / Re: GPS Sentence has unwanted characters in it... on: January 20, 2013, 12:14:13 pm
Thanks a lot wildbill.
Now all the "ÿ" are gone  smiley
2  Using Arduino / Sensors / GPS Sentence has unwanted characters in it... on: January 20, 2013, 10:34:02 am
Hi,
i have a little Problem when i work with my GPS-Arduino by Aspen:
http://www.cutedigi.com/arduino/aspen-arduino-compatible-gps-and-li-poly-board-with-gps.html

I always have random "ÿ"-characters in my GPS-Sentences

Quote
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ$GPGÿGA,154135ÿ.000,5339.ÿ5503,N,013ÿ33.0733,E,ÿ1,06,3.0,1ÿ8.4,M,42.9ÿ,M,,0000*6ÿ6
$GPGSA,ÿA,3,10,13,ÿ23,04,07,0ÿ8,,,,,,,3ÿ.7,3.0,2.3ÿ*3D
$GPRMÿC,154135.0ÿ00,A,5339.ÿ5503,N,013ÿ33.0733,E,ÿ0.00,149.0ÿ6,190113,,ÿ,A*62
$GÿPVTG,149.0ÿ6,T,,M,0.0ÿ0,N,0.0,K,ÿA*07
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ$ÿGPGGA,1541ÿ36.000,533ÿ9.5503,N,0ÿ1333.0733,ÿE,1,06,3.0ÿ,18.4,M,42ÿ.9,M,,0000ÿ*65
$GPGÿSA,A,3,10,ÿ13,23,04,0ÿ7,08,,,,,,ÿ,3.7,3.0,2ÿ.3*3D
$GPÿGSV,3,1,12ÿ,10,75,239ÿ,37,07,65,ÿ163,36,13ÿ,53,075,35ÿ,02,36,263ÿ,27*77
$GÿPGSV,3,2,1ÿ2,08,35,19ÿ4,20,23,24ÿ,083,35,29ÿ,24,260,,0ÿ1,23,074,*ÿ7B
$GPGSÿV,3,3,12,0ÿ4,23,213,3ÿ1,05,16,03ÿ8,,26,08,2ÿ57,,24,03,ÿ336,*7B
$ÿGPRMC,1541ÿ36.000,A,5ÿ339.5503,ÿN,01333.07ÿ33,E,0.00,ÿ149.06,190ÿ113,,,A*61ÿ
$GPVTG,1ÿ49.06,T,,Mÿ,0.00,N,0.ÿ0,K,A*07


I want to use the GPRMC-Line which looks fine after all the "ÿ" are filtered out:
Quote
$GPRMC , 154132.000 , A , 5339.5503 , N , 01333.0733 , E , 0.00 , 149.06 , 190113,,,A*65

Since the GPS-Output has this stupid extra-characters, the tinyGPS-Library dosen't work with it smiley-sad

What would be a good way to fix this ?
I already filtered the incoming characters from the serial-connection, but then i fail on the task of doing tinyGPS's job...
3  Using Arduino / Motors, Mechanics, and Power / Re: Strange servo-behavior on: January 14, 2012, 10:08:53 am
Oh, thanks a lot PaulS, i always thought the ethernet-shield only uses 11,12 &13 ^^

Can i use pin 1 or 2 for a servo, i heard that they are the serial-connection (hopefully not the usb).
4  Using Arduino / Motors, Mechanics, and Power / Re: Strange servo-behavior on: January 14, 2012, 08:14:03 am
Thanks, but that sadly did nothing.
when i serial-print posLenk which is written to the servo, it always shows the correct values.

It must be an error with how i write the value to the servo...
5  Using Arduino / Motors, Mechanics, and Power / Strange servo-behavior on: January 13, 2012, 02:53:55 pm
I have written a little visualBasic application that sends angle-values via UDP to an arduino that writes these angles to a servo.
The value is transfered with no problems and all, but the servo likes to screw up a lot.

The value can only increase/decrease in 2°-steps which is controlled by two buttons, this way the servo should always have enough time between upd-packets to get to its new position.
The lastest value it was set to should be 44° because the application always slowy goes back in 2°-steps until it reaches 44° if there is no more input.

The Problem:
Whenever i'm not constantly updating the servo-value it runs into it's clockwise limit, which can't be good for the gears/engine inside...
shouldn't the  servo stay at its last know value until it gets a new one ?


Code:
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <Servo.h>


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 0, 178 };
byte gateway[] = { 192, 168, 0, 1 };
byte subnet[] = { 255, 255, 255, 0 };


char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet
char  ReplyBuffer[] = "acknowledged";       // a string to send back
byte remoteIp[4]; // holds recvieved packet's originating IP
unsigned int remotePort; // holds received packet's originating port


//Pin 11,12 & 13 are used by the EthernetShield
const int lightBackPin = 8;  //Need to replace these somtime
const int lightFrontPin =9;  //
const int lightPin = 8;
const int irPin =9;

const int lenk = 10;
const int cam =3;

Servo lenkServo;  // Steering-Servo
Servo camServo;   //Use this later for moveable camera...



int posCam=44;
int posLenk=44;

int M1 = 4;
int E1 = 5;
int E2 = 6;
int M2 = 7;

EthernetUDP Udp;

void setup() {
  Ethernet.begin(mac, ip , gateway, subnet);
  Udp.begin(9100);
  Serial.begin(9600);
  pinMode(lightBackPin, OUTPUT);
  pinMode(lightFrontPin, OUTPUT);
  pinMode(M1,OUTPUT);
  pinMode(M2,OUTPUT);
  lenkServo.attach(lenk);  // attaches the servo on pin 10 to the servo object
  camServo.attach(cam);
  lenkServo.write(44);delay(500);
}



void loop() {
  int packetSize = Udp.parsePacket();  // holds received packet size
  int DriveSpeed = 0;
 
  if(packetSize)
    {
    Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
    //Serial.println(packetBuffer);
       
        switch(packetBuffer[5]){
        case '-': digitalWrite(lightPin,LOW);digitalWrite(irPin,LOW);break;
        case 'i': digitalWrite(lightPin,LOW);digitalWrite(irPin,HIGH);break;
        case 'l': digitalWrite(lightPin,HIGH);digitalWrite(irPin,LOW);break;
        case 'b': digitalWrite(lightPin,HIGH);digitalWrite(irPin,HIGH);break;
        //IR     = Pin 12
        //Light  = Pin 13
        }
     
   
    if(packetBuffer[4]!='-')
      {
        switch(packetBuffer[4]){
        case '0': DriveSpeed=30;break;
        case '1': DriveSpeed=55;break;
        case '2': DriveSpeed=80;break;
        case '3': DriveSpeed=105;break;
        case '4': DriveSpeed=130;break;
        case '5': DriveSpeed=155;break;
        case '6': DriveSpeed=180;break;
        case '7': DriveSpeed=205;break;
        case '8': DriveSpeed=230;break;
        case '9': DriveSpeed=255;break;
        }
      }
     
    if(packetBuffer[0]=='-' & packetBuffer[1]=='-') //Stillsttand
        {analogWrite(E1,0);}
    if(packetBuffer[0]=='x') 
        {digitalWrite(M1,HIGH);analogWrite(E1,DriveSpeed);} //Rückwärts ?    //
    if(packetBuffer[1]=='x')                       //
        {digitalWrite(M1,LOW);analogWrite(E1,DriveSpeed);}  //Vorwärts ?     //
       
        /*old code
    if(packetBuffer[2]=='-' & packetBuffer[3]=='-')//==========================Straight
        {;}                       
    if(packetBuffer[2]=='x')//=================================================Left
        {;}                         
    if(packetBuffer[3]=='x')//=================================================Right                   
        {;}     
        */             // complicated version of 'atoi()', but this works too ;P
        int lenkA,lenkB;
        switch(packetBuffer[6]){
        case '0': lenkA=0;break;
        case '1': lenkA=1;break;
        case '2': lenkA=2;break;
        case '3': lenkA=3;break;
        case '4': lenkA=4;break;
        case '5': lenkA=5;break;
        case '6': lenkA=6;break;
        case '7': lenkA=7;break;
        case '8': lenkA=8;break;
        case '9': lenkA=9;break;
        }
       
        switch(packetBuffer[6]){
        case '0': lenkB=0;break;
        case '1': lenkB=1;break;
        case '2': lenkB=2;break;
        case '3': lenkB=3;break;
        case '4': lenkB=4;break;
        case '5': lenkB=5;break;
        case '6': lenkB=6;break;
        case '7': lenkB=7;break;
        case '8': lenkB=8;break;
        case '9': lenkB=9;break;
        }
       
        posLenk=((lenkA*10)+lenkB);
        Serial.println("PosLenk: ");
        Serial.print(posLenk);
        if(posLenk<90 & posLenk>0)
          {
          lenkServo.write(posLenk);
          //delay(5);
          }   
    }

}

6  Using Arduino / Motors, Mechanics, and Power / Re: Motorshield and electromagnet ? on: February 18, 2011, 03:40:19 pm
Thanks a lot jraskell, i deleted the in fact useless check-part and moved the controls into the the "if(packetsize)".

The stuttering is also solved now, it was propably caused by:
Code:
  if(packetSize==0)
    {
    digitalWrite(ledPin,LOW);
    analogWrite(E1,0);             
    analogWrite(E2,0);           
    }

this always activates when there are no packets, which is always the case right after a packet.
So i removed the two "analogWrite()" and it was gone smiley-grin



About making the controls bitwise, i had that in mind before, but i couldn't get the RAW-Data from UDP...
7  Using Arduino / Motors, Mechanics, and Power / Re: Motorshield and electromagnet ? on: February 18, 2011, 09:51:50 am
HIGH is the same as 255.
8  Using Arduino / Motors, Mechanics, and Power / Re: Motorshield and electromagnet ? on: February 18, 2011, 08:14:53 am
Back to the PWM-mode, it dosent work perfect, but at least i have left and right...

But there was something else i've noticed, the controller seems to get the signal, but then its sending out a low power (~40%) which then switches to the set power value after ~0,5 seconds delay.
shouldn't it give out the full power instantly ?
9  Using Arduino / Motors, Mechanics, and Power / Re: Motorshield and electromagnet ? on: February 14, 2011, 06:36:35 pm
Thats the code:
Code:
#include <SPI.h>
#include <Ethernet.h>
#include <Udp.h>


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 56, 35, 178 };
byte gateway[] = { 10, 56, 35, 1 };
byte subnet[] = { 255, 255, 255, 0 };

#define MAX_SIZE 32 // maximum packet size
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet
byte remoteIp[4]; // holds recvieved packet's originating IP
unsigned int remotePort; // holds received packet's originating port

const int ledPin = 13;

int E1 = 5;
int M1 = 4;
int E2 = 6;
int M2 = 7;


void setup() {
  Ethernet.begin(mac, ip , gateway, subnet);
  Udp.begin(9100);
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(M1,OUTPUT);
  pinMode(M2,OUTPUT);
}

void loop() {
  int packetSize=Udp.available();  // holds received packet size
  int DriveSpeed = 0;
  boolean SteuerFehler;
  if(packetSize)
    {
    digitalWrite(ledPin,HIGH);
    int packetSize = packetSize-8;   // minus 8-Bit Header
    Udp.readPacket(packetBuffer,UDP_TX_PACKET_MAX_SIZE, remoteIp, remotePort);
    Serial.println(packetBuffer);
    }
  if(packetSize==0)
    {
    digitalWrite(ledPin,LOW);
    analogWrite(E1,0);
    analogWrite(E2,0);
    }

    
for (int i=1;i!=8;i++)    //Searches for illegal characters inside the control-string
  {
  SteuerFehler=false;
  if(packetBuffer[i]!='-' |packetBuffer[i]!='x' |packetBuffer[i]!='0' |packetBuffer[i]!='1' |packetBuffer[i]!='2' |packetBuffer[i]!='3' |packetBuffer[i]!='4' |packetBuffer[i]!='5' |packetBuffer[i]!='6' |packetBuffer[i]!='7' |packetBuffer[i]!='8' |packetBuffer[i]!='9')
    {SteuerFehler=true;}
  }
  
/*  
  
if (SteuerFehler)
  {
  Serial.println("--------Fehler--------");
  packetBuffer[0]='-';    //Reset the control-string to all off
  packetBuffer[1]='-';
  packetBuffer[2]='-';
  packetBuffer[3]='-';
  packetBuffer[4]='-';
  packetBuffer[5]='-';
  packetBuffer[6]='-';
  packetBuffer[7]='-';
    
  SteuerFehler=false;
  }
*/


//DriveSpeed
if(packetBuffer[4]!='-')
  {
    switch(packetBuffer[4]){
    case '0': DriveSpeed=30;break;
    case '1': DriveSpeed=55;break;
    case '2': DriveSpeed=80;break;
    case '3': DriveSpeed=105;break;
    case '4': DriveSpeed=130;break;
    case '5': DriveSpeed=155;break;
    case '6': DriveSpeed=180;break;
    case '7': DriveSpeed=205;break;
    case '8': DriveSpeed=230;break;
    case '9': DriveSpeed=255;break;
    }
  }

  
if(packetBuffer[0]=='-' & packetBuffer[1]=='-') //Stop
    {analogWrite(E1,0);}
if(packetBuffer[0]=='x')  
    {digitalWrite(M1,HIGH);analogWrite(E1,DriveSpeed);} //Reverse
if(packetBuffer[1]=='x')                       //
    {digitalWrite(M1,LOW);analogWrite(E1,DriveSpeed);}  //Forward    

//Steering
if(packetBuffer[2]=='-' & packetBuffer[3]=='-') //Straight ahead
    {analogWrite(E2,0);}
if(packetBuffer[2]=='x')                        //Left
    {digitalWrite(M2,LOW);analogWrite(E2,255);}  
if(packetBuffer[3]=='x')                        //Right                
    {digitalWrite(M2,HIGH);analogWrite(E2,255);}      
    

}      
    
Steering-part is at the last lines.

I send a control-string of 8 characters, [2] is left and [3] is right, i'm always using the max. 255 for steering in one direction and LOW/HIGH. If [2] or [3] is not 'x', i set it to 0 volt.

It currently uses PWM and i'm not sure what the PLL-mode is...
When i listen to the sound that it makes, i get the feeling that the controller is giving out a stuttering (_-_-) voltage, like on->off->on... in very fast.
Maybe the magnet could work better without that fast on-off...

Edit:
I have set the Motor2 to PLL, but i don't rellay know a thing about it.
Heres what i have figured out so far:
M2 LOW -> Does nothing on any E2-Value ?
M2 HIGH -> enables Speed Control (in only one direction ?)

With M2=HIGH and E2=0, i can turn left just fine. But what about Right ?
10  Using Arduino / Motors, Mechanics, and Power / Motorshield and electromagnet ? on: February 14, 2011, 11:29:10 am
Hi ,
i have a rc-car with a magnetic steering (+volts right, -volts left) which i'm controling it with a L298P Motorshield.
The only Problem is that the steering kinda vibrates an won't really move.
So my question is, how can i make the motor shield working with this electromagnet ?
Or could PLL-mode on this shield (for three-phase-motors) control it ?
Before i do anything maybe dangerous for the circuits, i want to ask someone with more experience smiley
11  International / Deutsch / Problem mit PacketBuffer bei UDP-Empfang ? on: February 11, 2011, 11:24:35 am
Hallo,
ich habe in den lezten Tagen ein Programm für meinen Arduino "ATmega328" mit Ethernetshield und L298P-Motorshield geschrieben, dass ein RC-Auto kontrollieren kann.
Ich sende mit einem VB-Programm einen 8-Stelligen String den ich im Arduino mit über ein Char array auslesen kann.
Soweit funktioniert auch noch alles einwandfrei.

Nun habe ich allerdings noch ein Problem:

Das Arduino-Programm nimmt manchmal nach einer Bestimmten Zeit keine neuen Netzwerkdaten mehr an und hat verschiedene Symbole im Steuerstring, die nicht vom VB-Programm kommen.
Ich bin mir nicht sicher, ob sich das Ethernetshield aufhängt, jedenfalls hilft dann nur noch der Reset-knopf oder code neu hochladen.

Hier noch mein aktueller Quellcode:
Code:
#include <SPI.h>
#include <Ethernet.h>
#include <Udp.h>


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 56, 35, 178 };
byte gateway[] = { 10, 56, 35, 1 };
byte subnet[] = { 255, 255, 255, 0 };

#define MAX_SIZE 32 // maximum packet size
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet
byte remoteIp[4]; // holds recvieved packet's originating IP
unsigned int remotePort; // holds received packet's originating port

const int ledPin = 13;

int E1 = 5;
int M1 = 4;
int E2 = 6;
int M2 = 7;


void setup() {
  Ethernet.begin(mac, ip , gateway, subnet);
  Udp.begin(9100);
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(M1,OUTPUT);
  pinMode(M2,OUTPUT);
}

void loop() {
  int packetSize=Udp.available();  // holds received packet size
  int DriveSpeed = 0;
  boolean SteuerFehler;
  if(packetSize)
    {
    digitalWrite(ledPin,HIGH);
    int packetSize = packetSize-8;   ws // minus 8-Bit Header
    Udp.readPacket(packetBuffer,UDP_TX_PACKET_MAX_SIZE, remoteIp, remotePort);
    Serial.println(packetBuffer);
    Serial.println(packetSize);
    }
  if(packetSize==0)
    {digitalWrite(ledPin,LOW);}

/*    
for (int i=1;i!=8;i++)    //Sucht nach ungültigen Zeichen im Steuerstring
  {
  SteuerFehler=false;
  if(packetBuffer[i]!='-' |packetBuffer[i]!='x' |packetBuffer[i]!='0' |packetBuffer[i]!='1' |packetBuffer[i]!='2' |packetBuffer[i]!='3' |packetBuffer[i]!='4' |packetBuffer[i]!='5' |packetBuffer[i]!='6' |packetBuffer[i]!='7' |packetBuffer[i]!='8' |packetBuffer[i]!='9')
    {SteuerFehler=true;}
  }
  
  
  
if (SteuerFehler)
  {
  Serial.println("--------Fehler--------");
  packetBuffer[0]='-';    //Reset des Steuerstring auf alles aus
  packetBuffer[1]='-';
  packetBuffer[2]='-';
  packetBuffer[3]='-';
  packetBuffer[4]='-';
  packetBuffer[5]='-';
  packetBuffer[6]='-';
  packetBuffer[7]='-';
  
  //Udp.close();        //Udp resetten zum fixen ?!?
  //Udp.begin(9100);    //Udp.close() geht nicht...???
  
  SteuerFehler=false;
  }
*/

if(packetBuffer[4]!='-')
  {
    switch(packetBuffer[4]){
    case '0': DriveSpeed=30;break;
    case '1': DriveSpeed=55;break;
    case '2': DriveSpeed=80;break;
    case '3': DriveSpeed=105;break;
    case '4': DriveSpeed=130;break;
    case '5': DriveSpeed=155;break;
    case '6': DriveSpeed=180;break;
    case '7': DriveSpeed=205;break;
    case '8': DriveSpeed=230;break;
    case '9': DriveSpeed=255;break;
    }
  }
  
if(packetBuffer[0]=='-' | packetBuffer[1]=='-') //Stillsttand
    {analogWrite(E1,0);}
if(packetBuffer[0]=='x')  
    {digitalWrite(M1,HIGH);analogWrite(E1,DriveSpeed);} //Rückwärts ?    //
if(packetBuffer[1]=='x')                       //
    {digitalWrite(M1,LOW);analogWrite(E1,DriveSpeed);}  //Vorwärts ?     //


if(packetBuffer[2]=='-' | packetBuffer[3]=='-') //Geradeaus
    {analogWrite(E2,0);}
if(packetBuffer[2]=='x')                        //Links
    {digitalWrite(M2,LOW);analogWrite(E2,255);}  
if(packetBuffer[3]=='x')                        //Rechts                  
    {digitalWrite(M2,HIGH);analogWrite(E2,255);}      
    

}

Falls nötig kann ich auch noch mein VB-Programm hochladen.
Danke schonmal  smiley


Ist irgendwie gelöst, da es komischerweise nur noch auftritt, wenn ich die COM-Konsole offen hab smiley-confuse
Pages: [1]