-
-
Notifications
You must be signed in to change notification settings - Fork 529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Control of a VFD Spindle over RS485, ie a second serial port. #24
Comments
Cool. I think I have one of those VFDs. I might be able to test it. do you have a schematic of the whole setup. |
I'll try and draw up one tomorrow. |
Here is an approximate schematic of my setup. I've used the adafruit level shifter , but I couldn't find an eagle library for it , so I've drawn it up with the sparkfun one. The pinout is slightly different . |
I've now tried this with an equivalent level shifter to the sparkfun one ( clone ) |
I like your suggestion of the option of using the existing PWM pin. Have you ever used RS485 transceivers with auto direction control ? |
:) |
To run the motor use the G-code command : Various debugging messages, written to Serial1 , can be enabled by defining DEBUGSERIAL in VFD.h I've hard coded the BAUD rate to 38400 binary 8N1 , PD164 needs setting to 3 for this PD01 and PD02 need setting to 2 to respond to stop/start and speed commands I think this is the last of the things I set up , but most was done along while ago , and while my memory is quite good ..... |
I think RPM is modal, like feedrate. S500 ;set rpm but don't turn on spindle You can see all modal values at any time by sending $G |
Check out this one. SMAKN® SCM TTL to RS485 Adapter 485 to Serial Port UART Level Converter Module 3.3V 5V https://www.amazon.com/dp/B010723BCE/ref=cm_sw_r_cp_apa_o4.IBbAXJ4E04 3.3v and direction control |
yes I would agree re RPM , but grbl doesn't seem to behave quite like that for me. I'm sure that no commands were getting thru properly to any functions in spindle_control.c wheen I did this with grbl-Mega, though I'll investigate further with this setup . I've just configured my g-code generator to use full commands like I listed above. |
I've ordered a couple on the 485 converters you list above off ebay from china, for about $2 each . On the subject of saving pins , do you know if it is possible to allocate inputs and outputs , to unexposed GPIO pins ,( 20,24,28,29,30,31) (37,38 have no pull up resistor , so I wouldn't try these ) so their pins could be used for other purposes , I'm thinking 4th axis as an example. |
Only TX is really needed, as the RS-485 driver may be kept enabled all the
time and RX can be ignored. Of course, if you do that there is no feedback
from the VFD but it is definitely a possibility to save pins.
…On Sun, Sep 2, 2018 at 6:33 PM davehines91 ***@***.***> wrote:
I've ordered a couple on the 485 converters you list above off ebay from
china, for about $2 each .
I'll try them when they arrive, The ESP32 is little short on available
pins , so any we can save will be a bonus
On the subject of saving pins , do you know if it is possible to allocate
inputs and outputs , to unexposed GPIO pins ,( 20,24,28,29,30,31) (37,38
have no pull up resistor , so I wouldn't try these ) so their pins could be
used for other purposes , I'm thinking 4th axis as an example.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#24 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAccyJeAMnanlEd7iZ35Vys2kSx8uabvks5uXAg2gaJpZM4WWYqQ>
.
|
I considered that when I first implement the motor control on the Mega, but I consider it safer to wait til the motor has run up to speed before continuing. so feedback is required IMHO. |
@davehines91 let me elaborate a bit more: for starting/stopping or setting the RPMs only TX is needed if you agree on giving up feedback. Otherwise, you need 3 I/O pins and can raise an error condition when, for example, the spindle is not starting up as requested so a tool will not be broken. I guess the module above does use TX signal activity to trigger a timer to enable the driver output thus saving one output pin. |
@misan I agree, |
@davehines91 unexposed GPIO pins. I don't know. It is probably easier to use something like Ultimately the use of an I/O expander will be supported for low speed I/O, but the initial goal is to get all features working for a basic machine in a single chip (ESP32) solution. |
@bdring #ifdef, yes , I would agree , I was just trying to make minimal changes. I like the idea of an IO expander , though I'm more than happy with your port so far . |
@davehines91 I was not so careful. I started by checking VFD response http://fightpc.blogspot.com/2014/10/vfd-control-with-arduino-using-rs485.html but ended up ignoring it in a patch I made for Marlin firmware. Someone suggested me to forward the patch for GRBL which I did but that was considered too specific a feature. |
@misan , yes I got the too specific a feature response as well , that's why I've implemented the interface to grbl in just the spindle_control.cpp file , so its easy for anyone to put in , or take out. |
I've just pushed a change to my repo which fixes this behaviour |
Can you please send your huanyang VFD RS485 code to this issue? terjeio/grblHAL#68 |
This is a port from my unpublished, but well used work using grbl-Mega
Background :
I currently use grbl-Mega to control a DIY CNC router with a work area of about 600mm x 900mm.
The spindle I currently use is an 800w spindle controlled by a 1.5KW Huanyang Variable Frequency Drive (HY01D523B) . I was looking for a more convenient platform than the Mega , and stumbled upon the ESP32 port.
Testing :
So far I've tested this with the ESP32 dev module in a breadboard , controlling a single axis , and a RS485 module , connected via a levelshifter breakout board to the ESP32 . (Note , the 3.3v version did not work well for me ) .
This setup was used to connect to the VFD over the RS485 interface.
Implementation:
The RS485 link is a two wire differential half duplex interface. The controller needs to assert a send signal
as it transmits , I've controlled this with a timer interrupt ( I've used timer 3 ) . The timer is restarted as each character is transmitted , so the transmit is held high for 4mS after the last character is send , the response is then awaited for by a task , shamelessly cloned from the main serial task. This task checks for the correct response from the VFD , and in the case of the speed request , holds up any further command processing , until the spindle has reached the required speed. If it fails to reach the required speed, the motor is sent the stop command, and an alarm ( 10) is raised.
All the interface to grbl has been implemented within spindle_control.cpp and is enabled or disabled via the Macro RS485_HUANYANG_MOTORCONTROL , currently defined in config.h. The pins used are defined in cpu_map.h , these could be the same three pins currently used by grbl for pwm control, but I've left this code in place in parallel at the moment.
To run the motor use the G-code command :
M3 S10000
To Stop the Motor use:
M5 S0
grbl doesn't seem to like commands like M5 or M3 without a speed .
Various debugging messages, written to Serial1 , can be enabled by defining DEBUGSERIAL in VFD.h
I've hard coded the BAUD rate to 38400 binary 8N1 , PD164 needs setting to 3 for this
baud rate. similarly PD165 should be set to 3 for binary 8N1 comms.
PD01 and PD02 need setting to 2 to respond to stop/start and speed commands
over RS485.
Repo currently at https://github.com/davehines91/Grbl_Esp32
The text was updated successfully, but these errors were encountered: