I using the Arduino mega to control a motor via VFD and 4-20ma transmitter. The transmitter is transmitted via i2c as well as the relay. I'm using a nextion display to input parameters like test time and pulley diameter.Not sure whats going on. I have one on my desk that's running the same test and it hasn't froze at all.
PS i am new to this forum. So please elaborate
Thank you
Please read 'how to use this forum - please read' (big clue in the title) then go back and post your code in code tags.
Many people here don't want to download an ino file then upload it to their IDE to read it when it could just as easily be posted here. Also are accessing this forum on their mobile phones, no IDE there.
I am no expert however your code looks good. Something not talked about much is that the I2C bus can hang up an Arduino library dependent if a peripheral does not respond. I find this by having it serially print a number to the debug console each time it goes to send something to the I2C. Typically it will go to the same spot. I usually comment that out and try again and if it happens at a different spot I am fairly sure it is the I2C buss, I am basing this on the fact your driving motors and they can generate noise transients. These transients typically get into the peripheral and cause it to fault by changing a counter state or something like that. First be sure the Ardunio is not powering any off board devices. Be sure everything is properly bypassed. It appears to be power supply related but again I am guessing. If you have a scope be sure the I2C wave forms are switching properly, including rise and fall times. Be sure that the pull ups are installed.
Good Luck & Have Fun!
Gil