- Posts: 27
- Thank you received: 0
Simulator with only HAL and gladeVCP
- h_munktell
- Topic Author
- Offline
- Junior Member
-
Less
More
11 years 1 week ago #64017
by h_munktell
Simulator with only HAL and gladeVCP was created by h_munktell
Hello,
I need to set up a simulator for a machine at my work. I need to simulate different pulse trains and pulse frequency (and possible phase) drift. I imagine two HAL stepgen is the way to go. I do not want a full blown linuxcnc display like axis. Best would be to just design a gladeVCP and to be able to "script" change HAL parameter and pin values from there in a controlled way.
A test cycle for a "frequency slip" could be like this:
1. Accelerate both stepgens with a preset acceleration to the same frequency
2. Wait a defined time
3. Set acceleration value for stepgen B to another value
4. Set stepgen frequency to another value for 40mS
5. Change stepgen B maxacceleration
6. Set stepgen B freq to stepgen A freq
7. Wait defined time
8. Ramp down to zero
How would I to this scripting, with python? Someone can point me in the right direction?
Best regards
Henrik
I need to set up a simulator for a machine at my work. I need to simulate different pulse trains and pulse frequency (and possible phase) drift. I imagine two HAL stepgen is the way to go. I do not want a full blown linuxcnc display like axis. Best would be to just design a gladeVCP and to be able to "script" change HAL parameter and pin values from there in a controlled way.
A test cycle for a "frequency slip" could be like this:
1. Accelerate both stepgens with a preset acceleration to the same frequency
2. Wait a defined time
3. Set acceleration value for stepgen B to another value
4. Set stepgen frequency to another value for 40mS
5. Change stepgen B maxacceleration
6. Set stepgen B freq to stepgen A freq
7. Wait defined time
8. Ramp down to zero
How would I to this scripting, with python? Someone can point me in the right direction?
Best regards
Henrik
Please Log in to join the conversation.
11 years 1 week ago #64056
by andypugh
Replied by andypugh on topic Simulator with only HAL and gladeVCP
This doesn't sound like what is normally termed a "simulator" configuration in that it sounds like you still need hard realtime.
However, it is relatively simple (and useful) to set up a HAL-only config without the rest of Linuxcnc.
A HAL file (structured the normal way) could loadrt, addf and net the two stepgens.
I think for your test, to get a true realtime simulated "glitch" I would net the output of the unglitched stepgen to the X axis of a lincurve component, and use the Y axis of the lincurve to drive the accel of the second one.
The HAL file can provide a simple UI to drive the target positions of the stepgens.
Use "halrun" to create a realtime environment and load/execute your HAL file
www.linuxcnc.org/docs/html/man/man1/halcmd.1.html
I do a lot of my development work in exactly this way.
However...
At the moment the stepgen maxaccel is a parameter, not a HAL pin. It is of the correct type and is stored in the correct data structure to be a HAL pin, however, so it is a relatively simple change to recompile stepgen.c to make it in to a pin. You need to change line 1080
git.linuxcnc.org/gitweb?p=linuxcnc.git;a...571954;hb=HEAD#l1080
I _think_ that you should be able to recompile and install stepgen.c using "halcompile"
The same is true of the Mesa stepgens.
You can change parameters in a Python script, but not in a realtime deterministic way. Whether this would work depends on how accurate the 40mS needs to be.
However, it is relatively simple (and useful) to set up a HAL-only config without the rest of Linuxcnc.
A HAL file (structured the normal way) could loadrt, addf and net the two stepgens.
I think for your test, to get a true realtime simulated "glitch" I would net the output of the unglitched stepgen to the X axis of a lincurve component, and use the Y axis of the lincurve to drive the accel of the second one.
The HAL file can provide a simple UI to drive the target positions of the stepgens.
Use "halrun" to create a realtime environment and load/execute your HAL file
www.linuxcnc.org/docs/html/man/man1/halcmd.1.html
I do a lot of my development work in exactly this way.
However...
At the moment the stepgen maxaccel is a parameter, not a HAL pin. It is of the correct type and is stored in the correct data structure to be a HAL pin, however, so it is a relatively simple change to recompile stepgen.c to make it in to a pin. You need to change line 1080
git.linuxcnc.org/gitweb?p=linuxcnc.git;a...571954;hb=HEAD#l1080
I _think_ that you should be able to recompile and install stepgen.c using "halcompile"
The same is true of the Mesa stepgens.
You can change parameters in a Python script, but not in a realtime deterministic way. Whether this would work depends on how accurate the 40mS needs to be.
Please Log in to join the conversation.
Time to create page: 0.091 seconds
