Functional overview

Discussions and file drops for Auggie
Post Reply
ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: Functional overview

Post by ArtF »

>>does nothing  unless preceeded with a senddata()  at least once

Ill check that.. shouldnt be..

Art
Richard Cullin
Site Admin
Posts: 152
Joined: Sat Jun 02, 2012 4:45 pm

Re: Functional overview

Post by Richard Cullin »

ToInt()  does the trick for sendhex , will try table again

thanks
Richard Cullin
Site Admin
Posts: 152
Joined: Sat Jun 02, 2012 4:45 pm

Re: Functional overview

Post by Richard Cullin »

ToInt()  does the trick for sendtable too 
next step crc calc
ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: Functional overview

Post by ArtF »

No problem, glad to know VFDs can work in Auggie. Ive been burning tests again lately,it  feels good to be using it
again, I've been so busy coding I hadnt done much cutting. Auggie impresses me more each time I use it lately.
 I see errors I need to fix and small troubles I'd like to change, but overall its treating me pretty good, like an old
reliable, turn it on and it burns..

 Each of your troubles has fixed a primary interface, so it shows how much testing can help. YaNvrNo helps me a
tremendous amount in primary testing , Ive crashed him hundreds of times.. (probably thousands..), so I
really have to hand it to him for stamina. The result is a controller thats a bit scary internally as it does so many things,
but for all that probably as reliable as Mach3 is on my mill at this point, better in terms of starting over or after a
pause. Never thought Id make another controller..but this one is purely for fun, that's why its free.   So keep testing.. :-)
 

Good luck
Art
ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: Functional overview

Post by ArtF »

Richard:

Ill look at adding a crcfromtable command..

Art
Richard Cullin
Site Admin
Posts: 152
Joined: Sat Jun 02, 2012 4:45 pm

Re: Functional overview

Post by Richard Cullin »

100% SUCCESS


global SpindleSpeed = function( speed )
{
    if( Engine.GetSpindleState() != 0)
    {
      CRC=0xffff;
      print("speed set to " + speed);
      vfd=table(0x01,0x05,0x03,0,0,0);
      freq=speed/55.0;
      freq=freq*100;
      vfd[3]=ToInt(freq/256);
      vfd[4]=ToInt(freq%256);
     
      FreeSetSpeed( MySpindleAxis, speed);
      print("Frequency  set to " + freq );

&nbsp; &nbsp; &nbsp; for (inx=0;inx<6;inx+=1)
&nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; myser.SendHex(vfd[inx]);
&nbsp; &nbsp; &nbsp; CRC=Crc16(CRC,vfd[inx]);
&nbsp; &nbsp; &nbsp; };
&nbsp; &nbsp; print("the CRC " + CRC);
&nbsp; &nbsp; &nbsp; myser.SendHex(ToInt(CRC/256));
&nbsp; &nbsp; &nbsp; myser.SendHex(ToInt(CRC%256));
&nbsp; &nbsp; };

};&nbsp;

global&nbsp; Crc16 = function(crc,byte_in)
{
//print("CRC " + byte_in );
crc = crc ^&nbsp; byte_in ;
&nbsp; &nbsp; &nbsp; for (c=0;c<8;c+=1){
&nbsp; &nbsp; &nbsp; &nbsp; if (crc&1)
&nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; crc= ((crc>>1) ^0xa001 )&nbsp; ;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; else
&nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; crc= crc>>1;
&nbsp; &nbsp; &nbsp; &nbsp; };
&nbsp; &nbsp; &nbsp; };
return ToInt(crc);
};
ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: Functional overview

Post by ArtF »

Awesome.. amazing how easy it looks after you figure it out , eh? I do like GameMonkey scripting... amazingly powerfull

Art
Richard Cullin
Site Admin
Posts: 152
Joined: Sat Jun 02, 2012 4:45 pm

Re: Functional overview

Post by Richard Cullin »

amazing how easy it looks after you figure it out
I will let you know if I ever get there

slight change used tableCount()&nbsp; for tx loop limit
I will leave spindle off/on&nbsp; as the are since the data will never change

Code: Select all


// Library Vfd-Spindle 
// Created&nbsp; Wednesday, January 04, 2017 
// Author&nbsp; rc&nbsp; &nbsp; &nbsp;  -- Do not edit above this line
&nbsp; 
 //&nbsp; Enter Global vars below this line. 
//&nbsp; the librarian no matter where they are, but its easier 
//&nbsp; to find and edit them in one spot.
&nbsp;  
&nbsp;  
&nbsp;  
//&nbsp; vfd stuff
&nbsp;  
global&nbsp;  myser = Serial();
 
 
// 
global&nbsp; Vfd_Open = function()
{
myser.Open(6,9600);
myser.SendData("123");
print( "VFD opened"); 
SpindleSpeed(5500);
};
 
//this is a&nbsp; HUANYANG vfd&nbsp;  control, 
//it will use rs485&nbsp; to control a spindle
//on/off spindle, and speed 

global SpindleOn = function()
{
&nbsp; &nbsp; vfd={0x01,0x03,0x01,0x01,0x31,0x88}; 
&nbsp; &nbsp; myser.Table = vfd;
&nbsp; &nbsp; myser.SendTable();
&nbsp; &nbsp; print("Vfd Spindle was turned on");
&nbsp; &nbsp; print("Set to Frequency " + GlobalGet("SpindleSpeed"));
};&nbsp;  
 
//this is a&nbsp; HUANYANG vfd&nbsp;  control, 
//it will use rs485&nbsp; to control a spindle
//on/off spindle, and speed&nbsp; 

global SpindleOff = function()
{
&nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; vfd= table(0x01,0x03,0x01,0x08,0xF1,0x8E); 
&nbsp; &nbsp; myser.Table = vfd;
&nbsp; &nbsp; myser.SendTable();
&nbsp; &nbsp; print("Spindle speed zeroed");
&nbsp; &nbsp; 
};&nbsp; 
 
 
global SpindleSpeed = function( speed )
{
&nbsp; &nbsp; if( Engine.GetSpindleState() != 0)
&nbsp; &nbsp;  {
&nbsp; &nbsp; &nbsp; CRC=0xffff;
&nbsp; &nbsp; &nbsp; print("speed set to " + speed); 
&nbsp; &nbsp; &nbsp; vfd=table(0x01,0x05,0x03,0,0,0); 
&nbsp; &nbsp; &nbsp; freq=speed/55.0;
&nbsp; &nbsp; &nbsp; freq=freq*100;
&nbsp; &nbsp; &nbsp; vfd[3]=ToInt(freq/256);
&nbsp; &nbsp; &nbsp; vfd[4]=ToInt(freq%256);&nbsp; 
&nbsp; &nbsp; &nbsp; print("Frequency&nbsp; set to " + freq );
&nbsp; &nbsp; &nbsp; for (inx=0;inx<tableCount(vfd);inx+=1)
&nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; myser.SendHex(vfd[inx]);
&nbsp; &nbsp; &nbsp; CRC=Crc16(CRC,vfd[inx]);
&nbsp; &nbsp; &nbsp; };
&nbsp; &nbsp; &nbsp; print("the CRC " + CRC);
&nbsp; &nbsp; &nbsp; myser.SendHex(ToInt(CRC/256));
&nbsp; &nbsp; &nbsp; myser.SendHex(ToInt(CRC%256));
&nbsp; &nbsp;  };
 
};&nbsp;  
 
// calculate a ccitt 16 bit crc on byte at a time
// preset crc to 0xffff to initialise a new calc



global&nbsp; Crc16 = function(crc,byte_in)
{
 //print("CRC " + byte_in );
 crc = crc ^&nbsp; byte_in ;
&nbsp; &nbsp; &nbsp; for (c=0;c<8;c+=1){
&nbsp; &nbsp; &nbsp; &nbsp;  if (crc&1)
&nbsp; &nbsp; &nbsp; &nbsp;  { 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  crc= ((crc>>1) ^0xa001 )&nbsp;  ;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp;  else
&nbsp; &nbsp; &nbsp; &nbsp;  {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  crc= crc>>1;
&nbsp; &nbsp; &nbsp; &nbsp;  };
&nbsp; &nbsp; &nbsp;  };
return ToInt(crc);
};
Amazon [Bot]
Full Member
Full Member
Posts: 185
Joined: Tue Jan 06, 2026 4:56 pm

Re: Functional overview

Post by Amazon [Bot] »

ArtF wrote: YaNvrNo helps me a tremendous amount in primary testing , Ive crashed him hundreds of times.. (probably thousands..), so I
really have to hand it to him for stamina.
Thanks Art, but I'm closer to a "glutton for punishment".

Admit I pushed you steadily with feedback, ideas and questions, as I knew that we both wanted a dedicated CNC laser controller. Then onto a robust toolbox of goodies including scripting to develop out of the box concepts for experimenting. The big plus is you have taught us a lot of things we never would have experienced without your creative abstract thinking, persistence and ability to bring it to life.

Still have a growing wish list. So we all are not done yet. &nbsp;:D

Craig
Richard Cullin
Site Admin
Posts: 152
Joined: Sat Jun 02, 2012 4:45 pm

Re: Functional overview

Post by Richard Cullin »

had to make some more changes , vfd was not happy with&nbsp; the data stream from setspeed&nbsp; for some reason [there was 2 or 3 mS gaps between bytes]
would make a crctable function a nice feature
can't figure how to add elements to a table yet either ,that would be useful



this is much better

Code: Select all

// Library Vfd-Spindle 
// Created&nbsp; Wednesday, January 04, 2017 
// Author&nbsp; rc&nbsp; &nbsp; &nbsp;  -- Do not edit above this line
&nbsp; 

&nbsp;  
&nbsp;  
//&nbsp; vfd stuff
//&nbsp; the rs485 port&nbsp;  
global&nbsp;  myser = Serial();




 
 
// open and init the port 


global&nbsp; Vfd_Open = function()
{
myser.Open(7,9600);
myser.SendData("123");
print( "VFD opened"); 

};
 
//this is a HUANYANG vfd spindle control, 
//it will use only rs485 port
//to control a the spindle
//on/off spindle, on or off and speed

global SpindleOn = function()
{
&nbsp; &nbsp; 
&nbsp; &nbsp; vfd={0x01,0x03,0x01,0x01,0x31,0x88}; 
&nbsp; &nbsp; myser.Table = vfd;
&nbsp; &nbsp; myser.SendTable();
&nbsp; &nbsp; print("Vfd Spindle was turned on");
&nbsp; &nbsp; print("Set to Frequency " + GlobalGet("SpindleSpeed"));
};&nbsp;  
 
//this is a HUANYANG vfd spindle control, 
//it will use only rs485 port
//to control a the spindle
//on/off spindle, on or off an speed
 
global SpindleOff = function()
{
&nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; vfd= table(0x01,0x03,0x01,0x08,0xF1,0x8E); 
&nbsp; &nbsp; myser.Table = vfd;
&nbsp; &nbsp; myser.SendTable();
&nbsp; &nbsp; print("Spindle speed zeroed");
&nbsp; &nbsp; 
};&nbsp; 
 

//this is a HUANYANG vfd spindle control, 
//it will use only rs485 port
//to control a the spindle
//on/off spindle, on or off an speed
 
global SpindleSpeed = function( speed )
{
 
&nbsp; &nbsp; &nbsp; CRC=0xffff;
&nbsp; &nbsp; &nbsp; print("speed set to " + speed); 
&nbsp; &nbsp; &nbsp; vfd=table(0x01,0x05,0x03,0,0,0,0,0); 
&nbsp; &nbsp; &nbsp; freq=speed/55.0;
&nbsp; &nbsp; &nbsp; freq=freq*100;
&nbsp; &nbsp; &nbsp; vfd[3]=ToInt(freq/256);
&nbsp; &nbsp; &nbsp; vfd[4]=ToInt(freq%256);&nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; print("Frequency&nbsp; set to " + freq );
&nbsp; &nbsp; &nbsp; for (inx=0;inx<(tableCount(vfd)-2);inx+=1)
&nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CRC=Crc16(CRC,vfd[inx]);
&nbsp; &nbsp; &nbsp; };
&nbsp; &nbsp; &nbsp; // print("the CRC " + CRC);
&nbsp; &nbsp; &nbsp; vfd[7]=ToInt(CRC/256);
&nbsp; &nbsp; &nbsp; vfd[6]=ToInt(CRC%256);
&nbsp; &nbsp; &nbsp; myser.Table = vfd;
&nbsp; &nbsp; &nbsp; myser.SendTable();
};&nbsp; 


// calculate a ccitt 16 bit crc on byte at a time
// preset crc to 0xffff to initialise a new calc


 
 
global&nbsp; Crc16 = function(crc,byte_in)
{
 //print("CRC " + byte_in );
 crc = crc ^&nbsp; byte_in ;
&nbsp; &nbsp; &nbsp; for (c=0;c<8;c+=1){
&nbsp; &nbsp; &nbsp; &nbsp;  if (crc&1)
&nbsp; &nbsp; &nbsp; &nbsp;  { 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  crc= ((crc>>1) ^0xa001 )&nbsp;  ;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp;  else
&nbsp; &nbsp; &nbsp; &nbsp;  {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  crc= crc>>1;
&nbsp; &nbsp; &nbsp; &nbsp;  };
&nbsp; &nbsp; &nbsp;  };
return ToInt(crc);
};
 

 
 
 
Post Reply