new hal modul
17 Dec 2020 07:31 #192231
by Grotius
Replied by Grotius on topic new hal modul
@ Rod,
Its good to see grotius helping. I helped him a lot when he was learning C so now he's paying it forward!
Thanks for helping me in the past Rod !
How is life in Australia at the moment?
Its good to see grotius helping. I helped him a lot when he was learning C so now he's paying it forward!
Thanks for helping me in the past Rod !
How is life in Australia at the moment?
Please Log in or Create an account to join the conversation.
17 Dec 2020 07:43 #192233
by rodw
Pretty busy actually. Not enough time to play with plasma cutters!
Replied by rodw on topic new hal modul
@ Rod,
Its good to see grotius helping. I helped him a lot when he was learning C so now he's paying it forward!
Thanks for helping me in the past Rod !
How is life in Australia at the moment?
Pretty busy actually. Not enough time to play with plasma cutters!
The following user(s) said Thank You: Grotius
Please Log in or Create an account to join the conversation.
17 Dec 2020 15:57 - 17 Dec 2020 16:00 #192254
by chris@cnc
Replied by chris@cnc on topic new hal modul
Its working now. And Rod you are right Syntaxis cleaner. Is only one variable necessary and in halshow is timer now only 0.3 digit variable.
For everyone how need one timer output control. May its also useful for flashing signal light.
timer += fperiod;
For everyone how need one timer output control. May its also useful for flashing signal light.
Warning: Spoiler!
component mist " ";
description
"""
//Compile :
//halcompile --compile mist.comp
//sudo halcompile --install mist.comp
//Halfile load :
//loadrt mist
//addf mist.0 servo-thread
//setp mist.0.TimerOn 30
//setp mist.0.TimerOff 300
/* 4 way input Modul with Timercontrol output
Input 0 = output 1
Input 1 && Input 2 = output 1
Input 2 && Input 3 = Timer On output 1 && Timer Off output 0
*/
""";
author "Chris@cnc";
license "GPL";
// Input pins
pin in bit in0=0;
pin in bit in1=0;
pin in bit in2=0;
pin in bit in3=0;
pin in float TimerOn = 30; //this value can be overwrited by setp command.
pin in float TimerOff = 300;
// Output pins
pin out bit on=0;
pin out float timer=0; //output for debug
// Global variables
//variable float timer=0;
function _;
;;
#include "rtapi_math.h"
FUNCTION(_) {
if(in0) {
on=1;
}
else if(in1 && in2) {
on=1;
}
else if(in2 && in3){
// Timer
timer += fperiod;
if(timer <= TimerOn /*calculating on time*/) {
on=1;
}
if(timer > TimerOn && timer <= TimerOff /*calculating off time*/){
on=0;
}
if(timer >= TimerOn + TimerOff /*Set Timer zero*/){
timer=0;
}
}
else {
on=0;
}
}
Last edit: 17 Dec 2020 16:00 by chris@cnc.
The following user(s) said Thank You: rodw
Please Log in or Create an account to join the conversation.
17 Dec 2020 22:10 #192274
by Himarc3D
Replied by Himarc3D on topic new hal modul
Linuxcnc have classic ladder and its powerful.
For one timer control 3 rungs you can get it, C/C++ is best for complex task like motion control.
The classic ladder editor you can see the the status of variable, status of logic result.
Here at forum root boy and big john have nice examples to setup it. I bet if you try the same using ladder in 2 days you get it
For one timer control 3 rungs you can get it, C/C++ is best for complex task like motion control.
The classic ladder editor you can see the the status of variable, status of logic result.
Here at forum root boy and big john have nice examples to setup it. I bet if you try the same using ladder in 2 days you get it
Please Log in or Create an account to join the conversation.
- The Feral Engineer
- Offline
- Senior Member
Less
More
- Posts: 79
- Thank you received: 22
23 Dec 2020 18:52 - 23 Dec 2020 18:53 #193002
by The Feral Engineer
Replied by The Feral Engineer on topic new hal modul
If you'd like some help putting this together in classicladder, I'd be willing to give it a go
Last edit: 23 Dec 2020 18:53 by The Feral Engineer.
Please Log in or Create an account to join the conversation.
23 Dec 2020 20:49 #193019
by chris@cnc
Thanks for the offer but the module works great and the code in the Hal is very short. So far all of my options have been very simple and I didn't really need the ladder. And this was one of the last ones and I didn't want to start with it. Maybe with the next machine. My last option is to be a 4th axis. It should be switchable from velocity to position control. I would like to be able to program speed or angle one day. And that's more difficult than expected. If you have an idea that would be great. The problem is to configure a second spindle that can also be a c-axis.
Replied by chris@cnc on topic new hal modul
If you'd like some help putting this together in classicladder, I'd be willing to give it a go
Thanks for the offer but the module works great and the code in the Hal is very short. So far all of my options have been very simple and I didn't really need the ladder. And this was one of the last ones and I didn't want to start with it. Maybe with the next machine. My last option is to be a 4th axis. It should be switchable from velocity to position control. I would like to be able to program speed or angle one day. And that's more difficult than expected. If you have an idea that would be great. The problem is to configure a second spindle that can also be a c-axis.
Please Log in or Create an account to join the conversation.
Time to create page: 0.070 seconds