USO output to an Arduino

Open a thread for a question about the simulator control software.
If you cannot receive any data in the input setup use the upper two forums!

USO output to an Arduino

Postby fw14b » Tue 19. Mar 2013, 11:25

Hi,

Can anyone help me?

I use the USO output to an Arduino Mega card, to control 6 servos.

I use the following formula

S~a01~R~a02~Y~a03~W~a04~P~a05~H~a06~

My servo turning, but not with one smooth motion

Look this video http://youtu.be/InvPT-C_Oe0

Has anyone an idea to solve this problem.

Sorry for my bad english.

Regards Charles,
fw14b
 
Posts: 4
Joined: Tue 18. Dec 2012, 14:20
Has thanked: 4 times
Been thanked: 0 time

Re: USO output to an Arduino

Postby sirnoname » Tue 19. Mar 2013, 14:00

Seems you are reading sometimes a zero.
Remember: transfere stability is at atmel chips 90% falling with the increasing rs232 speed. A checksum is needed. At microchip it is higher.
This can also happen if your code is to slow and you do not read the 1byte buffer of the atmel chip.
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: USO output to an Arduino

Postby adrianovrm » Mon 13. Apr 2015, 16:13

Good Morning, l having the same problemss with servos getting crazy at some moment , with my hexapod servos, getting crazy, sometimes it works, what sends a suspicious of serial errors cause without checksum , and l didnt discover how to make uso send the checksum byte ,
l know that ~a01~ is the axis value , l used 6 informations ( 25, 27 and 26 ) Vertical, longintudinal and lateral g forces to computer the translations and rotarion movements at my code and more speed, gear and rpm, gear l put in binary(8) , the left values at 16 bits. my data pacjet string is
X~A01~~A02~~A03~~A04~~A05~~A06~ , in the X-PID l saw the flowwing two functions


bool CheckChecksum() //Atmel chips have a comport error rate of 2%, so we need here a checksum
{
byte checksum=0;
for(int z=0; z < 3; z++)
{
byte val=commandbuffer[z];
checksum ^= val;
}
if(checksum==commandbuffer[3]){return true;}
return false;
}

void SerialWorker()
{
while(Serial.available())
{
if(buffercount==-1)
{
buffer = Serial.read();
if(buffer != 'X'){buffercount=-1;}else{buffercount=0;}
}
else
{
buffer = Serial.read();
commandbuffer[buffercount]=buffer;
buffercount++;
if(buffercount > 3)
{
if(CheckChecksum()==true){ParseCommand();}else{errorcount++;}
buffercount=-1;
}
}
}
}



and l notice that at the end of funcntion checkchecksum a variable computed "Checksum" is compared with the last byte received , am l right ? so , what l dont understand is how to make the USO sends this caculate byte over serial to my arduino interface, cou you aid me , guys ?
l what want to put a checksum byte for my string data packet that is now "X~A01~~A02~~A03~~A04~~A05~~A06~" how l do this ! l search at manuals l didnt found out how do it
adrianovrm
X-Sim Supporter
 
Posts: 214
Joined: Tue 20. Nov 2012, 07:35
Has thanked: 0 time
Been thanked: 1 time

Re: USO output to an Arduino

Postby adrianovrm » Mon 13. Apr 2015, 16:20

oops, l m blind , l think l found something like put c99 and the end of the string data packet , is that ? l will put it and see what happens, it sthere the uso explanantion, l just browse it and saw
adrianovrm
X-Sim Supporter
 
Posts: 214
Joined: Tue 20. Nov 2012, 07:35
Has thanked: 0 time
Been thanked: 1 time

Re: USO output to an Arduino

Postby adrianovrm » Mon 13. Apr 2015, 16:29

For we finnish this logic , there in USO it says :
"For XOR checksum use ~c99~ where 99 is a number between 0-99. This numer declares the used xor character before ~
which result the sum. "

with my data been X~A01~~A02~~A03~~A04~~A05~~A06~ , and now that we know my a01, a02, a03, a04, a05 are all 16 bits(2 BYTES) and my A06 IS 8 BITS (1 BYTES) , so we have 5*2bytes + 1byte(a06) + 1byte(X) as STX caracter, l dont use ETX(end caracter). l have 12 bytes Data Packet , right ? so my ˜c99~ string will be ~c12~ ? and my datapacket string will be X~A01~~A02~~A03~~A04~~A05~~A06~~c12~ ?

anyone with x-sim checksum experience , any help , any hope ?
adrianovrm
X-Sim Supporter
 
Posts: 214
Joined: Tue 20. Nov 2012, 07:35
Has thanked: 0 time
Been thanked: 1 time

Re: USO output to an Arduino

Postby sirnoname » Mon 13. Apr 2015, 17:37

X-Sim checksum code
Code: Select all
   current=current.Right(current.GetLength()-1);
   int before=atoi(current);   //length entry before ~cxx~
   int now=input.length; //input is current uso string translated before be sent
   char xorstring[5120]={0};
   if(now-before >= 0)
   {
      for(int z=0; z < before; z++)
      {
         xorstring[z]=input.buffer[now-(before-(z))];
      }
   }
   byte checksum=xorstring[0];
   if(before > 0)
   {
      for(int z=1; z < before; z++)
      {
         byte zahl=xorstring[z];
         checksum=checksum ^ zahl;
      }
   }
   char outsum=checksum;
   return outsum;

But I do not know how you can mix 8 and 16 bit output with USO.
Check the output with free comport monitor.
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: USO output to an Arduino

Postby adrianovrm » Mon 13. Apr 2015, 19:10

Thanks , l will analyze and test and return results to you... Well l alredy work will 16 and 8 bits axis at the same datapacket, data is retrive over arduini , byte from byte, so xor is done , one by one... l not sure l understood plenty tou concer , but l think this is not a problem for me yetr.. will analyze
adrianovrm
X-Sim Supporter
 
Posts: 214
Joined: Tue 20. Nov 2012, 07:35
Has thanked: 0 time
Been thanked: 1 time

Re: USO output to an Arduino

Postby adrianovrm » Mon 13. Apr 2015, 19:43

L study you code and l have another doubt :

am l suppose to do some kind of DLL file for compute that before xsim sends this packet over serial, at x-sim side ?

l ask that cause l was thinking in put ~c12~ at the end of my data packet(Converter) , and x-sim autmatics sends the packet with checksum calculated, then at arduino side l should recompose the calcs to see if packet is ok .. lm a bit confuse *...

L already put ~c12~ at the end of my packet that have 13 bytes , been sent over serial each 33ms intervals.
adrianovrm
X-Sim Supporter
 
Posts: 214
Joined: Tue 20. Nov 2012, 07:35
Has thanked: 0 time
Been thanked: 1 time

Re: USO output to an Arduino

Postby adrianovrm » Mon 13. Apr 2015, 19:44

they dont fit equal yet, what my mistake, cant se yet
adrianovrm
X-Sim Supporter
 
Posts: 214
Joined: Tue 20. Nov 2012, 07:35
Has thanked: 0 time
Been thanked: 1 time

Re: USO output to an Arduino

Postby adrianovrm » Mon 13. Apr 2015, 19:45

The checksum calcalte at arduino side and value received form xsim dont fit yet
adrianovrm
X-Sim Supporter
 
Posts: 214
Joined: Tue 20. Nov 2012, 07:35
Has thanked: 0 time
Been thanked: 1 time

Next

Return to Converter questions

Who is online

Users browsing this forum: No registered users and 3 guests