Show Posts
Pages: 1 2 3 [4] 5 6 ... 37
46  Using Arduino / Programming Questions / Re: Servo's spasm while sending code via serial with C++. Skipping data? on: February 07, 2013, 06:43:49 pm
Don't allow your pc to spit data at its whim, force it to wait for an acknowledge that the command currently executing has completed.
47  Using Arduino / Programming Questions / Re: For loop initializer, and increment on: May 06, 2012, 04:08:27 pm
I was curious because my polar functions returned abnormally fast, ie the mechanics didn't move at all. i did however note that I had not explicitly typcast back to integer when saving the results to my integer based coordinate points.
48  Using Arduino / Programming Questions / For loop initializer, and increment on: May 06, 2012, 03:55:52 pm
Does 'for(;;)' accept floats? Or will Inflate to integers then downscale within the loop code for use in calculations?
49  Using Arduino / Programming Questions / Re: Robot Arm 6 degrees of freedom servo and c# on: April 24, 2012, 08:50:45 pm
In my milling machine control I use a string to recieve the serial transmission then convert it to a character array after an end of transmission char is recieved. The numerical data is sent in hexadecimal ensuring that no valid numerical data gets misinterpreted as an end of transmission.
From the charracter array I have fixed byte positions for the beginning of each field. A user function reads characters then converts the hex char to its hex numerical counterpart and concates the group of chars one at a time into the appropriate byte locations. See below:
My command resembles MA 01FA 2EE7 *
I have up to 55 characters including whitespace allocated. The whitespace is a human reading aide and has no bearing on fetching the field data.
Code:
String HexToInt = "0123456789ABCDEFX";
//The 'X' is included so that I can get a return value indicating an ignored field.

int Chex(char symbol)
{
  int temp;
  temp = HexToInt.indexOf(symbol);
  if(temp==16)
    {
      return -1; //An ignored field
    }
  else
    {
      return temp;
    }
}
int GetValueFromString(char * buffer, int offset)
  {
    int temp;
    int j;
    int Ignored;
    for(j=0; j<=3; j++)
      {
         temp = Chex(buffer[ j + offset])
         if(temp==-1)
           {
              Ignored = -1;
           }
      }
    if(Ignored != -1)
      {
        temp = Chex(buffer[ offset]) * 4096;
        temp = temp + Chex(buffer[1 + offset]) * 256;
        temp = temp + Chex(buffer[2 + offset]) * 16;
        temp = temp + Chex(buffer[3 + offset]);
        return temp;
       }
     else
       {
         return '/0';
       }
   }
 
50  Using Arduino / Programming Questions / Re: Will a switch case statement Question on: April 24, 2012, 07:10:29 pm
JFYI Nick, I have a BX verb for box, and is working sweetly, aside from pole slip in the motors due to binding in the Y slide leadscrew. But this is a mechanical issue and the total matmatical error from start to finish has been +- 1 from the beginning coordinate. Not too bad if not allowed to propagate, and equates to only .05 thousandth of an inch on the table @ a scaling factor of 1. I really need to get the GUI written to a reasonable operating level, entering signed hex values is getting to exceed annoying when using the serial monitor as a interface.
51  Using Arduino / Programming Questions / Re: Will a switch case statement Question on: April 24, 2012, 06:59:07 pm
word. as in 2 unsigned integers. The case value is a verb in hexadecimal form. Verb is literally the hex value of 2 ascii characters BE, MA ect.
52  Using Arduino / Programming Questions / Re: Will a switch case statement Question on: April 24, 2012, 06:33:09 pm
The switch structer is quite lengthy so I will post a short form version. However  I have already added a if statement to look for a verb changed flag and rerun the ExecuteMovement();
Code:
....in void loop()
.....
    ExecuteMovement();
    if(CodeChangedVerb)
      {
        CodeChangedVerb = false;
        ExecuteMovement();
      }
....
}
within ExecuteMovement()..
Code:
switch (ThisOperation.Verb)
{
.........
  case 0x4241: //'BA' or 'ba' Batch apend. Adds a command to the batch job.
    {
        if((sizeof(Batches) - 1)<= BatchItem)
           {
        Batches[BatchItem] = ThisOperation;
        Batches[BatchItem].Verb = QueuedVerb;
        BatchItem ++;
           }
        break;
      }
  case 0x4245: //'BE' or 'be' Batch Execute.
    {
        if(IsBusy == true)
          {
             if(BatchItem<= (sizeof(Batches) - 1))
             ThisOperation = Batches[BatchItem]
             CodeChangedVerb = true;
             BatchItem ++;
          }
       else
         {
        BatchItem = 0;
        IsBusy = false;
         }
       break;
Within BE //Batch Execute case, the batch item is copied to the current command ThisOperation.
Of course the element ThisOperation.Verb has now changed. The question was will the cases be reassessed or will it rely on the flags for re entry.
53  Using Arduino / Programming Questions / Will a switch case statement Question on: April 24, 2012, 05:53:59 pm
If I do not include a break statement in a case branch will the switch be reassessed after exiting the branch? I wish to modify the variable assessed in the switch clause while within a case that is currently true. I can set a flag when I altered the conditions and have the main loop re run the function containing the switch tree.
54  Using Arduino / Programming Questions / Re: Intermittent compiler complaints of 'Point' does not define a type on: April 22, 2012, 08:00:53 pm
the switchcase statement reduced to this:
Code:
case 0x4D41: //Move Absolute 'MA' or 'ma' Cutter is moved to Begin.X and Begin.Y then moved to Finish.X and Finish.Y
  {
    if((Current.X != ThisOperation.Begin.X)||(Current.Y != ThisOperation.Begin.Y))
     {
        VectorMove(Current, ThisOperation.Begin);
      }
    VectorMove(ThisOperation.Begin, ThisOperation.Finish);
    break;
  }
For the record the forum needs to look for Chr(09) 'tab' and replace it with Chr(32) Chr(32). This re edit is nothing short of a pain.
55  Using Arduino / Programming Questions / Re: Intermittent compiler complaints of 'Point' does not define a type on: April 22, 2012, 07:18:08 pm
It was not intended as an assignment but was in a conditional comparison. I have gone through near 50 variations of the MA case code, and have reduced it to a vectorMove function and do my monkey business by swapping what i send the function. It also had the benefit of cropping almost 1kb of code in the compiled product. If you want the current ino let me knoe, and I'll post it, otherwise I'll continue on to a more complete command set.
56  Using Arduino / Programming Questions / Re: Intermittent compiler complaints of 'Point' does not define a type on: April 22, 2012, 10:29:23 am
The Y error was due to not closing the command with a whitespace char.
MA 1234 4567 89FA BCDE* although reporting back on the acknowledge as 'MA 1234 4567 89FA BCDE' was being processed into the command
structure as 'MA 1234 4567 89FA BCD'. I did not find this until I added a code for querying the current coordinate and discovered
RP* did not report but RP * did.
For those who are reading and may not know the format based on reading the code....
Verb (2 bytes) space BeginX (4 Bytes) space BeginY (4 Bytes) space FinishX ( 4 Bytes) space FinishY (4 Bytes) space ArcCenterX (4 Bytes) space ArcCenterY (4 Bytes) space BeginAngle (4 bytes) space EndingAngle (4 Bytes) space ToolDiameter (4 Bytes) space ToolBias (1 Byte) space * (end of command).
Some commands do not use all fields and in those cases all fields right of the last applicable field are not sent and the * appears at the begin of the next field, unused fields between the verb field and the end of command are filled with XXXX. An 'X' causes the Chex function to return a -1 which is an invalid hexadecimal value as -1 would be FE. My command set is growing faster than I can code the commands I already wanted. I am however making strides toward the end goal with one squashed bug at a time! If you are merely "browsing" and have a question of curiosity ask it please! It may not be as dumb of a question as you might convince yourself it is.
57  Using Arduino / Programming Questions / Re: Intermittent compiler complaints of 'Point' does not define a type on: April 22, 2012, 07:50:49 am
While running the machine making test cuts I noted my Current cursor is remaining 0,0. Is this statement being interpreted as 'A replaced with NOT B'?
Code:
Current.X != ThisOperation.Begin.X
Where my premise was != meant the same as <> or not equal to.
58  Using Arduino / Programming Questions / Re: Intermittent compiler complaints of 'Point' does not define a type on: April 22, 2012, 07:45:52 am
I attached the modified lib and header, but to get it to compile on your system without changing Servo libraries change the calls to X_Axis.step() and Y_Axis.step() to read 1 * DD.
59  Using Arduino / Programming Questions / Re: Intermittent compiler complaints of 'Point' does not define a type on: April 21, 2012, 08:47:52 pm
My servo lib is a modified one such that the step member returns a 1 if a step occours and a 0 if it didn't.
60  Using Arduino / Programming Questions / Re: Intermittent compiler complaints of 'Point' does not define a type on: April 21, 2012, 08:43:52 pm
Code attached. I have it operating on the mill. I get 0.05 mil/step so an integer is going to be too small but will do fine while I develop the routines.
Pages: 1 2 3 [4] 5 6 ... 37