Git Product home page Git Product logo

simulator's Introduction

grblHAL SIM

What can you do with grblHAL Sim?

  • Simply check out how grblHAL works without needing a microcontroller.
  • Visualize a g-code program by having the simulator parse and execute to a GUI. Fluctuations in feed rates by the acceleration planner can be viewed as well.
  • A powerful debugging tool for development.
  • The microcontroller peripherals are emulated using structs and functions. These could be written to do whatever you need. For example, output simulated step pulses over time and examine its performance.

How do you compile grblHAL Sim?

Use the Web Builder for x86 Linux or Windows, or follow these instructions:

Clone this repositoriy

$ git clone --recurse-submodules <url> 

Create a build directory

$ cd Simulator
$ mkdir build 

Run cmake and create the binaries

$ cd build
$ cmake ..
$ make

Debugging on LINUX

On Linux, hook it to a fake serial port (/dev/ttygrblHAL) and use it to test your grblHAL interface software:

socat PTY,raw,link=/dev/ttyGRBL,echo=0,group-late=dialout,mode=660 "EXEC:'./grblHAL_sim -n -s step.out -b block.out',pty,raw,echo=0" 

After this command, the simulator is running and has a serial connection to /dev/ttyGRBL.

With Minicom you can read and write to the serial connection. Let's take a closer look.

First start minicom with

$ minicom -s

in your terminal. Then you will see a configuration window and select the serial port setup.

Minicom Menu

In the setup press the A key and change the serial device to GRBL.

Minicom Serial

Now exit the setup and configuration and you will see the connection to our grblHAL simulator. Press $ + Return for your first help command.

Minicom Connected

Realtime modifications:

Now simulates microcontroller peripherals in separate thread. Runs in aproximate realtime. Emphasis on * Approximate *. Work is underway to speed it up.

Validator

Run

$ grblHAL_validator GCODE_FILE

to validate that grblHAL will parse your GCODE with no errors.

Raw telnet connection

NEW

Use the -p <port> command line argument to start a raw telnet server for communication instead of using serial simulation via stdin/stdout. This frees up stdin for input to trigger hardware events such as feed hold, cycle start or setting/clearing limit switches.

Maintainers

  • Created by Jens Geisler, Adam Shelly

  • Modified by Terje Io for grblHAL. Original implementation for Grbl can be found here.

This repository contains an experimental grblHAL simulator that compiles the main grblHAL source code into a wrapped executable for use on a computer. No microcontroller required. When the executable is run, the user should be able to interact with the grblHAL simulator as if connected to a microcontroller board with grblHAL.

WARNING: grblHAL Sim is under heavy development. So many things may not work, or respond in ways unexpected. At the moment, this code is a proof-of-concept.


2023-09-27

simulator's People

Contributors

infnorm avatar terjeio avatar vgerber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

simulator's Issues

Cannot compile for Windows

When i try to build the project i get the following error:

src\main.c(30,10): fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory

I'm using Windows 11, vscode with C/C++ Tools and CMake Tools extensions. I allow cmake to configure the project which it seems to do without a problem. But when I try to build I get the above compilation errors.
After searching I found that unistd.h (and possibly other header files) are specific to UNIX operating systems. I have run the project in WSL (Linux kernal on Windows) and it works fine. Maybe this project hasn't been ported to windows yet? Any help or insight into the matter is deeply appreciated.

Thank you :)

Simulator incompatible with last CORE

After last updates simulator code become incompatible with current grblHAL core, available by reference.
try to build it end with errors

driver.c: In function ‘driver_init’:
driver.c:446:20: error: ‘driver_cap_t’ has no member named ‘spindle_dir’; did you mean ‘spindle_pid’?
446 | hal.driver_cap.spindle_dir = On;
| ^~~~~~~~~~~
| spindle_pid
driver.c:448:19: error: ‘driver_cap_t’ has no member named ‘variable_spindle’
448 | hal.driver_cap.variable_spindle = On;
| ^

Error on launch: child exited on signal 11

I'm fairly new at this, and hoping to use the simulator so that I can test serial-port command streams without needing to be physically tethered to a machine.

I've tried both compiling with cmake myself, and the web-builder's binary, both cause the same issue.
I'm on Mint 21.3 (recent switch from Ubuntu), and I may have some permissions missing. If I run the given socat command as described in the README, I get a "permission denied" when attempting to create the /dev/ttyGRBL port.

When I run the same command with sudo, I get the following output (with a changing child process ID):

john@Eitri:~/tools/Grblhal-sim$ sudo socat PTY,raw,link=/dev/ttyGRBL,echo=0,group-late=dialout,mode=660 "EXEC:'./grblHAL_sim -n -s step.out -b block.out',pty,raw,echo=0" 
2024/03/02 21:02:34 socat[6196] E waitpid(): child 6197 exited on signal 11

Any idea what could be causing this?

"The specified File could not be found" error during running Make cmd.

Hello,
Firsty, I have downloaded repository https://github.com/grblHAL/STM32F4xx with submodules, then I cloned this repository into the grbl directory of STM32F4xx.
Just like the manual says I modified Makefile (change platform to Windows and also changed paths to files: GRBL_BASE_OBJECTS are in the parent directory, other files are in the current).

Unfortunately I still receiving error, that specified file cannot be found. The error suggests there is problem with grbl_interface file, so i also updated paths here, but it didnt solve problem.

make

Poniżej fragment Makefile
`
PLATFORM = WINDOWS

GRBL_BASE_OBJECTS = ../grbllib.o ../protocol.o ../planner.o ../settings.o ../nuts_bolts.o ../stepper.o ../gcode.o ../stream.o ../spindle_control.o ../motion_control.o ../limits.o ../coolant_control.o ../system.o ../report.o ../state_machine.o ../override.o ../nvs_buffer.o ../sleep.o ../tool_change.o ../my_plugin.o

SIM_OBJECTS = main.o simulator.o driver.o eeprom.o grbl_eeprom_extensions.o mcu.o serial.o platform_$(PLATFORM).o

GRBL_SIM_OBJECTS = grbl_interface.o $(GRBL_BASE_OBJECTS) $(SIM_OBJECTS)
GRBL_VAL_OBJECTS = validator.o validator_driver.o $(GRBL_BASE_OBJECTS)

CLOCK = 16000000
SIM_EXE_NAME = grbl_sim.exe
VALIDATOR_NAME = gvalidate.exe
FLAGS = -g -O3
COMPILE = $(CC) -Wall $(FLAGS) -DF_CPU=$(CLOCK) -I. -DPLAT_$(PLATFORM)
LINUX_LIBRARIES = -lrt -pthread
OSX_LIBRARIES =
WINDOWS_LIBRARIES =

all: main gvalidate

new: clean main gvalidate

clean:
rm -f $(SIM_EXE_NAME) $(GRBL_SIM_OBJECTS) $(VALIDATOR_NAME) $(GRBL_VAL_OBJECTS)

main: $(GRBL_SIM_OBJECTS)
$(COMPILE) -o $(SIM_EXE_NAME) $(GRBL_SIM_OBJECTS) -lm $($(PLATFORM)_LIBRARIES)

gvalidate: $(GRBL_VAL_OBJECTS)
$(COMPILE) -o $(VALIDATOR_NAME) $(GRBL_VAL_OBJECTS) -lm $($(PLATFORM)_LIBRARIES)

%.o: %.c
$(COMPILE) -c $&lt; -o $@

grbl/planner.o: grbl/planner.c
$(COMPILE) -include planner_inject_accessors.c -c $&lt; -o $@
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.