Machsupport Forum

Mach Discussion => Brains Development => Topic started by: zafarsalam on December 05, 2011, 11:18:05 PM

Title: Mach3, Arduino, Modbus and MPG
Post by: zafarsalam on December 05, 2011, 11:18:05 PM
Hi,

I've been successful in communicating with an Arduino Uno though modbus. Analog input, output, LED's, buttons and all. Why Arduino? Instead of Pokeys, ModIO or Cubloc? Because it's easily available where I am.

Today I tried MPG with Arduino and found it smoother than Pokeys. I am using ModIOMPG brain for the MPG. The only problem is that the axis keeps on rolling for almost half a second when I stop rotating the MPG. I am not using MPG tick count in the brain. Not sure how to calculate it in my Arduino. Is this the reason for this behaviour of MPG or do I need to tweak some other settings in Mach. I've tried different baud rates but they don't make any difference.

Another thing I've noticed is that when I switch to single or multi-step mode from velocity mode and then back to the velocity then the axis jog speed slows down to one fourth of the previous one. When I restart Mach, I can jog at full speed once again. I am running it on Mach V3.042.020.

Zafar
Title: Re: Mach3, Arduino, Modbus and MPG
Post by: Chaoticone on December 06, 2011, 12:20:21 AM
Depending on the MPG mode, step size and how fast you crank the wheel you can over run with a MPG wired straight to a Parallel port too.  You can request steps faster than your machine can travel if you aren't careful.  I'm not sure if this is whats going on in your case but I have seen this. You may want to wire the mpg straight to some inputs and by pass the arduino and Brain for testing.

Brett 
Title: Re: Mach3, Arduino, Modbus and MPG
Post by: zafarsalam on December 06, 2011, 12:39:10 AM
You can request steps faster than your machine can travel if you aren't careful.  I'm not sure if this is whats going on in your case but I have seen this.

Brett,
This situation you described happens in multiple steps mode when feed rate is set too low. This happens on PP too. In my case the overrun is with the velocity mode. The step mode is behaving similar to a PP and I have no problem with that.

Zafar
Title: Re: Mach3, Arduino, Modbus and MPG
Post by: zafarsalam on December 06, 2011, 06:12:28 AM
I tried the same mpg on PP and it works perfectly. With brains and modbus running, the MPG1 Velocity DRO on the settings page shows lag with the MPG movement. I suspect that's the culprit. Is there a fix for that  :-\

Zafar
Title: Re: Mach3, Arduino, Modbus and MPG
Post by: poppabear on December 12, 2011, 07:30:24 AM
Hey Zafar,

    For Velocity MPG stuff, you need the "MPG Tick" in brains, basically your device will need to send some kind of Clock or Tick signal. Mach then uses that tick
to see how "fast" vs. time your turning the MPG per scan.

Lag: You are going to have a LAG in MPG across the modbus, simple fact is, the modbus is only serviced once per 1/10th of a second. So if your turning quickly the MPG, and then stop, you still have some "build up" in the count register that is late data, and Mach will have to service that buffer when it comes around again.

TCP Modbus is somewhat faster, since it does not have the slow max speed of serial, I can turn a MPG pretty fast with TCP, but still in the end, it is still in Machs update loop. Nothing will be as fast as machs native engine.

scott