Hello Guest it is April 19, 2024, 09:55:26 PM

Author Topic: modbus and arduino sketch working exept for PWM  (Read 10202 times)

0 Members and 1 Guest are viewing this topic.

modbus and arduino sketch working exept for PWM
« on: March 03, 2013, 06:43:16 AM »
hello,
I'm pretty new in mach and also in brain , and i would like to learn more about that so i can convert a cheap wood router into a Laser engraver...
for that i would like to use modbus so i can send different power to the laser diode according to the depth of cut:

ex: 2mm deep would be full power and 0 would be 0 laser power .

i found the a zip file that is called arduino modbus that comes with a very good documentation called :Arduino Modbus, Complete, Documented and free.pdf

-now my question is , why when i sent the value 00FF with the modbus tester it works well and fire my laser  (see brain picture attached)

but no way to get it work when i try in brain (see pwm test brain attached)

do i miss something?

-and by the way is there a way to add in the formula some sort of limit like in C programing (max) so i can limit the whole values from PWM 2 to 100 for example with a modbus linked Pot

- is there any way to get a list of the command we can put in the formula boxes

thank you in advance for your precious help!

Offline Tweakie.CNC

*
  • *
  •  9,198 9,198
  • Super Kitty
    • View Profile
Re: modbus and arduino sketch working exept for PWM
« Reply #1 on: March 03, 2013, 07:34:13 AM »
Hi Fefenin,

Welcome to the forum.

Going off at bit of a tangent…
Obviously it depends on your intended X axis speed but I have found that the Mach3 PWM is not updated fast enough to be really useful for laser power control unless you only require infrequent changes, such as when vector engraving then profile cutting etc.

I would be interested to know what type of laser engraving work you are planning?

Also you may find this thread (and others links within that thread) of interest; http://www.machsupport.com/forum/index.php/topic,23584.0.html


Tweakie.
PEACE
Re: modbus and arduino sketch working exept for PWM
« Reply #2 on: March 03, 2013, 09:17:39 AM »
thank's for that , i'll consider changing my methode but i still would like to learn how to use PWM for other project maybe...

anyways i'll read the post you gave me it looks promissing

thank for your help

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: modbus and arduino sketch working exept for PWM
« Reply #3 on: March 03, 2013, 11:36:41 AM »
Hi fefenin - I may be misunderstanding but you have the arduino generating the PWM NOT Mach - yes? and the value you send over modbus to the arduino is used to set the duty cycle. Is that the case?

If so I've just tested your brain on arduino modbus and it works fine. -2 sends 255 and this is received fine. Likewise -1 sends 127 and 0 sends 0 etc.

Ian
Re: modbus and arduino sketch working exept for PWM
« Reply #4 on: March 03, 2013, 12:38:33 PM »
sorry it was a little blur , but yes, i'm using arduino to generate PWM. and when i write to the register it should change the value that control the duty cycle.

when i send it manually with the modbus tester it works fine for me as well, but when i run brain it doesn't change the dutycycle . (the laser stays off)

is there a way for me to see what i'm sending thru modbus in mach3 (LCD emulation or so?)

the link of the sketch i use and the documentation is here : http://www.machsupport.com/forum/index.php?topic=21105.0

and i did configure all the inpouts outputs  analog and PWM in arduino , and as i say before , everything works when i write manually to the registers???

i'm kind of lost

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: modbus and arduino sketch working exept for PWM
« Reply #5 on: March 03, 2013, 12:50:32 PM »
I use my own modbus code on arduinos so I've not used the code you've linked to. HOWEVER if what you have works from the modbus test panel then that would suggest your arduino code AND your modbus setup appears to be working. As I said - your brain works here so I'd look there for issues. Have you RELOADED and RE-ENABLED your brain? Have you looked at "brain control../brain view"?

Ian
Re: modbus and arduino sketch working exept for PWM
« Reply #6 on: March 03, 2013, 01:07:37 PM »
yes i did reload and had a look at the viewer.

in fact my real brain i s the one i post right now.


I'm not sure i get everything about the modbus configuration (what is the port column) . is there something wrong with my config??

i just know i need to send only the lower byte in the register for the pwm (00-FF).
« Last Edit: March 03, 2013, 01:11:33 PM by fefenin »
Re: modbus and arduino sketch working exept for PWM
« Reply #7 on: March 07, 2013, 07:54:06 AM »
Tweakie you were right i'm on to drop the PWM and go for the Zaxis controlled absolute sensor , it sound way easier and i alreday order the sensor anyways...