Functional overview
-
ArtF
- Global Moderator

- Posts: 4557
- Joined: Sun Sep 05, 2010 5:14 pm
- Contact:
Re: Functional overview
>>does nothing unless preceeded with a senddata() at least once
Ill check that.. shouldnt be..
Art
Ill check that.. shouldnt be..
Art
-
Richard Cullin
- Site Admin
- Posts: 152
- Joined: Sat Jun 02, 2012 4:45 pm
Re: Functional overview
ToInt() does the trick for sendhex , will try table again
thanks
thanks
-
Richard Cullin
- Site Admin
- Posts: 152
- Joined: Sat Jun 02, 2012 4:45 pm
Re: Functional overview
ToInt() does the trick for sendtable too
next step crc calc
next step crc calc
-
ArtF
- Global Moderator

- Posts: 4557
- Joined: Sun Sep 05, 2010 5:14 pm
- Contact:
Re: Functional overview
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
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

- Posts: 4557
- Joined: Sun Sep 05, 2010 5:14 pm
- Contact:
Re: Functional overview
Richard:
Ill look at adding a crcfromtable command..
Art
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
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 );
for (inx=0;inx<6;inx+=1)
{
myser.SendHex(vfd[inx]);
CRC=Crc16(CRC,vfd[inx]);
};
print("the CRC " + CRC);
myser.SendHex(ToInt(CRC/256));
myser.SendHex(ToInt(CRC%256));
};
};
global Crc16 = function(crc,byte_in)
{
//print("CRC " + byte_in );
crc = crc ^ byte_in ;
for (c=0;c<8;c+=1){
if (crc&1)
{
crc= ((crc>>1) ^0xa001 ) ;
}
else
{
crc= crc>>1;
};
};
return ToInt(crc);
};
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 );
for (inx=0;inx<6;inx+=1)
{
myser.SendHex(vfd[inx]);
CRC=Crc16(CRC,vfd[inx]);
};
print("the CRC " + CRC);
myser.SendHex(ToInt(CRC/256));
myser.SendHex(ToInt(CRC%256));
};
};
global Crc16 = function(crc,byte_in)
{
//print("CRC " + byte_in );
crc = crc ^ byte_in ;
for (c=0;c<8;c+=1){
if (crc&1)
{
crc= ((crc>>1) ^0xa001 ) ;
}
else
{
crc= crc>>1;
};
};
return ToInt(crc);
};
-
ArtF
- Global Moderator

- Posts: 4557
- Joined: Sun Sep 05, 2010 5:14 pm
- Contact:
Re: Functional overview
Awesome.. amazing how easy it looks after you figure it out , eh? I do like GameMonkey scripting... amazingly powerfull
Art
Art
-
Richard Cullin
- Site Admin
- Posts: 152
- Joined: Sat Jun 02, 2012 4:45 pm
Re: Functional overview
I will let you know if I ever get thereamazing how easy it looks after you figure it out
slight change used tableCount() for tx loop limit
I will leave spindle off/on as the are since the data will never change
Code: Select all
// Library Vfd-Spindle
// Created Wednesday, January 04, 2017
// Author rc -- Do not edit above this line
// Enter Global vars below this line.
// the librarian no matter where they are, but its easier
// to find and edit them in one spot.
// vfd stuff
global myser = Serial();
//
global Vfd_Open = function()
{
myser.Open(6,9600);
myser.SendData("123");
print( "VFD opened");
SpindleSpeed(5500);
};
//this is a HUANYANG vfd control,
//it will use rs485 to control a spindle
//on/off spindle, and speed
global SpindleOn = function()
{
vfd={0x01,0x03,0x01,0x01,0x31,0x88};
myser.Table = vfd;
myser.SendTable();
print("Vfd Spindle was turned on");
print("Set to Frequency " + GlobalGet("SpindleSpeed"));
};
//this is a HUANYANG vfd control,
//it will use rs485 to control a spindle
//on/off spindle, and speed
global SpindleOff = function()
{
vfd= table(0x01,0x03,0x01,0x08,0xF1,0x8E);
myser.Table = vfd;
myser.SendTable();
print("Spindle speed zeroed");
};
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);
print("Frequency set to " + freq );
for (inx=0;inx<tableCount(vfd);inx+=1)
{
myser.SendHex(vfd[inx]);
CRC=Crc16(CRC,vfd[inx]);
};
print("the CRC " + CRC);
myser.SendHex(ToInt(CRC/256));
myser.SendHex(ToInt(CRC%256));
};
};
// calculate a ccitt 16 bit crc on byte at a time
// preset crc to 0xffff to initialise a new calc
global Crc16 = function(crc,byte_in)
{
//print("CRC " + byte_in );
crc = crc ^ byte_in ;
for (c=0;c<8;c+=1){
if (crc&1)
{
crc= ((crc>>1) ^0xa001 ) ;
}
else
{
crc= crc>>1;
};
};
return ToInt(crc);
};-
Amazon [Bot]
- Full Member

- Posts: 185
- Joined: Tue Jan 06, 2026 4:56 pm
Re: Functional overview
Thanks Art, but I'm closer to a "glutton for punishment".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.
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. :D
Craig
-
Richard Cullin
- Site Admin
- Posts: 152
- Joined: Sat Jun 02, 2012 4:45 pm
Re: Functional overview
had to make some more changes , vfd was not happy with the data stream from setspeed 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
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 Wednesday, January 04, 2017
// Author rc -- Do not edit above this line
// vfd stuff
// the rs485 port
global myser = Serial();
// open and init the port
global 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()
{
vfd={0x01,0x03,0x01,0x01,0x31,0x88};
myser.Table = vfd;
myser.SendTable();
print("Vfd Spindle was turned on");
print("Set to Frequency " + GlobalGet("SpindleSpeed"));
};
//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()
{
vfd= table(0x01,0x03,0x01,0x08,0xF1,0x8E);
myser.Table = vfd;
myser.SendTable();
print("Spindle speed zeroed");
};
//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 )
{
CRC=0xffff;
print("speed set to " + speed);
vfd=table(0x01,0x05,0x03,0,0,0,0,0);
freq=speed/55.0;
freq=freq*100;
vfd[3]=ToInt(freq/256);
vfd[4]=ToInt(freq%256);
print("Frequency set to " + freq );
for (inx=0;inx<(tableCount(vfd)-2);inx+=1)
{
CRC=Crc16(CRC,vfd[inx]);
};
// print("the CRC " + CRC);
vfd[7]=ToInt(CRC/256);
vfd[6]=ToInt(CRC%256);
myser.Table = vfd;
myser.SendTable();
};
// calculate a ccitt 16 bit crc on byte at a time
// preset crc to 0xffff to initialise a new calc
global Crc16 = function(crc,byte_in)
{
//print("CRC " + byte_in );
crc = crc ^ byte_in ;
for (c=0;c<8;c+=1){
if (crc&1)
{
crc= ((crc>>1) ^0xa001 ) ;
}
else
{
crc= crc>>1;
};
};
return ToInt(crc);
};