Use pi as USB - RS232 translator
J Barber (2892) 1 post |
Have a work project. Need to replace old industrial power supply with with RS232 interface new version using USB interface. Here is the issue. Original power supply is in a production tool. Tool computer (SPARC based single board computer) queries power supply once per second on operating condition (ie WATER TEMPERATURE.. wait 1 second…. WATER CONDUCTIVITY… wait 1 second… etc). Tool software is a proprietary compile based on UNIX. Can’t change control computer. Looking at making a raspberry PI 2 into a translator. What I need to do is setup an RS232 connection from the PI to feed data to the control computer exactly when asked. Can not use any login permissions, passwords, prompts. Must be a specific value only. No funny characters. Have done a quick and dirty using a C script on an old SPARC20, but it has proven to be a little unreliable. My scripting abilities in C are limited at the “sleep” command. If I don’t throttle the response at all, data is fed too quickly and the computers lockup in a continuous conversation with themselves. If I throttle the script with a 1 second delay, response is too slow and the connection times out at the control computer. Any loss of connections and the command / answer stream gets out of sequence. What I need to do is setup a PI to answer 1 of 9 questions with an exact value, and only that value but I also need to delay the response by about 400 ms. Is RISC a good alternative or should I pursue LINUX? Thoughts are apreciated |
Dave Higton (1515) 3526 posts |
It may be that RISC OS will do the job – the biggest problem I see in answering your question is that you’ve only described part of the system. If I understand correctly, the link between SPARC SBC and Pi will be via RS232, and the link between power supply and Pi will be via USB. The RS232 side is easy; the only problem you’ll have to solve is to provide hardware level shifters between 3.3V logic levels on the Pi and RS232 levels on the SBC side. USB is a much more complicated interface. Firstly, can I take it that the power supply is a USB device (rather than a host)? It probably is. OK, do you know the protocol that the power supply speaks? Is it a proprietary one? Is the specification available from the power supply manufacturer? Or is it a device for which a published USB Class Specification exists? You’re going to have to work out how to communicate over USB, whatever OS you choose. I don’t know how familiar you are with writing USB device drivers, or with the USB protocol in general. In case you’re not: USB is very clever and very powerful indeed, but it’s a rather complicated, multi-layer, binary protocol, an order of magnitude more complicated than RS232. |