• Hanzito (unregistered)

    If the timing is critical, why is it Python?

  • LZ79LRU (unregistered) in reply to Hanzito

    So that when the inevitable failure happens the evidence is concealed by a conveniently placed giant foot.

  • (nodebb) in reply to Hanzito

    Because Python handles microsecond precision timing just fine, and in my experience, the hardware and communications medium is far slower than Python anyway.

  • kolik (unregistered) in reply to Hanzito

    TRWTF is the company. or python's GIL. idk

  • (nodebb)

    I grew up in a time when communicating with hardware mean reading signal charts. So, hard? No. Annoying? Yeah, maybe.

  • (author) in reply to Hanzito

    Timing can be critical, but also on relatively slow paces- on a lot of robotics systems, you might need to make sure something happens once in a given interval and that interval might be on the order of milliseconds. No big deal to hit that timing in your main loop- if nothing in the main loop pends for hundreds of milliseconds waiting for a timeout.

  • Sauron (unregistered)

    High-tech agriculture...

    Imagine the Food of the Future, reaped with Super-Connected-Crypto-Metaverse-ChatGPT-Tractors.

    Think about it. What could possibly go wrong?

  • LZ79LRU (unregistered)

    To be fair, if I understand the article correctly this is massive agricultural machinery we are talking about. You know, stuff like tractors weighing several tons and towing all sorts of sharp and potentially moving tools. Or combine harvesters that slice and dice corn and wheat, process them further and eject shredded bits out a chimney. Stuff like that.

    So what if we skip a signal? What's the worst that can happen?

    I mean, worst come to worst these things will always be surrounded by squishy humans and maybe even animals milling about the sharp bits so they can notice things have gone wrong in time to scream about it.

  • Foo AKA Fooo (unregistered) in reply to Sauron

    @SoylentGreen:

    Don't worry, nothing will go wrong, trust us.

  • Peter Smith (github)

    I worked with a very smart person who had earlier worked (doing software) at a potato factory in Idaho. His comment: "you only have to dump five tons of potatoes on the factory floor once to get a lot more careful with your code."

  • BeeKay (unregistered)

    I had a similar situation writing code for an industrial controller — in 1979. The device monitored a bunch of sensors, and periodically had to make a phone call to a modem and transmit a report. The “modem” in the device was a software modem; I had to switch a relay to dial the phone number (no touch tone generator in the device, just, pulse dialing) toggle a register to send the ones and series. Of course, the monitoring had to continue while the report was being transmitted, so the comms section of the software had to be non-blocking.

    My manger asked why it was taking so long, ignored my explanation and whipped up a phone dialer/transmitter — in Forth. Now Forth has some nifty features, but using it would mean including the Forth runtime, his code, AND the sensor monitoring all in a SIXTEEN kilobyte PROM.

    I ignored him and finished the non-blocking interrupt driven dialer/transmitter, we shipped it and went and installed it at the client site, and on that trip I learned NOT to match drink-for-drink with the marketing team.

  • Verisimilidude (unregistered) in reply to Peter Smith
    Comment held for moderation.
  • andru (unregistered) in reply to Hanzito
    Comment held for moderation.
  • andru (unregistered)
    Comment held for moderation.
  • (nodebb) in reply to Hanzito

    Python isn't too bad as what matters in realtime code is that you keep servicing things like event loops regularly and that an event handler takes no longer than it should. How long that is depends on the particular setup. You don't use it where you have precise sub-microsecond constraints... but a lot of realtime code isn't like that.

    I'd not be totally surprised if the typical time cycle in agricultural applications was on the order of a tenth of a second, and Python is usually plenty fast enough for that.

  • Industrial Automation Engineer (unregistered) in reply to Remy Porter
    Comment held for moderation.
  • Hanzito (unregistered)

    I checked the "microsecond precision", but the code shown in the example, supplied with minimal stubs to get it to run without errors, takes on average 1.9µs on a 2.6GHz i7. Getting Python to do anything meaningful in a microsecond is simply not possible, let alone write an application with microsecond precision timing in it.

  • Graculus (unregistered) in reply to Peter Smith

    Potatoes? Try automotive engines written in FORTH. Set the rpm to idle at what you think is 1000rpm and see it rattle through the gears to 10000rpm and you learn the difference between 1000 1000. and 1000.0

Leave a comment on “Sensing a Problem”

Log In or post as a guest

Replying to comment #:

« Return to Article