Machsupport Forum

Mach Discussion => Brains Development => Topic started by: oscbe112 on January 28, 2012, 09:32:47 AM

Title: Arduino -> modbus -> Brain
Post by: oscbe112 on January 28, 2012, 09:32:47 AM
Hi Guys,

Building a arduino[modbus] based Pendant for my machine but has run in some trouble with brain, plz help


1. I'm jogging the axis by buttonpress. When using the buttons I want it to jog while I press the buttons, just like the binded keys at my keyboard. It starts jogging but never stops! What am I missing?

# It haven't crashed. Everything else works.
# Keyboard jogging works
# "Cont jog" is selected
# According to control brain it all works, the input is turned on only when pressed.
# When trying in "Step mode" it works just fine, it steps the amount selected in "incremental step".

2. I'm using 2 analog inputs FRO and Jog%. One of the registers has stopped working, when I use another one it works but this is strange. The Arduino handles this registers the same way. Is there a limit of registers you can use (I'm using 22)? Is there some known bug causing this?

3. How do you configure brain to actuate a button on the screen that isnt in the buttonlist?
Title: Re: Arduino -> modbus -> Brain
Post by: poppabear on January 28, 2012, 11:00:54 AM
Hi Guys,

Building a arduino[modbus] based Pendant for my machine but has run in some trouble with brain, plz help


see below:

1. I'm jogging the axis by button press. When using the buttons I want it to jog while I press the buttons, just like the binded keys at my keyboard. It starts jogging but never stops! What am I missing?

>>>>>>>>>>>>>>>>>>in Brains there are "Stop Jog" commands as well, you will need to integrate that so it will stop moving when you let go.

# It haven't crashed. Everything else works.
# Keyboard jogging works
# "Cont jog" is selected
# According to control brain it all works, the input is turned on only when pressed.
# When trying in "Step mode" it works just fine, it steps the amount selected in "incremental step".

2. I'm using 2 analog inputs FRO and Jog%. One of the registers has stopped working, when I use another one it works but this is strange. The Arduino handles this registers the same way. Is there a limit of registers you can use (I'm using 22)? Is there some known bug causing this?

>>>>>>Havent played with the ardino so couldnt tell you

3. How do you configure brain to actuate a button on the screen that isnt in the buttonlist?

>>>>>>>>No direct way to do that, the best work around, is to set an ULED with the Brian, then have the Macro-pump also execute the code that is in that custom button.
>>>>>>>>make sure you put an Interlock in the MP so that it will only "Hit" that code once per push and release of your button.

Scott
Title: Re: Arduino -> modbus -> Brain
Post by: oscbe112 on January 28, 2012, 12:50:43 PM


1. Ok I got it. But having problem with the AND statement. It only works for one of the two inputs. See attached pictures

2. I suspect that the bug is caused on the other end.

3. Hmm..., no shortcut here  :-\


Thanks Poppabear
Title: Re: Arduino -> modbus -> Brain
Post by: oscbe112 on February 19, 2012, 04:54:22 AM
Anyone that can help me with the AND statements?
Title: Re: Arduino -> modbus -> Brain
Post by: poppabear on February 19, 2012, 09:01:00 AM
ok, that is an easy one..........  hehehee

the issue is according to your screen shots, for your and to work, BOTH of your inputs have to be OFF at the same time, so that the inverts flip it and pass both of them as ON to your AND block. In both screen shots, one of them is ON, and the other is OFF.......

For the AND to function, with the invert on both its feeds being ON, you will need BOTH of your inputs to be OFF at the same time. The Brian only reads what is in the input, so your Arduino is the one "setting" those two inputs. So you need to look at your Arduino code, and when you want the JOGX in M3 to push the off button, then the Ard, needs to send two "0's" one in each MB register.

Scott
Title: Re: Arduino -> modbus -> Brain
Post by: stirling on February 19, 2012, 09:41:29 AM
Hi Scott - I think what our man is saying is that in the bottom pic he's getting a "true" out of the AND gate and he SHOULDN'T be.

Ian
Title: Re: Arduino -> modbus -> Brain
Post by: poppabear on February 20, 2012, 08:36:19 AM
Hi Ian,

   Yeap, your right, sorry I missed that.........    :-[

Ok, do these 5 (possible) things to see if it resolves.

1).  Go into editor, and delete your complete last rung, and redo it, see if it works then... If NOT #2.
2).  Go into editor delete that last rung, then make a new brain call it part2 or what ever, and put JUST that problem rung in it... if not #3
3).  If that fails, Edit the part2 brain, in where you keep your inputs, but pass that data (as a no-op) to 2 unused UDROs.
      Then in the macro pump, write a interlock script that looks at those two dros, and does a button push depending on their and'ed value.
      you can use "NOT" key words to in effect "invert" their value if your using them as Boolean's..... if not #4
4).  Delete the entire brain, and rebuild a new one from scratch..........  if not #5
5). Scrap the Brian stuff, and just do it all in a macro pump, or periodic macro.

scott
Title: Re: Arduino -> modbus -> Brain
Post by: stirling on February 20, 2012, 01:50:04 PM
5). Scrap the Brian stuff, and just do it all in a macro pump, or periodic macro.

 ;D ;D ;D

Ian
Title: Re: Arduino -> modbus -> Brain
Post by: oscbe112 on February 26, 2012, 02:23:36 PM
1. Fail !
2. Works

Its weird because I've already tried this, but well now it works!

Thanks for the help
Title: Re: Arduino -> modbus -> Brain
Post by: zafarsalam on February 27, 2012, 09:07:13 PM
I've also noticed that only the first 10 AND based rungs work in a brain. All the AND's after the 10th one don't get triggered in any case. I break the brain into 2 parts for them to work. Is it a bug with brains?

Zafar
Title: Re: Arduino -> modbus -> Brain
Post by: fishin_fl on October 15, 2014, 09:55:20 AM
Oscbe112,

I saw you thread and thought your pendant looked cool.  I am in the middle of a build for a pendant.  Have not gotten to far but thought you could give some insight on the pendant you designed.  I was going to use a Cmore touchscreen at my table to jog axis around, turn vacuum zones on/off, ect.  When I saw you integrated the Arduino to mach3 and saw something that looks to be touch screen on yours it got my brain going.  Do I really need the cmore and all the code to make this work?   I was maybe thinking a 5 or 7" touch screen TFT adapted on the arduino mega maybe with hard estop on the side or front, and a couple of selector switches.  Any help would be greatly appreciated.

Thanks,
Brooks Nelson
Title: Re: Arduino -> modbus -> Brain
Post by: oscbe112 on November 08, 2014, 06:55:47 AM
Hi!
Always fun to inspire others, please let us know of your progress.

When it comes to my pendant project I concider it finished. Its not the best approach if you want to be able to change and configure a lot, then you'd better go with a keyboard and map the keys in mach3. But with that said it works great for what I intended.
The only thing that is missing is the handles on the sides (see pictures).. actually bought a 3D printer.. so I'm just lazy to not have done them yet.


So unfortunately I didnt find my arduino sketch but its built on this library: https://sites.google.com/site/jpmzometa/arduino-mbrt/arduino-modbus-slave
On the arduino side I'm just sending commands to the mach3 via modbus, its stored in variables, the brain decides what happens when the variables change.

Sure you could have a screen and touch interface. But I think its a lot of work with arduino.. And also i'd most definitely prefer fysical buttons when interfacing a moving cnc machine..
Just a thought from my side, if you need touchscreen interface, maybe raspberry pie could be an alternative? cheep, hdmi output, usb for interfacing touchscreens, easy to program.