Engineering, Research and Machine Control with LiveCode

LiveCode makes an ideal tool for use in the fields of engineering, research, machine or process control. We interviewed Charlie Faddis, Technology Director and co-founder of Prototek Corporation. Prototek Corporation are based in Seattle, Washington and are the inventors and manufacturers of the technology that is used to locate underground utilities.

Charlie chose LiveCode to create a low frequency radio receiver, which runs on a virtual machine on an embedded chip. This device is pushed through pipes to clean them and is used to locate the plug if it gets stuck. He wrote both the radio frequency receiver and the virtual machine for the embedded device using LiveCode. We asked Charlie to tell us a little more about what his company does and why he chose LiveCode for this fascinating project.

“When you see the lines painted over the streets in different colors when they’re getting ready to dig something up, that’s our technology that they are using. There are a number of companies that make this type of equipment but we make the best. Specifically, we make the only radio system in the world that will transmit through solid steel. Most physicists will tell you that that's impossible because it's a Faraday cage. But the petroleum industry requires this because their lines are thick steel pipes and they have to put plugs in the pipes to clean them. They’ll push these foam rubber plugs through the pipe for 10, 20 or even 50 miles to clean the pipe. If the plug gets stuck then they have a very serious problem because it takes that line out of service until they can find the plug. They’ve had to dig up as many as 10 miles of pipe in order to find the problem.”

“So we designed this transmitter that goes into the plug, using a very low frequency of just 16 Hz. Now the problem with building a radio receiver at that frequency in hardware is that it would have to be the size of a skyscraper and not terribly portable! So we had to build that receiver in software rather than in hardware. We built that receiver in LiveCode and it functions very well. We’re having trouble keeping product on the shelf because it’s functioning so well”

“The receiver runs on the embedded microprocessor. We had to change the target machine of LiveCode in order to get it to run on that microprocessor. So we constructed a virtual machine that would have the foundation we needed to execute a subset of the LiveCode language.

We asked Charlie if that took a lot of effort. “It took about a week and a half to write the virtual machine, because we built the virtual machine itself using LiveCode. It really is the world’s easiest programming language!”

“That was the first challenge, the second was that we had to change the LiveCode language so that it could handle interrupts. LiveCode’s timing is good to about a millisecond and we need sub-millisecond timing in order to write this receiver. So we introduced the concept of interrupts into LiveCode, in the form of a clock event. You can think of it like someone tapping the mouse and sending a message, but in this case it’s an event that comes every few microseconds. We added the ability to interrupt the handler that was running and turn control over to another one in order to process the event. So we extended the LiveCode language enough to handle that. And then of course we had to figure out how to make a compiler for all of this. We actually use your compiler, because all of this was accomplished in the namespace of the language.”

“The only thing we had to modify about LiveCode was the editor so that it would indent the keywords of our language rather than the keywords of your language.”

We asked Charlie why he chose to do it in LiveCode rather than in another language?

“Well if we had chosen C++ to do it we would be looking at year or two of effort to design such a thing. And we were way over budget and behind schedule. So I said, we’re not going use C++, we’ll do it in LiveCode and get it done in about 8 weeks. Which we achieved – well perhaps in 12!”

“Well if we had chosen C++ to do it we would be looking at year or two of effort to design such a thing. And we were way over budget and behind schedule. So I said, we’re not going use C++, we’ll do it in LiveCode and get it done in about 8 weeks. Which we achieved – well perhaps in 12!”

Where there any other notable benefits of using LiveCode for this?

“The three most important aspects of programming are testing, testing, testing. The wonderful thing about LiveCode when using it for development on something like a microchip is that it’s so easy to add a new test. My development screen is split up so that around about 80% of the screen is devoted to testing functions, with the remaining 20% dedicated to writing and debugging code. So if I conceive of a test I simply drag and drop a button onto the screen, it talks through the USB port to the chip and I can run a test. Once I’ve defined that test it’s always there right next to the source code. If I modify that source code a year from now all I have to do is click that button and it will run that test. Some of those buttons are sliders, maybe a field of data that comes back.”

“Given we are working with radio waves in real time, one of the key things we needed was to create a graph like an oscilloscope. So we inserted a feature that looks like a breakpoint you put in a source code. But it’s really what we call a probe point, because a breakpoint stops the code but when you’re processing radio signals in real time you really don’t want to stop execution. The probe point causes the handler to send data back through the serial port asynchronously in the remaining machine cycles that are available in our embedded chip. The interrupts take care of the main processing so whatever extra capacity the process has can be used to transmit that data back and LiveCode beautifully graphs it in color just like an oscilloscope with waves. My analog engineer can come over and look at the waveform and say that you need to adjust one coefficient or another.”

prototek

                                                                               A testing graph screen

“Thank you for a great product. It has saved me hundreds of thousands of dollars of engineering budget. No question about it.”

“Thank you for a great product. It has saved me hundreds of thousands of dollars of engineering budget. No question about it.”

http://www.prototek.net/