new hal modul

More
5 years 10 months ago - 5 years 10 months ago #192122 by chris@cnc
Replied by chris@cnc on topic new hal modul

Grotius wrote: Hi Chris.
Good luck !


Many Thanks Grotius. I can feel and see your smile ...:)
I will try it in the next few days

Many Thanks rodw that you point out that my idea will not work. I had not understand what grotius written.
Could you send me a link for some code examples. One big question is how input halui.program.run or is not possible to input nc signals?
Last edit: 5 years 10 months ago by chris@cnc.

Please Log in or Create an account to join the conversation.

More
5 years 10 months ago #192127 by rodw
Replied by rodw on topic new hal modul
The best way to learn programming is to read code. All of the standard code for components lives on git here
github.com/LinuxCNC/linuxcnc/tree/master/src/hal/components
Pick one of the simple components like or2 or and2 that you use and understand, then review the source for it.

The idea behind hal is that each component is stand alone iits own compartment so if it fails, everything else still works. So the only way to use another pin such as halui.program-on is to create a new in pin of the same data type and use a hal net statement to connect it to the in pin.

There are also many ways to skin a cat in C. Grotius used a hal variable called period to count milliseconds and convert it to seconds for your timer. There is another implicit varuable called fperiod which counts in seconds so I would probably do it like this because we are already using floating point numbers.
Code:
// Timer totalnsec += fperiod;

where using += is shorthand for totalnsec = totalnsec + fperiod;
Its cleaner and easier to read.

floating point numbers are much bigger and take more processing overhead to work with so we only use them when we have to but that is probably a hangover from an earlier era where PC's did not have the grunt they do today. But think of that if you are working with an arduino.
The following user(s) said Thank You: chris@cnc

Please Log in or Create an account to join the conversation.

More
5 years 10 months ago #192160 by chris@cnc
Replied by chris@cnc on topic new hal modul
For my first lesson not so bad. Modul is working and timer is one include? May i can count them
with original timer example i got error
Code:
mist.comp: In function ‘_’: mist.comp:71:12: error: invalid storage class for function ‘__comp_get_data_size’ mist.comp:71:1: error: expected declaration or statement at end of input mist.comp: At top level: mist.c:45:12: warning: ‘__comp_get_data_size’ used but never defined static int __comp_get_data_size(void); ^~~~~~~~~~~~~~~~~~~~


Warning: Spoiler!

Please Log in or Create an account to join the conversation.

More
5 years 10 months ago #192183 by rodw
Replied by rodw on topic new hal modul
I think in your first example you had a data type error becasue you had a bit as the input pin (which can only be 0 or 1) and you were using it to set it to 300. That likely explains the error messages.

Please Log in or Create an account to join the conversation.

More
5 years 10 months ago #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?

Please Log in or Create an account to join the conversation.

More
5 years 10 months ago #192233 by rodw
Replied by rodw on topic new hal modul

Grotius wrote: @ 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.

Time to create page: 0.332 seconds
Powered by Kunena Forum