Question

I have written an G code interpreter/control app for a cnc machine in objective C. Everything runs fine for the first 20 - 30 secs but after that the whole thing stops for an other 20 sec and resumes super slow. I made a video so you can see for your self: video (about a minute). As far as I can tell it doesn't skip steps or something like that it just goes really slow.

In my X-code console I can see that code is interpreted at the normal speed (using a NSLog every time a byte is written).

I use the IOkit from the Arduino Cocoa reference to communicate. I have tried a lot of different Baudrates and sometimes that will prolong the time it keeps working correctly but eventually it always slows down.

I some thing after this line needs to clean up the serial buffer or something

// send a byte to the serial port
void writeByte(char val) {
        write(serialFileDescriptor, [[NSString stringWithFormat:@"%c" , val]  cStringUsingEncoding:NSUTF8StringEncoding], 1);

}

Update: I am developing the app on my 17"MBP running OS X 10.9, I tried this on a other 13"MBP running 10.9.1 same thing happens but when I use yet an other 13"MBP running 10.6.8 it works fine!

Any ideas on what is happening here?

Was it helpful?

Solution 2

As it turned out there was a rogue Serial.Write() some were in the Arduino code (I placed there to find an other bug, and just forgot about it) The statement slowly filled the serial buffer.

OTHER TIPS

Probably you are writing faster than baudrate, but you will slow down only when output buffere will be full, because you need to wait to write. This can be solved or worked around in many ways

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top